replace nfs_ping with generic rpc_ping
This commit is contained in:
1 parent
58435e27ab
commit
b3fda3e6c1
6 files changed
+39
-10
No files matched your search
@@ -410,8 +410,9 @@ JNIEXPORT jobjectArray SIGAR_JNI(Sigar_getFileSystemListNative)
|
||||
return fsarray;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean SIGAR_JNI(NfsFileSystem_ping)
|
||||
(JNIEnv *env, jclass cls_obj, jstring jhostname)
|
||||
JNIEXPORT jboolean SIGAR_JNI(RPC_ping)
|
||||
(JNIEnv *env, jclass cls_obj, jstring jhostname,
|
||||
jint protocol, jlong program, jlong version)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return JNI_FALSE; /*XXX*/
|
||||
@@ -426,7 +427,9 @@ JNIEXPORT jboolean SIGAR_JNI(NfsFileSystem_ping)
|
||||
|
||||
hostname = JENV->GetStringUTFChars(env, jhostname, &is_copy);
|
||||
|
||||
retval = (sigar_nfs_ping((char *)hostname) == SIGAR_OK);
|
||||
retval =
|
||||
(sigar_rpc_ping((char *)hostname,
|
||||
protocol, program, version) == SIGAR_OK);
|
||||
|
||||
if (is_copy) {
|
||||
JENV->ReleaseStringUTFChars(env, jhostname, hostname);
|
||||
|
||||
@@ -5,8 +5,6 @@ import java.net.UnknownHostException;
|
||||
|
||||
public class NfsFileSystem extends FileSystem {
|
||||
|
||||
public static native boolean ping(String hostname);
|
||||
|
||||
String hostname = null;
|
||||
|
||||
public String getHostname() {
|
||||
@@ -30,7 +28,7 @@ public class NfsFileSystem extends FileSystem {
|
||||
}
|
||||
|
||||
public boolean ping() {
|
||||
return ping(getHostname());
|
||||
return RPC.ping(getHostname(), RPC.NFS);
|
||||
}
|
||||
|
||||
public String getUnreachableMessage() {
|
||||
@@ -43,6 +41,6 @@ public class NfsFileSystem extends FileSystem {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Sigar.load();
|
||||
System.out.println(NfsFileSystem.ping(args[0]));
|
||||
System.out.println(RPC.ping(args[0], RPC.NFS));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.hyperic.sigar;
|
||||
|
||||
public class RPC {
|
||||
|
||||
public static final int UDP = NetFlags.CONN_UDP;
|
||||
public static final int TCP = NetFlags.CONN_TCP;
|
||||
|
||||
public static final long NFS = 100003;
|
||||
|
||||
public static native boolean ping(String hostname,
|
||||
int protocol,
|
||||
long program,
|
||||
long version);
|
||||
|
||||
public static boolean ping(String hostname, long program) {
|
||||
return ping(hostname, UDP, program, 2);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user