本文整理汇总了Java中sun.management.ConnectorAddressLink.importFrom方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectorAddressLink.importFrom方法的具体用法?Java ConnectorAddressLink.importFrom怎么用?Java ConnectorAddressLink.importFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.management.ConnectorAddressLink
的用法示例。
在下文中一共展示了ConnectorAddressLink.importFrom方法的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();
}
示例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) {}
}
}
}
示例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));
}
}
}
示例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));
}
}
}
示例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();
}
示例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();
}
示例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));
}
}
}
示例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);
}
}
示例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));
}
}
}