當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。