AMX

Load balancer package summary.

Contents

Overview
API
Examples
Overview

The Load balancer administration is a glassfish component used to manage the HTTP Load balancer Plugin of the Webserver. HTTP LB plug-in stores its configuration in loadbalancer.xml. Instead of asking users to manually edit this loadbalancer.xml, we can generate loadbalancer.xml and push it to the HTTP LB plug-in automatically. This reduces chances of manual errors. In Glassfish, a load balancer configuration is a named configuration in the `domain.xml` file. Load balancer configuration can contain clusters or stand alone instances. It also has optional configuration for configuring the policy, weights to instances, LB device host and port details to push the loadbalancer.xml when certain changes happen (adding/deleting instance, deploy/undeploy,enable/disable an app etc.,) and health-check information. The AMX API for Load balancer provides an interface to configure this component programmatically.
API

Following is the AMX API for Load balancer administration
LBConfigHelper - appserv-api\src\java\com\sun\appserv\management/helper/LBConfigHelper . This is the AMX API which the clients use to administer most of the load-balancer elements in the domain.xml.
Loadbalancer - appserv-api\src\java\com\sun\appserv\management\ext\lb\LoadBalancer.java, this is the AMX code to do some of the new Load balancer configuration (apply lb-changes, ping-connection)
Others
MBeans - /admin-ee/lb-admin/src/java/com/sun/enterprise/ee/admin/lbadmin/mbeans/ contains the MBean interface and implementation to manage Load Balancer configuration.
Reader - /admin-ee/lb-admin/src/java/com/sun/enterprise/ee/admin/lbadmin/reader . contains the code that reads the config elements in domain.xml
Transform - /admin-ee/lb-admin/src/java/com/sun/enterprise/ee/admin/lbadmin/transform/ . contains the code that implements the Visitors, which visit the above readers and populate the elements in loadbalancer.xml
schema2beans - We read information from loadbalancer.xml using schema2beans. These generated schema2beans are in /admin-ee/lb-admin/src/java/com/sun/enterprise/ee/admin/lbadmin/beans/
Writer - /admin-ee/lb-admin/src/java/com/sun/enterprise/ee/admin/lbadmin/writer/ . The logic to the configuration to loadbalancer.xml is in Writer .

Examples

To create load-balancer configuration
new LBConfigHelper(domainRoot).createLoadBalancer(lbName, target, getLBParams(), LBProperties);
To delete a load-balancer configuration
new LBConfigHelper(domainRoot).removeLoadbalancer(lbName);
To get a list of load-balancer configurations
Map lbMap = domainConfig.getLoadBalancerConfigMap();
for (Object key : lbMap.keySet()) System.out.println((String)key);
To ping the Load balancer plugin for a secure connection (used for pushing the loadbalancer.xml and getting the monitoring data)
domainRoot.getLoadBalancerMap().get(lbName).testConnection()
To apply the load-balancer changes
domainRoot.getLoadBalancerMap().get(lbName).applyLBChanges()

##

To configure the weights for instances in a cluster
new LBConfigHelper(domainRoot).configureLBWeight(clusterName, instanceWeights);
To create a load-balancer reference to an existing lb-configuration (a domain.xml element)
new LBConfigHelper(domainRoot).createLBRef(lbName, configName, target, mOptions);
To delete a load-balancer reference from an existing lb-configuration (a domain.xml element)
new LBConfigHelper(domainRoot).removeLBRef(lbName, configName, target, mOptions);