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


Java JMXConnectorFactory.newJMXConnector方法代码示例

本文整理汇总了Java中javax.management.remote.JMXConnectorFactory.newJMXConnector方法的典型用法代码示例。如果您正苦于以下问题:Java JMXConnectorFactory.newJMXConnector方法的具体用法?Java JMXConnectorFactory.newJMXConnector怎么用?Java JMXConnectorFactory.newJMXConnector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.remote.JMXConnectorFactory的用法示例。


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

示例1: dotest

import javax.management.remote.JMXConnectorFactory; //导入方法依赖的package包/类
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:ProviderTest.java

示例2: MBeanWrapper

import javax.management.remote.JMXConnectorFactory; //导入方法依赖的package包/类
MBeanWrapper( int jvmPort ) throws MonitorConfigurationException {

        this.jvmPort = jvmPort;
        try {
            JMXConnector connector = JMXConnectorFactory.newJMXConnector(new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:"
                                                                                           + this.jvmPort
                                                                                           + "/jmxrmi"),
                                                                         null);
            connector.connect();

            this.connection = connector.getMBeanServerConnection();
        } catch (Exception e) {
            final String msg = "Error initializing the JMV monitor. Unable to connect to JVM at port "
                               + this.jvmPort;
            log.error(msg, e);
            throw new MonitorConfigurationException(msg, e);
        }
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:19,代码来源:MBeanWrapper.java

示例3: newJMXConnector

import javax.management.remote.JMXConnectorFactory; //导入方法依赖的package包/类
/**
    * {@inheritDoc}
    * @see javax.management.remote.JMXConnectorProvider#newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map)
    */
   @Override
public JMXConnector newJMXConnector(final JMXServiceURL serviceURL, final Map<String, ?> env) throws IOException {
	if (!serviceURL.getProtocol().equals(PROTOCOL_NAME)) {
		throw new MalformedURLException("Protocol not [" + PROTOCOL_NAME + "]: " +
					    serviceURL.getProtocol());
	}
	final Map<String, ?> environment = env==null ? new HashMap<String, Object>() : env;
	final String remoteHost = serviceURL.getHost();
	final int remotePort = serviceURL.getPort();
	
	final int localPort = SSHTunnelManager.getInstance().getPortForward(remoteHost, remotePort);
	final String format = environment.containsKey(DELEGATE_PROTOCOL_FORMAT_KEY) ? environment.get(DELEGATE_PROTOCOL_FORMAT_KEY).toString() : DEFAULT_DELEGATE_PROTOCOL_FORMAT;
	
	final JMXServiceURL tunneledURL = JMXHelper.serviceUrl(format, "localhost", localPort);
	final JMXConnector connector = JMXConnectorFactory.newJMXConnector(tunneledURL, environment);
	
	final UpdateableJMXConnector ujmx = new UpdateableJMXConnector(connector, serviceURL, environment);
	connector.addConnectionNotificationListener(this, this, ujmx);
	return ujmx;
   }
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:25,代码来源:ClientProvider.java

示例4: testStop

import javax.management.remote.JMXConnectorFactory; //导入方法依赖的package包/类
@Test
public void testStop() throws Exception {
  MiniHBaseCluster cluster = UTIL.getHBaseCluster();
  LOG.info("shutdown hbase cluster...");
  cluster.shutdown();
  LOG.info("wait for the hbase cluster shutdown...");
  cluster.waitUntilShutDown();

  JMXConnector connector = JMXConnectorFactory.newJMXConnector(
    JMXListener.buildJMXServiceURL(connectorPort,connectorPort), null);
  expectedEx.expect(IOException.class);
  connector.connect();

}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:TestJMXListener.java

示例5: JMXClient

import javax.management.remote.JMXConnectorFactory; //导入方法依赖的package包/类
/**
 * Creates a new JMXClient
 * @param jmxUrl The JMX URL
 * @param connectTimeoutSecs The timeout on connecting and acquiring a connection
 * @param credentials The optional credentials
 */
