有关设置 JMX 路由环境的示例

您可使用 Liberty 在集合体成员服务器上通过集合体控制器服务器来调用 Java™ 管理扩展 (JMX) 管理 Bean (MBean)。

For distributed platformsFor IBM i platforms注: collectiveController-1.0 功能部件及其功能仅在 WebSphere® Application Server Network Deployment LibertyWebSphere Application Server for z/OS® Liberty 中可用。该功能部件在 WebSphere Application Server LibertyWebSphere Application Server Liberty Core 中不可用。如果已安装 WebSphere Application Server Network Deployment Liberty,那么可使用其 collectiveController-1.0 功能部件以处理 WebSphere Application Server LibertyWebSphere Application Server Express® LibertyWebSphere Application Server Liberty Core 安装中的集合体成员。

collectiveMember-1.0 功能部件允许服务器由集合体控制器(collectiveController-1.0 功能部件)管理。将服务器配置为由集合体控制器来管理之后,可以通过集合体控制器服务器来直接调用集合体成员上的任何 MBean。

以下示例是通过集合体控制器服务器来调用集合体成员上的 MBean 的示例。

// Set up the trust store to the collective controller server.

    System.setProperty("javax.net.ssl.trustStore", "<trustStore for https connection to collective controller>");
    System.setProperty("javax.net.ssl.trustStorePassword", "<trustStore password>");

    Map<String, Object> environment = new HashMap<String, Object>();
    environment.put("jmx.remote.protocol.provider.pkgs", "com.ibm.ws.jmx.connector.client");
    environment.put(JMXConnector.CREDENTIALS, new String[] { "<username>", "<password>" });
    environment.put(ClientProvider.DISABLE_HOSTNAME_VERIFICATION, true);
    environment.put(ClientProvider.READ_TIMEOUT, 2 * 60 * 1000);

    JMXServiceURL url = new JMXServiceURL(
        "REST", "<hostname of collective controller server>", <https port>, "/IBMJMXConnectorREST");
    jmxConnector = JMXConnectorFactory.connect(url, environment);
    MBeanServerConnection exmbsc = jmxConnector.getMBeanServerConnection();

// You have a MBeanServerConnection now; at this point, however, all of your MBean calls 
// are on the collective controller server.

// The next few lines of code are to set up the routing context so that all calls 
// can be routed to a collective member.

   ObjectName rmObjectName = new ObjectName(
       "WebSphere:feature=collectiveController,type=RoutingContext,name=RoutingContext");

// Call the MBeanRoutingContext MBean to set up the routing context.

    Object rcObj = connection.invoke(rmObjectName, "assignServerContext",
    new Object[] { 
        "<hostname of the collective member>", "<collective member server usr dir>", "<collective member server name>"
    },  

// With the collective-member server usr dir and collective-member server name, 
// the managed server can be uniquely identified on a host.

    new String[] { "java.lang.String", "java.lang.String", "java.lang.String" });

    if (rcObj instanceof Boolean) {
        Boolean result = (Boolean) rcObj;
    if (result.booleanValue()) {
       System.out.println("routing context is configured correctly");
       }
    Or if (!result.booleanValue()) {
       System.out.println("routing context result is false");
       }
    } else {
        System.out.println("failed to configure routing context");
    }
如果正确配置了路由上下文,那么将来对此 MBeanServerConnection 进行的所有调用都将路由至目标集合体成员服务器。

用于指示主题类型的图标 参考主题

文件名:rwlp_jmx_routing.html