Java Code Examples for com.sun.tools.attach.VirtualMachineDescriptor#id()
The following examples show how to use
com.sun.tools.attach.VirtualMachineDescriptor#id() .
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: AixAttachProvider.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new AixVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 2
Source File: BsdAttachProvider.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new BsdVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 3
Source File: BsdAttachProvider.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new BsdVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 4
Source File: LinuxAttachProvider.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new LinuxVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 5
Source File: BsdAttachProvider.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new BsdVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 6
Source File: AttachProviderImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new VirtualMachineImpl(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 7
Source File: LinuxAttachProvider.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new LinuxVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 8
Source File: SolarisAttachProvider.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new SolarisVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 9
Source File: JCmd.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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) { // There is a potential race, where a running java app is being // queried, unfortunately the java app has shutdown after this // method is started but before getMonitoredVM is called. // If this is the case, then the /tmp/hsperfdata_xxx/pid file // will have disappeared and we will get a NullPointerException. // Handle this gracefully.... return null; } }
Example 10
Source File: LinuxAttachProvider.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new LinuxVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 11
Source File: JCmd.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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) { // There is a potential race, where a running java app is being // queried, unfortunately the java app has shutdown after this // method is started but before getMonitoredVM is called. // If this is the case, then the /tmp/hsperfdata_xxx/pid file // will have disappeared and we will get a NullPointerException. // Handle this gracefully.... return null; } }
Example 12
Source File: JCmd.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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) { // There is a potential race, where a running java app is being // queried, unfortunately the java app has shutdown after this // method is started but before getMonitoredVM is called. // If this is the case, then the /tmp/hsperfdata_xxx/pid file // will have disappeared and we will get a NullPointerException. // Handle this gracefully.... return null; } }
Example 13
Source File: AixAttachProvider.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new AixVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 14
Source File: SolarisAttachProvider.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new SolarisVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 15
Source File: BsdAttachProvider.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new BsdVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 16
Source File: JMXUtil.java From SuitAgent with Apache License 2.0 | 6 votes |
/** * 获取指定服务名的本地JMX VM 描述对象 * @param serverName * @return */ public static List<VirtualMachineDescriptor> getVmDescByServerName(String serverName){ List<VirtualMachineDescriptor> vmDescList = new ArrayList<>(); if (StringUtils.isEmpty(serverName)){ return vmDescList; } List<VirtualMachineDescriptor> vms = VirtualMachine.list(); for (VirtualMachineDescriptor desc : vms) { //java -jar 形式启动的Java应用 if(desc.displayName().matches(".*\\.jar(\\s*-*.*)*") && desc.displayName().contains(serverName)){ vmDescList.add(desc); }else if(hasContainsServerName(desc.displayName(),serverName)){ vmDescList.add(desc); }else if (isJSVC(desc.id(),serverName)){ VirtualMachineDescriptor descriptor = new VirtualMachineDescriptor(desc.provider(),desc.id(),serverName); vmDescList.add(descriptor); } } return vmDescList; }
Example 17
Source File: SolarisAttachProvider.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new SolarisVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 18
Source File: AixAttachProvider.java From hottub with GNU General Public License v2.0 | 6 votes |
public VirtualMachine attachVirtualMachine(VirtualMachineDescriptor vmd) throws AttachNotSupportedException, IOException { if (vmd.provider() != this) { throw new AttachNotSupportedException("provider mismatch"); } // To avoid re-checking if the VM if attachable, we check if the descriptor // is for a hotspot VM - these descriptors are created by the listVirtualMachines // implementation which only returns a list of attachable VMs. if (vmd instanceof HotSpotVirtualMachineDescriptor) { assert ((HotSpotVirtualMachineDescriptor)vmd).isAttachable(); checkAttachPermission(); return new AixVirtualMachine(this, vmd.id()); } else { return attachVirtualMachine(vmd.id()); } }
Example 19
Source File: ProcessArgumentMatcher.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static boolean check(VirtualMachineDescriptor vmd, String excludeClass, String partialMatch) { String mainClass = null; try { 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); } catch (NullPointerException npe) { // There is a potential race, where a running java app is being // queried, unfortunately the java app has shutdown after this // method is started but before getMonitoredVM is called. // If this is the case, then the /tmp/hsperfdata_xxx/pid file // will have disappeared and we will get a NullPointerException. // Handle this gracefully.... return false; } catch (MonitorException | URISyntaxException e) { return false; } if (excludeClass != null && mainClass.equals(excludeClass)) { return false; } if (partialMatch != null && mainClass.indexOf(partialMatch) == -1) { return false; } return true; }
Example 20
Source File: ArthasStarter.java From bistoury with GNU General Public License v3.0 | 4 votes |
private static void attachAgent(Configure configure) throws Exception { logger.info("start attach to arthas agent"); VirtualMachineDescriptor virtualMachineDescriptor = null; for (VirtualMachineDescriptor descriptor : VirtualMachine.list()) { String pid = descriptor.id(); if (pid.equals(String.valueOf(configure.getJavaPid()))) { virtualMachineDescriptor = descriptor; } } VirtualMachine virtualMachine = null; try { if (virtualMachineDescriptor == null) { virtualMachine = VirtualMachine.attach(String.valueOf(configure.getJavaPid())); } else { virtualMachine = VirtualMachine.attach(virtualMachineDescriptor); } Properties targetSystemProperties = virtualMachine.getSystemProperties(); String targetJavaVersion = targetSystemProperties.getProperty("java.specification.version"); String currentJavaVersion = System.getProperty("java.specification.version"); if (targetJavaVersion != null && currentJavaVersion != null) { if (!targetJavaVersion.equals(currentJavaVersion)) { logger.warn("Current VM java version: {} do not match target VM java version: {}, attach may fail.", currentJavaVersion, targetJavaVersion); logger.warn("Target VM JAVA_HOME is {}, try to set the same JAVA_HOME.", targetSystemProperties.getProperty("java.home")); } } String arthasAgent = configure.getArthasAgent(); File agentFile = new File(arthasAgent); String name = agentFile.getName(); String prefix = name.substring(0, name.indexOf('.')); File dir = agentFile.getParentFile(); File realAgentFile = getFileWithPrefix(dir, prefix); logger.info("start load arthas agent, input {}, load {}", arthasAgent, realAgentFile.getCanonicalPath()); final String delimiter = "$|$"; virtualMachine.loadAgent(realAgentFile.getCanonicalPath(), configure.getArthasCore() + delimiter + ";;" + configure.toString() + delimiter + System.getProperty("bistoury.app.lib.class")); } finally { if (virtualMachine != null) { virtualMachine.detach(); } } }