Search in sources :

Example 1 with MonitoredHost

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");
}
Also used : MonitoredVm(sun.jvmstat.monitor.MonitoredVm) VmIdentifier(sun.jvmstat.monitor.VmIdentifier) AttachNotSupportedException(com.sun.tools.attach.AttachNotSupportedException) MonitoredHost(sun.jvmstat.monitor.MonitoredHost)

Example 2 with MonitoredHost

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;
    }
}
Also used : MonitoredVm(sun.jvmstat.monitor.MonitoredVm) VmIdentifier(sun.jvmstat.monitor.VmIdentifier) MonitoredHost(sun.jvmstat.monitor.MonitoredHost)

Example 3 with MonitoredHost

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();
    }
}
Also used : JStatLogger(sun.tools.jstat.JStatLogger) MonitoredVm(sun.jvmstat.monitor.MonitoredVm) VmIdentifier(sun.jvmstat.monitor.VmIdentifier) URISyntaxException(java.net.URISyntaxException) MonitoredHost(sun.jvmstat.monitor.MonitoredHost) MonitorException(sun.jvmstat.monitor.MonitorException)

Example 4 with MonitoredHost

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");
    }
}
Also used : Set(java.util.Set) MonitoredVm(sun.jvmstat.monitor.MonitoredVm) VmIdentifier(sun.jvmstat.monitor.VmIdentifier) MonitoredHost(sun.jvmstat.monitor.MonitoredHost) MonitorException(sun.jvmstat.monitor.MonitorException) URISyntaxException(java.net.URISyntaxException)

Example 5 with MonitoredHost

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;
}
Also used : VmIdentifier(sun.jvmstat.monitor.VmIdentifier) URISyntaxException(java.net.URISyntaxException) MonitoredHost(sun.jvmstat.monitor.MonitoredHost) MonitorException(sun.jvmstat.monitor.MonitorException)

Aggregations

MonitoredHost (sun.jvmstat.monitor.MonitoredHost)10 VmIdentifier (sun.jvmstat.monitor.VmIdentifier)8 MonitoredVm (sun.jvmstat.monitor.MonitoredVm)7 MonitorException (sun.jvmstat.monitor.MonitorException)5 URISyntaxException (java.net.URISyntaxException)4 HostIdentifier (sun.jvmstat.monitor.HostIdentifier)4 AttachNotSupportedException (com.sun.tools.attach.AttachNotSupportedException)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 VirtualMachineDescriptor (com.sun.tools.attach.VirtualMachineDescriptor)1 Set (java.util.Set)1 MBeanServerConnection (javax.management.MBeanServerConnection)1 ObjectInstance (javax.management.ObjectInstance)1 ObjectName (javax.management.ObjectName)1 JMXConnector (javax.management.remote.JMXConnector)1 JMXServiceURL (javax.management.remote.JMXServiceURL)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 GridJavaProcess (org.apache.ignite.internal.util.GridJavaProcess)1 HostListener (sun.jvmstat.monitor.event.HostListener)1 JStatLogger (sun.tools.jstat.JStatLogger)1