当前位置: 首页>>代码示例>>Java>>正文


Java ConnectorAddressLink类代码示例

本文整理汇总了Java中sun.management.ConnectorAddressLink的典型用法代码示例。如果您正苦于以下问题:Java ConnectorAddressLink类的具体用法?Java ConnectorAddressLink怎么用?Java ConnectorAddressLink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConnectorAddressLink类属于sun.management包,在下文中一共展示了ConnectorAddressLink类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import sun.management.ConnectorAddressLink; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    String pid = args[0]; // pid as a string
    System.out.println("Starting TestManager for PID = " + pid);
    System.out.flush();
    VirtualMachine vm = VirtualMachine.attach(pid);

    String agentPropLocalConnectorAddress = (String)
        vm.getAgentProperties().get(LOCAL_CONNECTOR_ADDRESS_PROP);

    int vmid = Integer.parseInt(pid);
    String jvmstatLocalConnectorAddress =
        ConnectorAddressLink.importFrom(vmid);

    if (agentPropLocalConnectorAddress == null &&
        jvmstatLocalConnectorAddress == null) {
        // No JMX Connector address so attach to VM, and start local agent
        startManagementAgent(pid);
        agentPropLocalConnectorAddress = (String)
            vm.getAgentProperties().get(LOCAL_CONNECTOR_ADDRESS_PROP);
        jvmstatLocalConnectorAddress =
            ConnectorAddressLink.importFrom(vmid);
    }


    // Test address obtained from agent properties
    System.out.println("Testing the connector address from agent properties");
    connect(pid, agentPropLocalConnectorAddress);

    // Test address obtained from jvmstat buffer
    System.out.println("Testing the connector address from jvmstat buffer");
    connect(pid, jvmstatLocalConnectorAddress);

    // Shutdown application
    int port = Integer.parseInt(args[1]);
    System.out.println("Shutdown process via TCP port: " + port);
    Socket s = new Socket();
    s.connect(new InetSocketAddress(port));
    s.close();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:40,代码来源:TestManager.java

示例2: attachJmx

import sun.management.ConnectorAddressLink; //导入依赖的package包/类
public static String attachJmx(String pid) throws IOException, AttachNotSupportedException, AgentLoadException, AgentInitializationException {
    VirtualMachine vm = null;
    try {
        vm = VirtualMachine.attach(pid);
        String serviceUrl = ConnectorAddressLink.importFrom(Integer.parseInt(vm.id().trim()));
        if(serviceUrl == null) {
            String home = System.getProperty("java.home");
            String agent = home + File.separator + "jre" + File.separator + "lib"
                    + File.separator + "management-agent.jar";
            File f = new File(agent);
            if (!f.exists()) {
                agent = home + File.separator + "lib" + File.separator +
                        "management-agent.jar";
                f = new File(agent);
                if (!f.exists()) {
                    throw new RuntimeException("management-agent.jar missing");
                }
            }
            agent = f.getCanonicalPath();
            __.println("Loading " + agent + " into target VM ...");

            vm.loadAgent(agent);
            serviceUrl = ConnectorAddressLink.importFrom(Integer.parseInt(vm.id().trim()));
        }
        return serviceUrl;

    } finally {
        if(vm != null) {
            try {
                vm.detach();
            } catch (IOException e) {}
        }
    }
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:35,代码来源:__.java

示例3: getMonitoredVMs

import sun.management.ConnectorAddressLink; //导入依赖的package包/类
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));
        }
    }
}
 
开发者ID:toomanyopenfiles,项目名称:jmxmon,代码行数:33,代码来源:LocalVirtualMachine.java

示例4: getMonitoredVMs

import sun.management.ConnectorAddressLink; //导入依赖的package包/类
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));
        }
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:33,代码来源:LocalVirtualMachine.java

示例5: main

import sun.management.ConnectorAddressLink; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    String pid = args[0]; // pid as a string
    VirtualMachine vm = VirtualMachine.attach(pid);

    String agentPropLocalConnectorAddress = (String)
        vm.getAgentProperties().get(LOCAL_CONNECTOR_ADDRESS_PROP);

    int vmid = Integer.parseInt(pid);
    String jvmstatLocalConnectorAddress =
        ConnectorAddressLink.importFrom(vmid);

    if (agentPropLocalConnectorAddress == null &&
        jvmstatLocalConnectorAddress == null) {
        // No JMX Connector address so attach to VM, and load
        // management-agent.jar
        startManagementAgent(pid);
        agentPropLocalConnectorAddress = (String)
            vm.getAgentProperties().get(LOCAL_CONNECTOR_ADDRESS_PROP);
        jvmstatLocalConnectorAddress =
            ConnectorAddressLink.importFrom(vmid);
    }


    // Test address obtained from agent properties
    System.out.println("Testing the connector address from agent properties");
    connect(pid, agentPropLocalConnectorAddress);

    // Test address obtained from jvmstat buffer
    System.out.println("Testing the connector address from jvmstat buffer");
    connect(pid, jvmstatLocalConnectorAddress);


    // Shutdown application
    int port = Integer.parseInt(args[1]);
    System.out.println("Shutdown process via TCP port: " + port);
    Socket s = new Socket();
    s.connect(new InetSocketAddress(port));
    s.close();
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:40,代码来源:TestManager.java

