当前位置: 首页>>代码示例>>Java>>正文


Java MonitoredHost.activeVms方法代码示例

本文整理汇总了Java中sun.jvmstat.monitor.MonitoredHost.activeVms方法的典型用法代码示例。如果您正苦于以下问题:Java MonitoredHost.activeVms方法的具体用法?Java MonitoredHost.activeVms怎么用?Java MonitoredHost.activeVms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.jvmstat.monitor.MonitoredHost的用法示例。


在下文中一共展示了MonitoredHost.activeVms方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findList

import sun.jvmstat.monitor.MonitoredHost; //导入方法依赖的package包/类
public List<MonitoredVm> findList() throws Exception
{
    List<MonitoredVm> list = new ArrayList<MonitoredVm>();

    MonitoredHost local = MonitoredHost.getMonitoredHost("localhost");
    Set<Integer> vmlist = new HashSet<Integer>(local.activeVms());
    for (int id : vmlist)
    {
        MonitoredVm vm = local.getMonitoredVm(new VmIdentifier("//" + id));
        String processname = MonitoredVmUtil.mainClass(vm, true);
        System.out.println(id + " [" + processname + "]");

        list.add(vm);
    }

    return list;
}
 
开发者ID:geekflow,项目名称:light,代码行数:18,代码来源:JavaProcess.java

示例2: main

import sun.jvmstat.monitor.MonitoredHost; //导入方法依赖的package包/类
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");
    }
}
 
开发者ID:frohoff,项目名称:jdk8u-dev-jdk,代码行数:29,代码来源:CR6672135.java

示例3: attachToMonitoredVm

import sun.jvmstat.monitor.MonitoredHost; //导入方法依赖的package包/类
private static MonitoredVm attachToMonitoredVm(MonitoredHost host, long pid) throws MonitorException, URISyntaxException {
    final Set vmIds = host.activeVms();
    for (Object vmId : vmIds) {
        if (vmId instanceof Integer &&
            ((Integer)vmId).longValue() == pid) {
            return host.getMonitoredVm(new VmIdentifier(vmId.toString()));
        }
    }
    return null;
}
 
开发者ID:rh-messaging,项目名称:Artemis-JON-plugin,代码行数:11,代码来源:JvmStatUtility.java

示例4: getMonitoredVMs

import sun.jvmstat.monitor.MonitoredHost; //导入方法依赖的package包/类
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));
        }
    }
}
 
开发者ID:toomanyopenfiles,项目名称:jmxmon,代码行数:33,代码来源:LocalVirtualMachine.java

示例5: killAll

import sun.jvmstat.monitor.MonitoredHost; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:36,代码来源:IgniteNodeRunner.java

示例6: getMonitoredVMs

import sun.jvmstat.monitor.MonitoredHost; //导入方法依赖的package包/类
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));
        }
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:33,代码来源:LocalVirtualMachine.java

示例7: getMonitoredVMs

import sun.jvmstat.monitor.MonitoredHost; //导入方法依赖的package包/类
private static void getMonitoredVMs(Map<Integer, LocalVirtualMachine> map) {
    MonitoredHost host;
    Set<Integer> 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));
        }
    }
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:33,代码来源:LocalVirtualMachine.java

示例8: resetTogglingStores

import sun.jvmstat.monitor.MonitoredHost; //导入方法依赖的package包/类
public static void resetTogglingStores(String host, boolean enabled) throws Exception {

		MonitoredHost _host = MonitoredHost.getMonitoredHost(new HostIdentifier(host));

		for (Object pidObj : _host.activeVms()) {
			int pid = (Integer) pidObj;

			System.out.println("checking pid: " + pid);

			JMXServiceURL jmxUrl = null;
			com.sun.tools.attach.VirtualMachine vm = com.sun.tools.attach.VirtualMachine.attach(pid + "");

			try {
				// get the connector address
				String connectorAddress = vm.getAgentProperties().getProperty("localhost");
				// establish connection to connector server
				if (connectorAddress != null) {
					jmxUrl = new JMXServiceURL(connectorAddress);
				}
			} finally {
				vm.detach();
			}

			if (jmxUrl != null) {
				System.out.println("got jmx url: " + jmxUrl);

				// connect to jmx
				JMXConnector connector = JMXConnectorFactory.connect(jmxUrl);

				connector.connect();

				MBeanServerConnection mbeanServer = connector.getMBeanServerConnection();

				// look for all beans in the d2 name space
				Set<ObjectInstance> objectInstances = mbeanServer.queryMBeans(new ObjectName("com.linkedin.d2:*"), null);

				for (ObjectInstance objectInstance : objectInstances) {
					System.err.println("checking object: " + objectInstance.getObjectName());

					// if we've found a toggling store, then toggle it
					if (objectInstance.getObjectName().toString().endsWith("TogglingStore")) {
						System.out.println("found toggling zk store, so toggling to: " + enabled);

						mbeanServer.invoke(objectInstance.getObjectName(), "setEnabled", new Object[] { enabled },
								new String[] { "boolean" });
					}
				}
			} else {
				System.out.println("pid is not a jmx process: " + pid);
			}
		}
	}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:53,代码来源:JstatTest.java

示例9: getMonitoredVMs

import sun.jvmstat.monitor.MonitoredHost; //导入方法依赖的package包/类
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));
    }
  }
}
 
开发者ID:patric-r,项目名称:jvmtop,代码行数:54,代码来源:LocalVirtualMachine.java


注:本文中的sun.jvmstat.monitor.MonitoredHost.activeVms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。