java类javax.management.remote.JMXConnectorServer的实例源码

Agent.java 文件源码 项目:OpenJSharp 阅读 24 收藏 0 点赞 0 评论 0
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
JMXAgent.java 文件源码 项目:OperatieBRP 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Maak een connector server instantie.
 *
 * @return connector server
 * @throws IOException bij fouten
 */
private JMXConnectorServer createConnectorServer() throws IOException {
    final Properties configuration = readConfiguration();
    final MBeanServer server = locateMBeanServer();

    final JMXServiceURL url = new JMXServiceURL(SimpleJmx.PROTOCOL,
            configuration.getProperty("jmx.host", DEFAULT_HOST), Integer.parseInt(configuration.getProperty("jmx.port", DEFAULT_PORT)));

    final Map<String,Object> environment = new HashMap<>();
    Properties authentication = new Properties();
    authentication.setProperty("admin", "admin");
    environment.put("jmx.remote.authenticator", new PropertiesAuthenticator(authentication));
    environment.put("jmx.remote.accesscontroller", new AllAccessController());

    return JMXConnectorServerFactory.newJMXConnectorServer(url, environment, server);
}
Agent.java 文件源码 项目:jdk8u-jdk 阅读 32 收藏 0 点赞 0 评论 0
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
ListenerScaleTest.java 文件源码 项目:jdk8u-jdk 阅读 25 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
RMIConnectorLogAttributesTest.java 文件源码 项目:jdk8u-jdk 阅读 21 收藏 0 点赞 0 评论 0
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
ProviderTest.java 文件源码 项目:jdk8u-jdk 阅读 26 收藏 0 点赞 0 评论 0
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());
}
Agent.java 文件源码 项目:openjdk-jdk10 阅读 27 收藏 0 点赞 0 评论 0
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
ListenerScaleTest.java 文件源码 项目:openjdk-jdk10 阅读 25 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception {
    if (Platform.isDebugBuild()) {
        System.out.println("Running on a debug build. Performance test not applicable. Skipping.");
        return;
    }
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
RMIConnectorLogAttributesTest.java 文件源码 项目:openjdk-jdk10 阅读 20 收藏 0 点赞 0 评论 0
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
ProviderTest.java 文件源码 项目:openjdk-jdk10 阅读 23 收藏 0 点赞 0 评论 0
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());
}
Agent.java 文件源码 项目:openjdk9 阅读 24 收藏 0 点赞 0 评论 0
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
ListenerScaleTest.java 文件源码 项目:openjdk9 阅读 22 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception {
    if (Platform.isDebugBuild()) {
        System.out.println("Running on a debug build. Performance test not applicable. Skipping.");
        return;
    }
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
RMIConnectorLogAttributesTest.java 文件源码 项目:openjdk9 阅读 22 收藏 0 点赞 0 评论 0
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
ProviderTest.java 文件源码 项目:openjdk9 阅读 30 收藏 0 点赞 0 评论 0
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());
}
MBeanServerConnectionFactoryBeanTests.java 文件源码 项目:spring4-understanding 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void testTestValidConnection() throws Exception {
    Assume.group(TestGroup.JMXMP);
    JMXConnectorServer connectorServer = getConnectorServer();
    connectorServer.start();

    try {
        MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
        bean.setServiceUrl(serviceUrl);
        bean.afterPropertiesSet();

        try {
            MBeanServerConnection connection = bean.getObject();
            assertNotNull("Connection should not be null", connection);

            // perform simple MBean count test
            assertEquals("MBean count should be the same", getServer().getMBeanCount(), connection.getMBeanCount());
        } finally {
            bean.destroy();
        }
    } finally {
        connectorServer.stop();
    }
}
MBeanServerConnectionFactoryBeanTests.java 文件源码 项目:spring4-understanding 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void testTestWithLazyConnection() throws Exception {
    Assume.group(TestGroup.JMXMP);
    MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean();
    bean.setServiceUrl(serviceUrl);
    bean.setConnectOnStartup(false);
    bean.afterPropertiesSet();

    MBeanServerConnection connection = bean.getObject();
    assertTrue(AopUtils.isAopProxy(connection));

    JMXConnectorServer connector = null;
    try {
        connector = getConnectorServer();
        connector.start();
        assertEquals("Incorrect MBean count", getServer().getMBeanCount(), connection.getMBeanCount());
    } finally {
        bean.destroy();
        if (connector != null) {
            connector.stop();
        }
    }
}
Agent.java 文件源码 项目:jdk8u_jdk 阅读 28 收藏 0 点赞 0 评论 0
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
ListenerScaleTest.java 文件源码 项目:jdk8u_jdk 阅读 27 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
RMIConnectorLogAttributesTest.java 文件源码 项目:jdk8u_jdk 阅读 33 收藏 0 点赞 0 评论 0
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
ProviderTest.java 文件源码 项目:jdk8u_jdk 阅读 29 收藏 0 点赞 0 评论 0
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());
}
Agent.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 27 收藏 0 点赞 0 评论 0
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
ListenerScaleTest.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 24 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
RMIConnectorLogAttributesTest.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 24 收藏 0 点赞 0 评论 0
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
ProviderTest.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 28 收藏 0 点赞 0 评论 0
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());
}
KeikoSniffer.java 文件源码 项目:Keiko 阅读 18 收藏 0 点赞 0 评论 0
private static void createJSR160Server() throws RemoteException, MalformedURLException,
    IOException {
    // Create RMI registry needed for JSR-160 connectors
    LocateRegistry.createRegistry(8998);

    // Create MBeanServer
    final MBeanServer server = MBeanServerFactory.createMBeanServer();

    // Create the JMXConnectorServer
    final JMXServiceURL address =
        new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:8998/jmxconnector");
    // The environment map
    // Map environment = new HashMap();
    // environment.put(JMXConnectorServer.AUTHENTICATOR, new
    // FooAuthenticator());

    final JMXConnectorServer connectorServer =
        JMXConnectorServerFactory.newJMXConnectorServer(address, null, server);

    // Start the JMXConnectorServer
    connectorServer.start();
}
Server.java 文件源码 项目:cacheonix-core 阅读 26 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception
{
   // The MBeanServer
   MBeanServer server = MBeanServerFactory.createMBeanServer();

   // Pass null as the host name to tell JMXServiceURL to default to InetAddress.getLocalHost().getHostName()
   JMXServiceURL url = new JMXServiceURL("hessian+ssl", null, 8443, "/hessianssl");

   // Replace the value of the configuration with the file path of the configuration file
   Map serverEnv = new HashMap();
   serverEnv.put(HTTPConnectorServer.WEB_CONTAINER_CONFIGURATION, "<your-web-container-configuration>");
   JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, serverEnv, server);
   connectorServer.start();

   System.out.println("Server up and running " + connectorServer + " on " + url);
}
Server.java 文件源码 项目:cacheonix-core 阅读 36 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception
{
   // The MBeanServer
   MBeanServer server = MBeanServerFactory.createMBeanServer();

   // Register and start the rmiregistry MBean, needed by JSR 160 RMIConnectorServer
   ObjectName namingName = ObjectName.getInstance("naming:type=rmiregistry");
   server.createMBean("mx4j.tools.naming.NamingService", namingName, null);
   server.invoke(namingName, "start", null, null);
   int namingPort = ((Integer)server.getAttribute(namingName, "Port")).intValue();

   String jndiPath = "/jmxconnector";
   JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:" + namingPort + jndiPath);

   // Create and start the RMIConnectorServer
   JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
   connectorServer.start();

   System.out.println("Server up and running");
}
Server.java 文件源码 项目:cacheonix-core 阅读 32 收藏 0 点赞 0 评论 0
public static void main(String[] args) throws Exception
{
   // The address of the connector server
   JMXServiceURL url = new JMXServiceURL("rmi", "localhost", 0, "/jndi/jmx");

   // No need of environment variables or the MBeanServer at this point
   JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, null);
   ObjectName cntorServerName = ObjectName.getInstance(":service=" + JMXConnectorServer.class.getName() + ",protocol=" + url.getProtocol());

   MBeanServer server = MBeanServerFactory.createMBeanServer("remote.notification.example");
   // Register the connector server as MBean
   server.registerMBean(cntorServer, cntorServerName);

   // The rmiregistry needed to bind the RMI stub
   NamingService naming = new NamingService();
   ObjectName namingName = ObjectName.getInstance(":service=" + NamingService.class.getName());
   server.registerMBean(naming, namingName);
   naming.start();

   // Start the connector server
   cntorServer.start();

   System.out.println("Server up and running");
}
CojacReferences.java 文件源码 项目:Cojac 阅读 19 收藏 0 点赞 0 评论 0
private void registerInstrumentationStats(MBeanServer mbServer, InstrumentationStats stats) {
    try {
        String name = args.getValue(Arg.JMX_NAME);
        int port = Integer.parseInt(args.getValue(Arg.JMX_PORT));
        String host = args.getValue(Arg.JMX_HOST);
        ObjectName statsName = new ObjectName("COJAC:type=InstrumentationMXBean,name=" +
                name);
        LocateRegistry.createRegistry(port);
        StringBuilder sb = new StringBuilder("/jndi/rmi://").append(host).append(":").append(port);
        sb.append("/").append(name);
        JMXServiceURL url = new JMXServiceURL("rmi", null, 0, sb.toString());
        JMXConnectorServer jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbServer);
        jmxConnectorServer.start();
        if (!mbServer.isRegistered(statsName)) {
            mbServer.registerMBean(stats, statsName);
        }
    } catch (MalformedObjectNameException | NullPointerException
            | InstanceAlreadyExistsException
            | MBeanRegistrationException | NotCompliantMBeanException
            | IOException e) {
        e.printStackTrace();
    }
}
GemliteAgent.java 文件源码 项目:GemFireLite 阅读 21 收藏 0 点赞 0 评论 0
public void startRMIConnector(int jmxPort)
{
  try
  {
    LogUtil.getCoreLog().info("RMI port:"+jmxPort);
    ServerConfigHelper.setProperty("JMX_RMI_PORT", ""+jmxPort);
    MBeanServer mbs= ManagementFactory.getPlatformMBeanServer();
    ObjectName namingName = ObjectName.getInstance("naming:type=rmiregistry");
    mbs.registerMBean(new NamingService(jmxPort), namingName);
    mbs.invoke(namingName, "start", null, null);
    String jndiPath = "/jmxconnector";
    String bindIp = ServerConfigHelper.getProperty(ITEMS.BINDIP.name());
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+bindIp+":" + jmxPort + jndiPath);
    JMXConnectorServer connector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);

    ObjectName connectorName = null;
    connectorName = new ObjectName("Gemlite:name=RMIConnector");
    mbs.registerMBean(connector, connectorName);
    connector.start();
  }
  catch (Exception e)
  {
    LogUtil.getCoreLog().error("Error start rmi connector",e);
  }
}


问题


面经


文章

微信
公众号

扫码关注公众号