Generating a merged plug-in configuration for Liberty servers by using the ClusterManager MBean
You can call the ClusterManager
MBean
generateClusterPluginConfig
operation to create a single, merged
plugin-cfg.xml file that instructs a web server plug-in to redirect requests to
multiple application servers residing on multiple hosts.
About this task
The operation first generates server-specific plugin-cfg.xml files on each started cluster member. The operation then merges the server-specific plugin-cfg.xml files into one plugin-cfg.xml file on the cluster manager.
This operation works only if the cluster has at least two started cluster members. The path to
the merged plugin-cfg.xml file on the cluster manager is returned to the
client. Therefore, it can be downloaded using the fileTransfer
MBean.
${server.output.dir}/pluginConfig
clusterPluginConfig
element in
the server.xml
file:<clusterPluginConfig>
<outputDir>new output directory</outputDir>
</clusterPluginConfig>
fileTransfer
MBean. Refer to the fileTransfer
MBean documentation for details.// call the generateClusterPluginConfig operation on the ClusterManager MBean to generate
// a merged plugin-cfg.xml file for all started cluster members.
String clusterName = "myCluster";
ObjectName rmObjectName = new ObjectName("WebSphere:feature=collectiveController,type=ClusterManager,name=ClusterManager");
// rcObj contains the absolute path to the merged plugin-cfg.xml file.
Object rcObj = connection.invoke(rmObjectName, "generateClusterPluginConfig",
new Object[] { clusterName },
new String[] { "java.lang.String" });
// invoke the downloadFile operation on fileTransfer MBean to download the merged plugin-cfg.xml to the client.
String sourceFilePath = (String) rcObj;
String targetFilePath = "<my target directory>";
ObjectName objectName = new ObjectName("WebSphere:feature=restConnector,type=FileTransfer,name=FileTransfer");
connection.invoke(objectName, "downloadFile",
new String[] { sourceFilePath, targetFilePath },
new String[] { "java.lang.String", "java.lang.String" });
Refer to the ClusterManager
MBean documentation for additional information on
cluster management.