Search in sources :

Example 1 with MonitoredVm

use of sun.jvmstat.monitor.MonitoredVm 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 MonitoredVm

use of sun.jvmstat.monitor.MonitoredVm 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 MonitoredVm

use of sun.jvmstat.monitor.MonitoredVm 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 MonitoredVm

use of sun.jvmstat.monitor.MonitoredVm in project Gargoyle by callakrsos.

the class Monitors method started.

private static void started(String status, Integer lvmid) {
    try {
        String vmidString = "//" + lvmid + "?mode=r";
        VmIdentifier id = new VmIdentifier(vmidString);
        MonitoredVm vm = monitoredHost.getMonitoredVm(id, 0);
        String mainArgs = MonitoredVmUtil.mainArgs(vm);
        String mainClassName = MonitoredVmUtil.mainClass(vm, true);
        String jvmArgs = MonitoredVmUtil.jvmArgs(vm);
        String vmVersion = MonitoredVmUtil.vmVersion(vm);
        String jvmFlags = MonitoredVmUtil.jvmFlags(vm);
        String commandLine = MonitoredVmUtil.commandLine(vm);
        ApplicationModel model = new ApplicationModel();
        model.setProcessId(lvmid);
        model.setApplicationName(mainClassName);
        model.setArgument(mainArgs);
        model.setJvmArgs(jvmArgs);
        model.setVmVersion(vmVersion);
        model.setJvmFlags(jvmFlags);
        model.setCommandLine(commandLine);
        cache.put(lvmid.toString(), model);
        notifyMessage(Status.started, cache.get(lvmid.toString()));
        LOGGER.debug("status[{}] V PID : {} mainClassName : {} vmVersion : {}  jvmFlags : {} commandLine : {}", status, lvmid, mainClassName, vmVersion, jvmFlags, commandLine);
        monitoredHost.detach(vm);
    }/*
		 * 수행이 빠른 프로그램인경우 모니터링이되지않고 중간에 에러가 발생하는 케이스가 있다.
		 */
     catch (sun.jvmstat.monitor.MonitorException e) {
        LOGGER.warn(ValueUtil.toString(e));
    } catch (Exception e) {
        LOGGER.error(ValueUtil.toString(e));
    }
}
Also used : MonitorException(sun.jvmstat.monitor.MonitorException) MonitoredVm(sun.jvmstat.monitor.MonitoredVm) VmIdentifier(sun.jvmstat.monitor.VmIdentifier) MonitorException(sun.jvmstat.monitor.MonitorException)

Example 5 with MonitoredVm

use of sun.jvmstat.monitor.MonitoredVm 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)

Aggregations

MonitoredVm (sun.jvmstat.monitor.MonitoredVm)9 VmIdentifier (sun.jvmstat.monitor.VmIdentifier)9 MonitoredHost (sun.jvmstat.monitor.MonitoredHost)7 MonitorException (sun.jvmstat.monitor.MonitorException)6 AttachNotSupportedException (com.sun.tools.attach.AttachNotSupportedException)3 IOException (java.io.IOException)3 URISyntaxException (java.net.URISyntaxException)3 HostIdentifier (sun.jvmstat.monitor.HostIdentifier)3 ArrayList (java.util.ArrayList)2 VirtualMachineDescriptor (com.sun.tools.attach.VirtualMachineDescriptor)1 Set (java.util.Set)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 GridJavaProcess (org.apache.ignite.internal.util.GridJavaProcess)1 JStatLogger (sun.tools.jstat.JStatLogger)1