Java Code Examples for sun.jvmstat.monitor.MonitoredHost#activeVms()
The following examples show how to use
sun.jvmstat.monitor.MonitoredHost#activeVms() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CR6672135.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 2
Source File: CR6672135.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 3
Source File: CR6672135.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 4
Source File: CR6672135.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 5
Source File: CR6672135.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 6
Source File: CR6672135.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 7
Source File: CR6672135.java From hottub with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 8
Source File: CR6672135.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 9
Source File: CR6672135.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 10
Source File: CR6672135.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 11
Source File: LocalVirtualMachine.java From jmxmon with Apache License 2.0 | 5 votes |
private static void getMonitoredVMs(Map<Integer, LocalVirtualMachine> map) { MonitoredHost host; Set vms; try { host = MonitoredHost.getMonitoredHost(new HostIdentifier((String)null)); vms = host.activeVms(); } catch (java.net.URISyntaxException sx) { throw new InternalError(sx.getMessage()); } catch (MonitorException mx) { throw new InternalError(mx.getMessage()); } for (Object vmid: vms) { if (vmid instanceof Integer) { int pid = ((Integer) vmid).intValue(); String name = vmid.toString(); // default to pid if name not available boolean attachable = false; String address = null; try { MonitoredVm mvm = host.getMonitoredVm(new VmIdentifier(name)); // use the command line as the display name name = MonitoredVmUtil.commandLine(mvm); attachable = MonitoredVmUtil.isAttachable(mvm); address = ConnectorAddressLink.importFrom(pid); mvm.detach(); } catch (Exception x) { // ignore } map.put((Integer) vmid, new LocalVirtualMachine(pid, name, attachable, address)); } } }
Example 12
Source File: CR6672135.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 13
Source File: IgniteNodeRunner.java From ignite with Apache License 2.0 | 5 votes |
/** * Kill all Jvm runned by {#link IgniteNodeRunner}. Works based on jps command. * * @return List of killed process ids. * @throws Exception If exception. */ public static List<Integer> killAll() throws Exception { MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(new HostIdentifier("localhost")); Set<Integer> jvms = monitoredHost.activeVms(); List<Integer> res = new ArrayList<>(); for (Integer jvmId : jvms) { try { MonitoredVm vm = monitoredHost.getMonitoredVm(new VmIdentifier("//" + jvmId + "?mode=r"), 0); if (IgniteNodeRunner.class.getName().equals(MonitoredVmUtil.mainClass(vm, true))) { Process killProc = Runtime.getRuntime().exec(U.isWindows() ? new String[] {"taskkill", "/pid", jvmId.toString(), "/f", "/t"} : new String[] {"kill", "-9", jvmId.toString()}); killProc.waitFor(); res.add(jvmId); } } catch (Exception e) { // Print stack trace just for information. X.printerrln("Could not kill IgniteNodeRunner java processes. Jvm pid = " + jvmId, e); } } return res; }
Example 14
Source File: CR6672135.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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(); String uriString = "//" + vmInt + "?mode=r"; // NOI18N 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"); } }
Example 15
Source File: LocalVirtualMachine.java From jvmtop with GNU General Public License v2.0 | 4 votes |
private static void getMonitoredVMs(Map<Integer, LocalVirtualMachine> map, Map<Integer, LocalVirtualMachine> existingMap) { //Unsupported on J9 if (J9Mode) { return; } MonitoredHost host; Set vms; try { host = MonitoredHost.getMonitoredHost(new HostIdentifier((String) null)); vms = host.activeVms(); } catch (java.net.URISyntaxException sx) { throw new InternalError(sx.getMessage()); } catch (MonitorException mx) { throw new InternalError(mx.getMessage()); } for (Object vmid : vms) { if (existingMap.containsKey(vmid)) { continue; } if (vmid instanceof Integer) { int pid = ((Integer) vmid).intValue(); String name = vmid.toString(); // default to pid if name not available boolean attachable = false; String address = null; try { MonitoredVm mvm = host.getMonitoredVm(new VmIdentifier(name)); // use the command line as the display name name = MonitoredVmUtil.commandLine(mvm); attachable = MonitoredVmUtil.isAttachable(mvm); address = ConnectorAddressLink.importFrom(pid); mvm.detach(); } catch (Exception x) { // ignore } map.put((Integer) vmid, new LocalVirtualMachine(pid, name, attachable, address)); } } }