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.

The merged plugin-cfg.xml file name is <clusterName>-plugin-cfg.xml. It is saved in the following directory on the cluster manager by default:
${server.output.dir}/pluginConfig
This directory can be changed by providing the clusterPluginConfig element in the server.xml file:
<clusterPluginConfig>
    <outputDir>new output directory</outputDir>
</clusterPluginConfig>
Note: Make sure that the new output directory is writable and accessible by the fileTransfer MBean. Refer to the fileTransfer MBean documentation for details.
Example:
// 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.