示例6: main

import sun.management.ConnectorAddressLink; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    String pid = args[0]; // pid as a string
    System.out.println("Starting TestManager for PID = " + pid);
    System.out.flush();
    VirtualMachine vm = VirtualMachine.attach(pid);

    String agentPropLocalConnectorAddress = (String)
        vm.getAgentProperties().get(LOCAL_CONNECTOR_ADDRESS_PROP);

    int vmid = Integer.parseInt(pid);
    String jvmstatLocalConnectorAddress =
        ConnectorAddressLink.importFrom(vmid);

    if (agentPropLocalConnectorAddress == null &&
        jvmstatLocalConnectorAddress == null) {
        // No JMX Connector address so attach to VM, and load
        // management-agent.jar
        startManagementAgent(pid);
        agentPropLocalConnectorAddress = (String)
            vm.getAgentProperties().get(LOCAL_CONNECTOR_ADDRESS_PROP);
        jvmstatLocalConnectorAddress =
            ConnectorAddressLink.importFrom(vmid);
    }


    // Test address obtained from agent properties
    System.out.println("Testing the connector address from agent properties");
    connect(pid, agentPropLocalConnectorAddress);

    // Test address obtained from jvmstat buffer
    System.out.println("Testing the connector address from jvmstat buffer");
    connect(pid, jvmstatLocalConnectorAddress);

    // Shutdown application
    int port = Integer.parseInt(args[1]);
    System.out.println("Shutdown process via TCP port: " + port);
    Socket s = new Socket();
    s.connect(new InetSocketAddress(port));
    s.close();
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:41,代码来源:TestManager.java

示例7: getMonitoredVMs

import sun.management.ConnectorAddressLink; //导入依赖的package包/类
private static void getMonitoredVMs(Map<Integer, LocalVirtualMachine> map) {
    MonitoredHost host;
    Set<Integer> 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));
        }
    }
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:33,代码来源:LocalVirtualMachine.java

示例8: init

import sun.management.ConnectorAddressLink; //导入依赖的package包/类
/**
 * @param args
 * @throws Exception
 * initializes MBeanServer
 */
public void init() throws Exception{

  err("init: server="+server+";port="+port+";service="+
      service+";localVMPid="+localVMPid);

  String url_string = null;
  // build connection url 
  if (localVMPid != null) {
    // from the file /tmp/hsperfdata*
    url_string = ConnectorAddressLink.importFrom(Integer.parseInt(localVMPid));
  } else if (!port.isEmpty() && !server.isEmpty()) {
    // using server and port
    url_string = "service:jmx:rmi:///jndi/rmi://"+server+ ":"+port+"/jmxrmi";
  } // else url stays null

  // Create an RMI connector client and
  // connect it to the RMI connector server

  if (url_string == null) { //assume local vm (for example for Testing)
    mbsc = ManagementFactory.getPlatformMBeanServer();
  } else {
    JMXServiceURL url = new JMXServiceURL(url_string);

    err("Create RMI connector and connect to the RMI connector server" + url);

    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
    // Get an MBeanServerConnection
    //
    err("\nGet an MBeanServerConnection");
    mbsc = jmxc.getMBeanServerConnection();
  }

  // Get domains from MBeanServer
  //
  err("\nDomains:");

  String domains[] = mbsc.getDomains();
  Arrays.sort(domains);
  for (String domain : domains) {
    err("\tDomain = " + domain);
  }

  // Get MBeanServer's default domain
  //
  err("\nMBeanServer default domain = " + mbsc.getDefaultDomain());

  // Get MBean count 
  //
  err("\nMBean count = " + mbsc.getMBeanCount());

  // Query MBean names for specific domain "hadoop" and service
  ObjectName query = new ObjectName("hadoop:service="+service+",*");
  hadoopObjectNames = new ArrayList<ObjectName>(5);
  err("\nQuery MBeanServer MBeans:");
  Set<ObjectName> names =
    new TreeSet<ObjectName>(mbsc.queryNames(query, null));

  for (ObjectName name : names) {
    hadoopObjectNames.add(name);
    err("hadoop services: " + name);
  }

}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:69,代码来源:JMXGet.java

示例9: getMonitoredVMs

import sun.management.ConnectorAddressLink; //导入依赖的package包/类
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));
    }
  }
}
 
开发者ID:patric-r,项目名称:jvmtop,代码行数:54,代码来源:LocalVirtualMachine.java


注:本文中的sun.management.ConnectorAddressLink类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。