Java Code Examples for sun.jvmstat.monitor.MonitoredVmUtil#isAttachable()

The following examples show how to use sun.jvmstat.monitor.MonitoredVmUtil#isAttachable() . 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: HotSpotAttachProvider.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 2
Source File: HotSpotAttachProvider.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 3
Source File: HotSpotAttachProvider.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 4
Source File: HotSpotAttachProvider.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 5
Source File: HotSpotAttachProvider.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 6
Source File: HotSpotAttachProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 7
Source File: HotSpotAttachProvider.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 8
Source File: HotSpotAttachProvider.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 9
Source File: HotSpotAttachProvider.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 10
Source File: HotSpotAttachProvider.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 11
Source File: HotSpotAttachProvider.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 12
Source File: LocalVirtualMachine.java    From jmxmon with Apache License 2.0 5 votes vote down vote up
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 13
Source File: HotSpotAttachProvider.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 14
Source File: HotSpotAttachProvider.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 15
Source File: HotSpotAttachProvider.java    From Carbon with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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");
}
 
Example 16
Source File: LocalVirtualMachine.java    From jvmtop with GNU General Public License v2.0 4 votes vote down vote up
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));
    }
  }
}