當前位置: 首頁>>代碼示例>>Java>>正文


Java VirtualMachineDescriptor.id方法代碼示例

本文整理匯總了Java中com.sun.tools.attach.VirtualMachineDescriptor.id方法的典型用法代碼示例。如果您正苦於以下問題:Java VirtualMachineDescriptor.id方法的具體用法?Java VirtualMachineDescriptor.id怎麽用?Java VirtualMachineDescriptor.id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sun.tools.attach.VirtualMachineDescriptor的用法示例。


在下文中一共展示了VirtualMachineDescriptor.id方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMainClass

import com.sun.tools.attach.VirtualMachineDescriptor; //導入方法依賴的package包/類
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;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:JCmd.java

示例2: getVmDescByServerName

import com.sun.tools.attach.VirtualMachineDescriptor; //導入方法依賴的package包/類
/**
 * 獲取指定服務名的本地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;
}
 
開發者ID:DevopsJK,項目名稱:SuitAgent,代碼行數:25,代碼來源:JMXUtil.java

示例3: attachVirtualMachine

import com.sun.tools.attach.VirtualMachineDescriptor; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:SolarisAttachProvider.java

示例4: attachVirtualMachine

import com.sun.tools.attach.VirtualMachineDescriptor; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:BsdAttachProvider.java

示例5: attachVirtualMachine

import com.sun.tools.attach.VirtualMachineDescriptor; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:LinuxAttachProvider.java

示例6: attachVirtualMachine

import com.sun.tools.attach.VirtualMachineDescriptor; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:AixAttachProvider.java

示例7: attachVirtualMachine

import com.sun.tools.attach.VirtualMachineDescriptor; //導入方法依賴的package包/類
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());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:AttachProviderImpl.java

示例8: check

import com.sun.tools.attach.VirtualMachineDescriptor; //導入方法依賴的package包/類
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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:31,代碼來源:ProcessArgumentMatcher.java

示例9: check

import com.sun.tools.attach.VirtualMachineDescriptor; //導入方法依賴的package包/類
private boolean check(VirtualMachineDescriptor vmd) {
    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) {
        if (e.getMessage() != null) {
            System.err.println(e.getMessage());
        } else {
            Throwable cause = e.getCause();
            if ((cause != null) && (cause.getMessage() != null)) {
                System.err.println(cause.getMessage());
            } else {
                e.printStackTrace();
            }
        }
        return false;
    }

    if (mainClass.equals(excludeCls)) {
        return false;
    }

    if (matchAll || mainClass.indexOf(matchClass) != -1) {
        return true;
    }

    return false;
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:41,代碼來源:ProcessArgumentMatcher.java


注:本文中的com.sun.tools.attach.VirtualMachineDescriptor.id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。