lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType);
} catch (Exception e) {
String message = "Error getting info for " + lbCartridgeType;
log.error(message, e);
throw new ADCException(message, e);
}
if (lbCartridgeInfo == null) {
String msg = "Please specify a LB cartridge type for the cartridge: " + serviceType + " as category: " +
Constants.DEFAULT_LOAD_BALANCER;
log.error(msg);
throw new ADCException(msg);
}
lbDataCtxt.setLbCartridgeInfo(lbCartridgeInfo);
if (log.isDebugEnabled()) {
log.debug("This cartridge uses default load balancer. " + "[Type] " + serviceType);
}
try {
// get the valid policies for lb cartridge
DeploymentPolicy[] lbCartridgeDepPolicies =
getAutoscalerServiceClient().getDeploymentPolicies(lbCartridgeType);
// traverse deployment policies of lb cartridge
for (DeploymentPolicy policy : lbCartridgeDepPolicies) {
// check existence of the subscribed policy
if (deploymentPolicyName.equals(policy.getId())) {
if (!getAutoscalerServiceClient().checkDefaultLBExistenceAgainstPolicy(deploymentPolicyName)) {
if(log.isDebugEnabled()){
log.debug(" Default LB doesn't exist for deployment policy ["+deploymentPolicyName+"] ");
}
Properties lbProperties = new Properties();
// if LB cartridge definition has properties as well, combine
if (lbCartridgeInfo.getProperties() != null && lbCartridgeInfo.getProperties().length > 0) {
if(log.isDebugEnabled()){
log.debug(" Combining LB properties ");
}
lbProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{lbRefProperty}));
} else {
lbProperties.setProperties(new Property[]{lbRefProperty});
}
lbDataCtxt.addLBProperties(lbProperties);
}
}
}
} catch (Exception ex) {
// we don't need to throw the error here.
log.error(ex.getMessage(), ex);
}
// set deployment and autoscaling policies
lbDataCtxt.setDeploymentPolicy(deploymentPolicyName);
lbDataCtxt.setAutoscalePolicy(lbCartridgeInfo.getDefaultAutoscalingPolicy());
lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty);
break;
}
} else if (Constants.SERVICE_AWARE_LOAD_BALANCER.equals(name)) {
if ("true".equals(value)) {
lbDataCtxt.setLbCategory(Constants.SERVICE_AWARE_LOAD_BALANCER);
lbRefProperty.setValue(name);
CartridgeInfo lbCartridgeInfo;
try {
lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType);
} catch (Exception e) {
String message = "Error getting info for " + lbCartridgeType;
log.error(message, e);
throw new ADCException(message, e);
}
if (lbCartridgeInfo == null) {
String msg = "Please specify a LB cartridge type for the cartridge: " + serviceType + " as category: " +
Constants.SERVICE_AWARE_LOAD_BALANCER;
log.error(msg);
throw new ADCException(msg);
}
lbDataCtxt.setLbCartridgeInfo(lbCartridgeInfo);
// add a property for the service type