if (availabilityService == null) {
availabilityService = new AvailabilityService();
config.setAvailabilityService(availabilityService);
}
ConvergedLoadBalancer clb = availabilityService.getConvergedLoadBalancer();
if (clb != null) {
String msg = _strMgr.getString("CLBAlreadyConfigured", targetName);
throw new MBeanException(new ConfigException(msg));
}
Boolean selfLb = Boolean.valueOf(selfLoadbalance);
if (selfLb.booleanValue() && lbtargetName == null)
lbtargetName = targetName;
_logger.log(Level.FINE, "Checking if selfloadbalance option and target provided are valid");
if (selfLb.booleanValue() && !lbtargetName.equals(targetName)) {
String msg = _strMgr.getString("ClbTargetSameHostingTarget");
throw new MBeanException(new ConfigException(msg));
}
else if (!selfLb.booleanValue()) {
if (lbtargetName != null && lbtargetName.equals(targetName)) {
String msg = _strMgr.getString("ClbTargetNotSameHostingTarget");
throw new MBeanException(new ConfigException(msg));
}
}
if (clbConfigName == null) {
// create clb config name with given clbName
clbConfigName = clbName + "_CLB_CONFIG";
_logger.log(Level.FINE, "Creating CLB Config " + clbConfigName + "as part of creation of CLB");
AttributeList al = new AttributeList();
al.add(new Attribute(DCRFILE, dcrFileName));
al.add(new Attribute(HTTPLBPOLICY, httplbPolicy));
al.add(new Attribute(SIPLBPOLICY, siplbPolicy));
al.add(new Attribute(LBENABLEINSTANCES, lbenableallInstances));
al.add(new Attribute(TARGET, targetName));
createConvergedLbConfig(al, null, clbConfigName);
}
else {
// check if given clb config exists and
// if clbconfig has dcr file already set
// copy the dcr file to corresponding cluster config directory
ConvergedLbConfig clbConfig = getConvergedLbConfig(clbConfigName);
copyDcrFile(clbConfig, targetName);
}
// we have to create it
clb = new ConvergedLoadBalancer();
clb.setName(clbName);
clb.setConfigFile(clbConfigFile);
clb.setConvergedLbConfigName(clbConfigName);
clb.setAutoCommit(autocommit);
Proxy proxy = new Proxy();
//properties
if (null != props) {
proxy.setElementProperty(convertPropertiesToElementProperties(
props));
}
clb.setProxy(proxy);
availabilityService.setConvergedLoadBalancer(clb);
// If lbenableallinstances is true, set lb-enabled flag to true
setLbEnabledFlag(lbenableallInstances, clbConfigName);