public JMXClient(final String jmxUrl, final long connectTimeoutSecs, final String...credentials) {
	super();
	this.jmxUrl = jmxUrl;
	this.connectTimeoutSecs = connectTimeoutSecs;
	env.put(ClientProvider.RECONNECT_TIMEOUT_KEY, this.connectTimeoutSecs);
	JMXServiceURL jurl = JMXHelper.serviceUrl(jmxUrl);
	final String rhost = jurl.getHost();
	final int rport = jurl.getPort();
	if("tunnel".equals(jurl.getProtocol())) {
		final int localPort = SSHTunnelManager.getInstance().getPortForward(rhost, rport);
		jurl = JMXHelper.serviceUrl("service:jmx:jmxmp://localhost:" + localPort);
	}
	jmxServiceUrl = jurl;
	log = LogManager.getLogger(getClass().getName() + "-" + rhost.replace('.', '_') + "-" + rport);
	if(credentials!=null && credentials.length > 1) {
		final String[] creds = new String[2];
		System.arraycopy(credentials, 0, creds, 0, 2);
		env.put(JMXConnector.CREDENTIALS, creds);
	}
	final Map<String, String> qArgs = queryArgsToMap(jmxServiceUrl);
	remoteApp = qArgs.get(APP_QUERY_ARG);
	remoteHost = qArgs.get(HOST_QUERY_ARG);
	hystrixEnabled.set(ConfigurationHelper.getBooleanSystemThenEnvProperty(CONFIG_HYSTRIX_ENABLED, DEFAULT_HYSTRIX_ENABLED));
	if(hystrixEnabled.get()) {
		commandBuilder = HystrixCommandFactory.getInstance().builder(CONFIG_HYSTRIX, "jmx-remote-" + jmxServiceUrl.getProtocol())
				.andCommandKey(jmxServiceUrl.getHost().replace('.', '-') + "." + jmxServiceUrl.getPort())
				.andThreadPoolKey("jmxremoting")
				.build();
	} else {
		commandBuilder = null;
	}
	
	
	try {
		jmxConnector = JMXConnectorFactory.newJMXConnector(jmxServiceUrl, env);
	} catch (IOException iex) {
		throw new RuntimeException("Failed to create JMXConnector", iex);
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:46,代码来源:JMXClient.java

示例6: initializeJMXConnector

import javax.management.remote.JMXConnectorFactory; //导入方法依赖的package包/类
@PostConstruct
public void initializeJMXConnector() {
    try {
        String managementPort = System.getProperty("com.sun.management.jmxremote.port");
        JMXServiceURL jmxServiceURL = new JMXServiceURL("rmi", "", 0, "/jndi/rmi://" + JMX_HOST + ":" + managementPort + "/jmxrmi");
        jmxConnector = JMXConnectorFactory.newJMXConnector(jmxServiceURL, new HashMap<>());
        jmxConnector.connect();
        remoteConnection = jmxConnector.getMBeanServerConnection();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:ivannov,项目名称:javaee-actuator,代码行数:13,代码来源:JmxInspectorImpl.java

示例7: test

import javax.management.remote.JMXConnectorFactory; //导入方法依赖的package包/类
private static void test() {
    try {
        JMXServiceURL u = new JMXServiceURL("rmi", null, 0);
        JMXConnectorServer server;
        JMXServiceURL addr;
        JMXConnector client;
        MBeanServerConnection mserver;

        final ObjectName delegateName =
            new ObjectName("JMImplementation:type=MBeanServerDelegate");
        final NotificationListener dummyListener =
            new NotificationListener() {
                    public void handleNotification(Notification n,
                                                   Object o) {
                        // do nothing
                        return;
                    }
                };

        server = JMXConnectorServerFactory.newJMXConnectorServer(u,
                                                                 null,
                                                                 mbs);
        server.start();

        addr = server.getAddress();
        client = JMXConnectorFactory.newJMXConnector(addr, null);
        client.connect(null);

        mserver = client.getMBeanServerConnection();
        String s1 = "1";
        String s2 = "2";
        String s3 = "3";

        mserver.addNotificationListener(delegateName,
                                        dummyListener, null, s1);
        mserver.addNotificationListener(delegateName,
                                        dummyListener, null, s2);
        mserver.addNotificationListener(delegateName,
                                        dummyListener, null, s3);

        mserver.removeNotificationListener(delegateName,
                                           dummyListener, null, s3);
        mserver.removeNotificationListener(delegateName,
                                           dummyListener, null, s2);
        mserver.removeNotificationListener(delegateName,
                                           dummyListener, null, s1);
        client.close();

        server.stop();
    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        System.exit(1);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:56,代码来源:RMIExitTest.java

示例8: dotest

import javax.management.remote.JMXConnectorFactory; //导入方法依赖的package包/类
private static void dotest(String protocol,
                           NotificationSender s,
                           ObjectName notifierName) throws Exception {
    JMXConnector client = null;
    JMXConnectorServer server = null;
    JMXServiceURL u = null;
    try {
        u = new JMXServiceURL(protocol, null, 0);
        server =
            JMXConnectorServerFactory.newJMXConnectorServer(u,
                                                            null,
                                                            mbs);
        checkNotifier(s, 0, "new ConnectorServer");

        server.start();

        checkNotifier(s, 0, "ConnectorServer start");

        JMXServiceURL addr = server.getAddress();
        client = JMXConnectorFactory.newJMXConnector(addr, null);

        checkNotifier(s, 0, "new Connector");

        client.connect(null);

        checkNotifier(s, 0, "Connector connect");

        MBeanServerConnection mbsc = client.getMBeanServerConnection();

        final NotificationListener dummyListener =
            new NotificationListener() {
                    public void handleNotification(Notification n,
                                                   Object o) {
                        // do nothing
                        return;
                    }
                };

        mbsc.addNotificationListener(notifierName,
                                     dummyListener,
                                     null,
                                     null);

        // 1 Listener is expected to be added by the ServerNotifForwader
        checkNotifier(s, 1, "addNotificationListener");

        mbsc.removeNotificationListener(notifierName,
                                        dummyListener);
        System.out.println("Test OK for " + protocol);
    }catch(MalformedURLException e) {
        System.out.println("Skipping URL " + u);
    }
    finally {
        if(client != null)
            client.close();
        if(server != null)
            server.stop();
    }
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:60,代码来源:NotificationBufferCreationTest.java


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