Package sun.jvmstat.monitor

Examples of sun.jvmstat.monitor.MonitoredHost


        List<VirtualMachineDescriptor> descriptors = VirtualMachine.list();
        for (VirtualMachineDescriptor vm : descriptors) {
            System.out.println("VM: " + vm.displayName());
        }

        MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(new HostIdentifier((String) null));
        Set all = monitoredHost.activeVms();


        System.out.println("Providers List:");
        for (AttachProvider p : AttachProvider.providers()) {
            System.out.println("\t" + p);
View Full Code Here


        }
        return manageableVMs;
    }

    private static void getMonitoredVMs(Map<Integer, LocalVirtualMachine> map) {
        MonitoredHost monitoredhost;
        Set set;
        try {
            monitoredhost = MonitoredHost.getMonitoredHost(new HostIdentifier((String) null));
            set = monitoredhost.activeVms();
        }
        catch (URISyntaxException urisyntaxexception) {
            throw new InternalError(urisyntaxexception.getMessage());
        }
        catch (MonitorException monitorexception) {
            throw new InternalError(monitorexception.getMessage());
        }

        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            Object obj = iterator.next();
            if (obj instanceof Integer) {
                int i = ((Integer) obj).intValue();
                String s = obj.toString();
                boolean flag = false;
                String s1 = null;
                try {
                    MonitoredVm monitoredvm = monitoredhost.getMonitoredVm(new VmIdentifier(s));
                    s = MonitoredVmUtil.commandLine(monitoredvm);
                    flag = MonitoredVmUtil.isAttachable(monitoredvm);
                    s1 = ConnectorAddressLink.importFrom(i);
                    monitoredvm.detach();
                }
View Full Code Here

        getAttachableVMs(map);
        return map;
    }

    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();
View Full Code Here

        getAttachableVMs(map);
        return map;
    }

    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();
View Full Code Here

     */
    public List<VirtualMachineDescriptor> listVirtualMachines() {
        ArrayList<VirtualMachineDescriptor> result =
            new ArrayList<VirtualMachineDescriptor>();

        MonitoredHost host;
        Set vms;
        try {
            host = MonitoredHost.getMonitoredHost(new HostIdentifier((String)null));
            vms = host.activeVms();
        } catch (Throwable t) {
            if (t instanceof ExceptionInInitializerError) {
                t = t.getCause();
            }
            if (t instanceof ThreadDeath) {
                throw (ThreadDeath)t;
            }
            if (t instanceof SecurityException) {
                return result;
            }
            throw new InternalError();          // shouldn't happen
        }

        for (Object vmid: vms) {
            if (vmid instanceof Integer) {
                String pid = vmid.toString();
                String name = pid;      // default to pid if name not available
                boolean isAttachable = false;
                MonitoredVm mvm = null;
                try {
                    mvm = host.getMonitoredVm(new VmIdentifier(pid));
                    try {
                        isAttachable = MonitoredVmUtil.isAttachable(mvm);
                        // use the command line as the display name
                        name =  MonitoredVmUtil.commandLine(mvm);
                    } catch (Exception e) {
View Full Code Here

    void testAttachable(String id) throws AttachNotSupportedException {
        MonitoredVm mvm = null;
        boolean isKernelVM = false;
        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;
            }
View Full Code Here

  }

  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);
View Full Code Here

  public static void main(String[] args) throws Exception {
    runTestApp();

    // print the PIDs and other application info
    MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(new HostIdentifier((String) null));
    Set<Integer> activeVmPids = monitoredHost.activeVms();
    for (Integer vmPid : activeVmPids) {
      MonitoredVm mvm = monitoredHost.getMonitoredVm(new VmIdentifier(vmPid.toString()));
      System.out.println("" +
        "pid: " + vmPid.intValue() + ", " +
        "main class: " + MonitoredVmUtil.mainClass(mvm, true) + ", " +
        "command line: " + MonitoredVmUtil.commandLine(mvm) + "\n");
      mvm.detach();
View Full Code Here

   *
   * @param mainClass
   * @return
   */
  public Integer getPid(Class<?> mainClass) {
    MonitoredHost monitoredHost;
    Set<Integer> activeVmPids;
    try {
      monitoredHost = MonitoredHost.getMonitoredHost(new HostIdentifier((String) null));
      activeVmPids = monitoredHost.activeVms();
      MonitoredVm mvm = null;
      for (Integer vmPid : activeVmPids) {
        try {
          mvm = monitoredHost.getMonitoredVm(new VmIdentifier(vmPid.toString()));
          String mvmMainClass = MonitoredVmUtil.mainClass(mvm, true);
          if (mainClass.getName().equals(mvmMainClass)) {
            return vmPid;
          }
        } finally {
View Full Code Here

   * ActiveVm [pid=4532, name=org.eclipse.jdt.internal.junit.runner.RemoteTestRunner] The pid=6972
   * must be Eclipse. So this approach is not water tight.
   */
  public static List<ActiveVm> getActiveLocalVms() {
    List<ActiveVm> result = new LinkedList<ActiveVm>();
    MonitoredHost monitoredHost;
    Set<Integer> activeVmPids;
    try {
      monitoredHost = MonitoredHost.getMonitoredHost(new HostIdentifier((String) null));
      activeVmPids = monitoredHost.activeVms();
      for (Integer vmPid : activeVmPids) {
        try {
          MonitoredVm mvm = monitoredHost.getMonitoredVm(new VmIdentifier(vmPid.toString()));
          result.add(new ActiveVm(vmPid.intValue(), MonitoredVmUtil.mainClass(mvm, true), MonitoredVmUtil.commandLine(mvm)));
          mvm.detach();
        } catch (Exception e) {
          result.add(new FailedActiveVm(vmPid.intValue(), e));
        }
View Full Code Here

TOP

Related Classes of sun.jvmstat.monitor.MonitoredHost

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.