Fields Summary |
---|
private static final String | COMMA |
private static final String | COLON |
private static final String | EQUAL |
public static final String | NAME_PROP_VALUE |
public static final String | LAST_APPLIED_PROPERTY |
public static final String | LAST_APPLIED_HASH_PROPERTY |
public static final String | LAST_EXPORTED_PROPERTY |
public static final String | LOADBALANCER_CONFIG_OBJECT_NAME |
public static final String | LBCONFIG_OBJECT_NAME |
public static final String | LOADBALANCER_OBJECT_NAME |
private static final String | XML_COMMENT_START |
private static final String | MD5 |
private final com.sun.enterprise.server.pluggable.LBFeatureFactory | lbFactory |
private final com.sun.appserv.management.config.LoadBalancerConfig | loadBalancerConfig |
private final MBeanServerConnection | mServer |
Methods Summary |
---|
public void | applyLBChanges()Applies changes in the corresponding configuration to this LB
final String lbConfigName = loadBalancerConfig.getLbConfigName();
lbFactory.applyChanges(lbConfigName, getName());
if(!loadBalancerConfig.existsProperty(LAST_APPLIED_PROPERTY))
loadBalancerConfig.createProperty(LAST_APPLIED_PROPERTY,String.valueOf(new Date().getTime()));
else
loadBalancerConfig.setPropertyValue(LAST_APPLIED_PROPERTY,String.valueOf(new Date().getTime()));
String digest = getMessageDigest();
if(!loadBalancerConfig.existsProperty(LAST_APPLIED_HASH_PROPERTY))
loadBalancerConfig.createProperty(LAST_APPLIED_HASH_PROPERTY,digest);
else
loadBalancerConfig.setPropertyValue(LAST_APPLIED_HASH_PROPERTY,digest);
|
private com.sun.appserv.management.config.LBConfig | getLBConfig(java.lang.String lbConfigName)
ObjectName lbConfigObjName = null;
try{
lbConfigObjName =
new ObjectName(LBCONFIG_OBJECT_NAME+lbConfigName);
} catch ( MalformedObjectNameException e ){
e.printStackTrace();
}
LBConfig lbConfig = getProxy(lbConfigObjName, LBConfig.class);
return lbConfig;
|
public java.util.Date | getLastApplied()Returns the timestamp of the most recent application of referenced LBConfig
final String lbName = getName();
if(loadBalancerConfig.existsProperty(LAST_APPLIED_PROPERTY))
return new Date(Long.valueOf(loadBalancerConfig.getPropertyValue(LAST_APPLIED_PROPERTY)));
return null;
|
public java.lang.String | getLastAppliedMessageDigest()method to return the message digest of the load balaner.xml that was last
applied
final String lbName = getName();
if(loadBalancerConfig.existsProperty(LAST_APPLIED_HASH_PROPERTY))
return loadBalancerConfig.getPropertyValue(LAST_APPLIED_HASH_PROPERTY);
return null;
|
public java.util.Date | getLastExported()Returns the timestamp of the most recent export of referenced LBConfig
final String lbName = getName();
final String lbConfigName = loadBalancerConfig.getLbConfigName();
LBConfig lbConfig = getLBConfig(lbConfigName);
if(lbConfig.existsProperty(LAST_EXPORTED_PROPERTY))
return new Date(Long.valueOf(lbConfig.getPropertyValue(LAST_EXPORTED_PROPERTY)));
return null;
|
public java.util.Date | getLastResetTime()Returns the timestamp of the last time the stats on this loadbalancer were reset
return null;
|
public java.lang.String | getLoadBalancerXML()Exports the corresponding LBConfig information and returns the contents as a string.
return getLoadBalancerXML(true);
|
private java.lang.String | getLoadBalancerXML(boolean updateTimeStamp)
final String lbName = getName();
final String lbConfigName = loadBalancerConfig.getLbConfigName();
final LBConfig lbConfig = getLBConfig(lbConfigName);
if(updateTimeStamp) {
if(!lbConfig.existsProperty(LAST_EXPORTED_PROPERTY))
lbConfig.createProperty(LAST_EXPORTED_PROPERTY,String.valueOf(new Date().getTime()));
else
lbConfig.setPropertyValue(LAST_EXPORTED_PROPERTY,String.valueOf(new Date().getTime()));
}
return lbFactory.getLoadBalancerXML(lbConfigName,lbName);
|
private java.lang.String | getMessageDigest()
try {
String lbxml = getLoadBalancerXML(false).split(XML_COMMENT_START)[0];
MessageDigest md = MessageDigest.getInstance(MD5);
md.update(lbxml.getBytes());
String hash = new BigInteger(md.digest()).toString(16);
return hash;
}catch(NoSuchAlgorithmException e){
getMBeanLogger().warning(e.getMessage());
if(getMBeanLogger().isLoggable(Level.FINE))
e.printStackTrace();
}
return "";
|
public java.lang.String | getStatus(java.lang.String instanceName)Returns the uhealthy/healthy/quiesced status for an insatnce load balanced
by this load balancer.
return null;
|
public boolean | isApplyChangeRequired()checks if apply change is required
boolean isRequired = true;
try{
String digest = getMessageDigest();
String lastDigest = getLastAppliedMessageDigest();
if(lastDigest!=null)
isRequired = !digest.equals(lastDigest);
}catch (Throwable t){
getMBeanLogger().warning(t.getMessage());
if(getMBeanLogger().isLoggable(Level.FINE))
t.printStackTrace();
}
return isRequired;
|
public void | resetStats()Reset the monitoring stats on this loadbalancer.
final String lbName = getName();
final String lbConfigName = loadBalancerConfig.getLbConfigName();
lbFactory.resetStats(lbConfigName,lbName);
|
public boolean | testConnection()Test the LB and Domain Application Server setup
final String lbName = getName();
final String lbConfigName = loadBalancerConfig.getLbConfigName();
return lbFactory.testConnection(lbConfigName,lbName);
|