JMX 라우팅 환경 설정 예
Liberty 프로파일을 사용하여 집합체 제어기 서버를 통해 집합체 멤버 서버에서 JMX(Java™ Management Extensions) 관리 Bean(MBean)을 호출할 수 있습니다.


collectiveMember-1.0 기능은 서버가 집합체 제어기(collectiveController-1.0 기능)에 의해 관리될 수 있도록 합니다. 서버가 집합체 제어기에 의해 관리되도록 구성된 후, 집합체 제어기 서버를 통해 집합체 멤버에 대해 MBean을 직접 호출할 수 있습니다.
다음은 집합체 제어기 서버를 통해 MBeans를 집합체 멤버로 호출하는 방법의 예입니다.
// 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에 대한 모든 나중 호출은 집합체 멤버 서버를
대상으로 지정하기 위해 라우팅됩니다.