use of sun.jvmstat.monitor.MonitoredHost in project jdk8u_jdk by JetBrains.
the class HotSpotAttachProvider method testAttachable.
/**
* Test if a VM is attachable. If it's not attachable,
* an AttachNotSupportedException will be thrown. For example,
* 1.4.2 or 5.0 VM are not attachable. There are cases that
* we can't determine if a VM is attachable or not and this method
* will just return.
*
* This method uses the jvmstat counter to determine if a VM
* is attachable. If the target VM does not have a jvmstat
* share memory buffer, this method returns.
*
* @exception AttachNotSupportedException if it's not attachable
*/
void testAttachable(String id) throws AttachNotSupportedException {
MonitoredVm mvm = null;
try {
VmIdentifier vmid = new VmIdentifier(id);
MonitoredHost host = MonitoredHost.getMonitoredHost(vmid);
mvm = host.getMonitoredVm(vmid);
if (MonitoredVmUtil.isAttachable(mvm)) {
// it's attachable; so return false
return;
}
} catch (Throwable t) {
if (t instanceof ThreadDeath) {
ThreadDeath td = (ThreadDeath) t;
throw td;
}
// we do not know what this id is
return;
} finally {
if (mvm != null) {
mvm.detach();
}
}
// we're sure it's not attachable; throw exception
throw new AttachNotSupportedException("The VM does not support the attach mechanism");
}
use of sun.jvmstat.monitor.MonitoredHost in project jdk8u_jdk by JetBrains.
the class JCmd method getMainClass.
private static String getMainClass(VirtualMachineDescriptor vmd) throws URISyntaxException, MonitorException {
try {
String mainClass = null;
VmIdentifier vmId = new VmIdentifier(vmd.id());
MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId);
MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1);
mainClass = MonitoredVmUtil.mainClass(monitoredVm, true);
monitoredHost.detach(monitoredVm);
return mainClass;
} catch (NullPointerException e) {
// Handle this gracefully....
return null;
}
}
use of sun.jvmstat.monitor.MonitoredHost in project jdk8u_jdk by JetBrains.
the class JCmd method listCounters.
private static void listCounters(String pid) {
// Code from JStat (can't call it directly since it does System.exit)
VmIdentifier vmId = null;
try {
vmId = new VmIdentifier(pid);
} catch (URISyntaxException e) {
System.err.println("Malformed VM Identifier: " + pid);
return;
}
try {
MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId);
MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1);
JStatLogger logger = new JStatLogger(monitoredVm);
// all names
logger.printSnapShot(// all names
"\\w*", // comparator
new AscendingMonitorComparator(), // not verbose
false, // show unsupported
true, System.out);
monitoredHost.detach(monitoredVm);
} catch (MonitorException ex) {
ex.printStackTrace();
}
}
use of sun.jvmstat.monitor.MonitoredHost in project jdk8u_jdk by JetBrains.
the class CR6672135 method main.
public static void main(String[] args) {
int vmInterval;
int hostInterval;
try {
MonitoredHost localHost = MonitoredHost.getMonitoredHost("localhost");
Set vms = localHost.activeVms();
Integer vmInt = (Integer) vms.iterator().next();
// NOI18N
String uriString = "//" + vmInt + "?mode=r";
VmIdentifier vmId = new VmIdentifier(uriString);
MonitoredVm vm = localHost.getMonitoredVm(vmId);
vm.setInterval(INTERVAL);
localHost.setInterval(INTERVAL);
vmInterval = vm.getInterval();
hostInterval = localHost.getInterval();
} catch (Exception ex) {
throw new Error("Test failed", ex);
}
System.out.println("VM " + vmInterval);
if (vmInterval != INTERVAL) {
throw new Error("Test failed");
}
System.out.println("Host " + hostInterval);
if (hostInterval != INTERVAL) {
throw new Error("Test failed");
}
}
use of sun.jvmstat.monitor.MonitoredHost in project btrace by btraceio.
the class PerfReaderImpl method getThisVm.
private synchronized MonitoredVm getThisVm() {
if (thisVm == null) {
try {
MonitoredHost localHost = MonitoredHost.getMonitoredHost("localhost");
VmIdentifier vmIdent = new VmIdentifier("0");
thisVm = localHost.getMonitoredVm(vmIdent);
} catch (MonitorException | URISyntaxException me) {
throw new IllegalArgumentException("jvmstat perf counters not available: " + me);
}
}
return thisVm;
}
Aggregations