Java 类javax.management.remote.jmxmp.JMXMPConnectorServer 实例源码

项目:HeliosStreams    文件:InstallCommandProcessor.java   
@Override
public Void run() {
    Runtime.getRuntime().addShutdownHook(new Thread(){
        public void run() {
            if(!servers.isEmpty()) {
                SimpleLogger.log("Shutting down JMXMP Connector Servers");
                for(final JMXMPConnectorServer server: servers) {
                    AccessController.doPrivileged(new PrivilegedAction<Void>() {
                        @Override
                        public Void run() {
                            try { server.stop(); } catch (Exception x) {/* No Op */}
                            return null;
                        }
                    });

                }
                servers.clear();
            }
        }
    });
    return null;
}
项目:JMXMPAgent    文件:InstallCommandProcessor.java   
@Override
public Void run() {
    Runtime.getRuntime().addShutdownHook(new Thread(){
        public void run() {
            if(!servers.isEmpty()) {
                SimpleLogger.log("Shutting down JMXMP Connector Servers");
                for(final JMXMPConnectorServer server: servers) {
                    AccessController.doPrivileged(new PrivilegedAction<Void>() {
                        @Override
                        public Void run() {
                            try { server.stop(); } catch (Exception x) {/* No Op */}
                            return null;
                        }
                    });

                }
                servers.clear();
            }
        }
    });
    return null;
}
项目:HeliosStreams    文件:SSHConnectionTest.java   
/**
 * Tests loading an array of SSHConnections from JSON and establishing a basic connection
 * @throws Exception thrown on any error
 */
@SuppressWarnings("static-method")
@Test
public void testJMXMPTunnel() throws Exception {
    System.clearProperty(SSHD_PORT_PROP);
    final ApacheSSHDServer sshdServer = ApacheSSHDServer.getInstance();     
    final int[] ports = setLocalPorts();
    System.setProperty(SSHD_PORT_PROP, "" + sshdServer.getPort());
    final JMXMPConnectorServer jmxmp = JMXHelper.fireUpJMXMPServer(0);
    final int remotePort = jmxmp.getAddress().getPort();
    final String agentId = JMXHelper.getAgentId();
    log("Actual Agent ID: [" + agentId + "]");
    try {           
        final URL url = SSHConnectionTest.class.getClassLoader().getResource(TEST_JSON);
        final SSHConnection[] connections = SSHTunnelManager.parseConnections(url);
        log(Arrays.deepToString(connections));
        for(int i = 0; i < connections.length; i++) {
            connections[i].authenticate();
            LocalPortForwarder lpf = (LocalPortForwarder)PrivateAccessor.invoke(connections[i], "createPortForward", new Object[]{0, "localhost", remotePort}, int.class, String.class, int.class);
            final int localPort = lpf.getLocalPort();
            final JMXConnector jmxConnector = JMXHelper.getJMXConnection("service:jmx:jmxmp://localhost:" + localPort, true, null);
            final MBeanServerConnection server = jmxConnector.getMBeanServerConnection();
            final String readAgentId = JMXHelper.getAgentId(server);
            log("Agent ID: for [" + connections[i] + "] : [" + agentId + "]");
            Assert.assertEquals("Mismatch on expected agent ids", agentId, readAgentId);
            jmxConnector.close();
        }
    } finally {
        jmxmp.stop();
        sshdServer.stop(true);
        System.clearProperty(SSHD_PORT_PROP);
    }
}
项目:freeVM    文件:JMXRemoteProfilesTest.java   
public Result testJMXMPProfiles() throws Exception {

        log.info("          ");
        log.info("starat test JMXMPProfiles");
        String[] profiles = { "JMXMP", "SASL", "TLS" };
        for (int i = 0; i < profiles.length; i++) {
            log.info("Create mbean server");
            MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();

            JMXServiceURL url = new JMXServiceURL("service:jmx:jmxmp://");
            log.info("Create JMX Service URL - " + url);
            log.info("Create enviroment with profiles - " + profiles[i] );
            HashMap enviroment = new HashMap();
            enviroment.put("jmx.remote.profiles", profiles[i]);
            // Create a JMXConnectorServer
            log.info("Create JMXMPConnectorServer");
            JMXMPConnectorServer server = new JMXMPConnectorServer(url,
                    enviroment, mbeanServer);
            server.start();
            log.info("Create JMXMPConnectorClient");
            JMXMPConnector client = new JMXMPConnector(url, enviroment);

            server.stop();

        }
        return result();
    }