get our stats back by reflecting mxbeans correctly
This commit is contained in:
parent
8be7fde181
commit
3ec5cf6263
|
@ -157,12 +157,10 @@ public class OsProbe {
|
|||
*/
|
||||
private static Method getMethod(String methodName) {
|
||||
try {
|
||||
Method method = osMxBean.getClass().getMethod(methodName);
|
||||
method.setAccessible(true);
|
||||
return method;
|
||||
return Class.forName("com.sun.management.OperatingSystemMXBean").getMethod(methodName);
|
||||
} catch (Throwable t) {
|
||||
// not available
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ public class ProcessProbe {
|
|||
private static final Method getCommittedVirtualMemorySize;
|
||||
|
||||
static {
|
||||
getMaxFileDescriptorCountField = getMethod("getMaxFileDescriptorCount");
|
||||
getOpenFileDescriptorCountField = getMethod("getOpenFileDescriptorCount");
|
||||
getMaxFileDescriptorCountField = getUnixMethod("getMaxFileDescriptorCount");
|
||||
getOpenFileDescriptorCountField = getUnixMethod("getOpenFileDescriptorCount");
|
||||
getProcessCpuLoad = getMethod("getProcessCpuLoad");
|
||||
getProcessCpuTime = getMethod("getProcessCpuTime");
|
||||
getCommittedVirtualMemorySize = getMethod("getCommittedVirtualMemorySize");
|
||||
|
@ -163,12 +163,23 @@ public class ProcessProbe {
|
|||
*/
|
||||
private static Method getMethod(String methodName) {
|
||||
try {
|
||||
Method method = osMxBean.getClass().getDeclaredMethod(methodName);
|
||||
method.setAccessible(true);
|
||||
return method;
|
||||
return Class.forName("com.sun.management.OperatingSystemMXBean").getMethod(methodName);
|
||||
} catch (Throwable t) {
|
||||
// not available
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a given method of the UnixOperatingSystemMXBean,
|
||||
* or null if the method is not found or unavailable.
|
||||
*/
|
||||
private static Method getUnixMethod(String methodName) {
|
||||
try {
|
||||
return Class.forName("com.sun.management.UnixOperatingSystemMXBean").getMethod(methodName);
|
||||
} catch (Throwable t) {
|
||||
// not available
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue