jni adapter for udp v4 & v6 monitor added.

This commit is contained in:
Zhen Tang 2013-07-14 09:34:14 +08:00
parent 08bbb3fac5
commit a459d73a68
7 changed files with 254 additions and 0 deletions

View File

@ -156,6 +156,8 @@
<ClInclude Include="stdafx.h" />
<ClInclude Include="TCPv4Monitor.h" />
<ClInclude Include="TCPv6Monitor.h" />
<ClInclude Include="UDPv4Monitor.h" />
<ClInclude Include="UDPv6Monitor.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Common.cpp" />
@ -185,6 +187,8 @@
</ClCompile>
<ClCompile Include="TCPv4Monitor.cpp" />
<ClCompile Include="TCPv6Monitor.cpp" />
<ClCompile Include="UDPv4Monitor.cpp" />
<ClCompile Include="UDPv6Monitor.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -45,6 +45,12 @@
<ClInclude Include="PhysicalDiskMonitor.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="UDPv4Monitor.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="UDPv6Monitor.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
@ -74,5 +80,11 @@
<ClCompile Include="PhysicalDiskMonitor.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="UDPv4Monitor.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="UDPv6Monitor.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,51 @@
#include "stdafx.h"
#include "UDPv4Monitor.h"
#include "Common.h"
JNIEXPORT jobjectArray JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getCounterList
(JNIEnv * environment, jobject object)
{
list<wstring> counterList=UDPv4::GetCounterList();
list<wstring>::iterator iter;
long count=(long)counterList.size();
jobjectArray array=environment->NewObjectArray(
count,environment->FindClass("java/lang/String"),environment->NewStringUTF(""));
int i=0;
for(iter=counterList.begin();iter!=counterList.end();iter++)
{
environment->SetObjectArrayElement(array,i
,environment->NewStringUTF(GetUTF8String((*iter).c_str())));
i++;
}
return array;
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getDatagramsPerSecond
(JNIEnv * environment, jobject object, jint idleTime)
{
return UDPv4::GetDatagramsPerSecond(idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getDatagramsReceivedPerSecond
(JNIEnv * environment, jobject object, jint idleTime)
{
return UDPv4::GetDatagramsReceivedPerSecond(idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getDatagramsNoPortPerSecond
(JNIEnv * environment, jobject object, jint idleTime)
{
return UDPv4::GetDatagramsNoPortPerSecond(idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getDatagramsReceivedErrors
(JNIEnv * environment, jobject object)
{
return UDPv4::GetDatagramsReceivedErrors();
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getDatagramsSentPerSecond
(JNIEnv * environment, jobject object, jint idleTime)
{
return UDPv4::GetDatagramsSentPerSecond(idleTime);
}

View File

@ -0,0 +1,61 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_bench4q_monitor_performance_windows_UDPv4Monitor */
#ifndef _Included_org_bench4q_monitor_performance_windows_UDPv4Monitor
#define _Included_org_bench4q_monitor_performance_windows_UDPv4Monitor
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_bench4q_monitor_performance_windows_UDPv4Monitor
* Method: getCounterList
* Signature: ()[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getCounterList
(JNIEnv *, jobject);
/*
* Class: org_bench4q_monitor_performance_windows_UDPv4Monitor
* Method: getDatagramsPerSecond
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getDatagramsPerSecond
(JNIEnv *, jobject, jint);
/*
* Class: org_bench4q_monitor_performance_windows_UDPv4Monitor
* Method: getDatagramsReceivedPerSecond
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getDatagramsReceivedPerSecond
(JNIEnv *, jobject, jint);
/*
* Class: org_bench4q_monitor_performance_windows_UDPv4Monitor
* Method: getDatagramsNoPortPerSecond
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getDatagramsNoPortPerSecond
(JNIEnv *, jobject, jint);
/*
* Class: org_bench4q_monitor_performance_windows_UDPv4Monitor
* Method: getDatagramsReceivedErrors
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getDatagramsReceivedErrors
(JNIEnv *, jobject);
/*
* Class: org_bench4q_monitor_performance_windows_UDPv4Monitor
* Method: getDatagramsSentPerSecond
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv4Monitor_getDatagramsSentPerSecond
(JNIEnv *, jobject, jint);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,51 @@
#include "stdafx.h"
#include "UDPv6Monitor.h"
#include "Common.h"
JNIEXPORT jobjectArray JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getCounterList
(JNIEnv * environment, jobject object)
{
list<wstring> counterList=UDPv6::GetCounterList();
list<wstring>::iterator iter;
long count=(long)counterList.size();
jobjectArray array=environment->NewObjectArray(
count,environment->FindClass("java/lang/String"),environment->NewStringUTF(""));
int i=0;
for(iter=counterList.begin();iter!=counterList.end();iter++)
{
environment->SetObjectArrayElement(array,i
,environment->NewStringUTF(GetUTF8String((*iter).c_str())));
i++;
}
return array;
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getDatagramsPerSecond
(JNIEnv * environment, jobject object, jint idleTime)
{
return UDPv6::GetDatagramsPerSecond(idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getDatagramsReceivedPerSecond
(JNIEnv * environment, jobject object, jint idleTime)
{
return UDPv6::GetDatagramsReceivedPerSecond(idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getDatagramsNoPortPerSecond
(JNIEnv * environment, jobject object, jint idleTime)
{
return UDPv6::GetDatagramsNoPortPerSecond(idleTime);
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getDatagramsReceivedErrors
(JNIEnv * environment, jobject object)
{
return UDPv6::GetDatagramsReceivedErrors();
}
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getDatagramsSentPerSecond
(JNIEnv * environment, jobject object, jint idleTime)
{
return UDPv6::GetDatagramsSentPerSecond(idleTime);
}

View File

@ -0,0 +1,61 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_bench4q_monitor_performance_windows_UDPv6Monitor */
#ifndef _Included_org_bench4q_monitor_performance_windows_UDPv6Monitor
#define _Included_org_bench4q_monitor_performance_windows_UDPv6Monitor
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_bench4q_monitor_performance_windows_UDPv6Monitor
* Method: getCounterList
* Signature: ()[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getCounterList
(JNIEnv *, jobject);
/*
* Class: org_bench4q_monitor_performance_windows_UDPv6Monitor
* Method: getDatagramsPerSecond
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getDatagramsPerSecond
(JNIEnv *, jobject, jint);
/*
* Class: org_bench4q_monitor_performance_windows_UDPv6Monitor
* Method: getDatagramsReceivedPerSecond
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getDatagramsReceivedPerSecond
(JNIEnv *, jobject, jint);
/*
* Class: org_bench4q_monitor_performance_windows_UDPv6Monitor
* Method: getDatagramsNoPortPerSecond
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getDatagramsNoPortPerSecond
(JNIEnv *, jobject, jint);
/*
* Class: org_bench4q_monitor_performance_windows_UDPv6Monitor
* Method: getDatagramsReceivedErrors
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getDatagramsReceivedErrors
(JNIEnv *, jobject);
/*
* Class: org_bench4q_monitor_performance_windows_UDPv6Monitor
* Method: getDatagramsSentPerSecond
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL Java_org_bench4q_monitor_performance_windows_UDPv6Monitor_getDatagramsSentPerSecond
(JNIEnv *, jobject, jint);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -8,6 +8,8 @@ import org.bench4q.monitor.performance.windows.NetworkInterfaceMonitor;
import org.bench4q.monitor.performance.windows.PhysicalDiskMonitor;
import org.bench4q.monitor.performance.windows.TCPv4Monitor;
import org.bench4q.monitor.performance.windows.TCPv6Monitor;
import org.bench4q.monitor.performance.windows.UDPv4Monitor;
import org.bench4q.monitor.performance.windows.UDPv6Monitor;
public class Main {
static {
@ -111,6 +113,18 @@ public class Main {
System.out.println(elem);
}
UDPv4Monitor udpv4Monitor = new UDPv4Monitor();
String[] udpv4Counter = udpv4Monitor.getCounterList();
for (String elem : udpv4Counter) {
System.out.println(elem);
}
UDPv6Monitor udpv6Monitor = new UDPv6Monitor();
String[] udpv6Counter = udpv6Monitor.getCounterList();
for (String elem : udpv6Counter) {
System.out.println(elem);
}
MonitorServer monitorServer = new MonitorServer(5555);
monitorServer.start();
}