+

Search Tips   |   Advanced Search

Example of setting up a JMX routing environment

We can use the Liberty profile to call Java Management Extensions (JMX) management beans (MBeans) on a collective member server through a collective controller server.


Note: The collectiveController-1.0 feature and its capabilities are available only in WebSphere Application Server Liberty Network Deployment and WebSphere Application Server Liberty for z/OS .

The feature is not available in WebSphere Application Server Liberty, WebSphere Application Server Liberty - Express , or WebSphere Application Server Liberty Core.

If we have a WebSphere Application Server Liberty Network Deployment installation, we can use its collectiveController-1.0 feature to work with collective members from WebSphere Application Server Liberty, WebSphere Application Server Liberty - Express, or WebSphere Application Server Liberty Core installations.

The collectiveMember-1.0 feature enables a server to be managed by a collective controller (the collectiveController-1.0 feature) . After a server is configured to be managed by a collective controller, we can directly call any MBeans on the collective member through the collective controller server.

The following is an example of how to call MBeans on a collective member through a collective controller server.

// 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();

// We have a MBeanServerConnection now; at this point, however, all of the 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");
    }
If the routing context is configured correctly, all future calls to this MBeanServerConnection will be routed to target collective member server.


Parent topic: Work with JMX MBeans

Concepts:

  • Collective architecture
  • File transfer in a Liberty collective
  • Collective security
  • File transfer
  • Liberty collective troubleshooting

    Tasks:

  • Set the default host name of a Liberty server
  • Configure a Liberty collective
  • Register host computers with a Liberty collective
  • Set the JAVA_HOME variable for Liberty collective members
  • Configure Liberty collective replica sets

    Reference:

  • List of provided MBeans
  • Overriding Liberty server host information