String mgtClusterDomain = "";
String mgtClusterSubDomain = CartridgeConstants.DEFAULT_MGT_SUBDOMAIN;
CartridgeSubscription subscription = null;
String mysqlPassword = null;
Repository repository = null;
DataCartridge dataCartridge = null;
String cartName = (alias != null && alias.trim().length() > 0) ? alias : cartridgeType;
String payloadZipFileName = "/tmp/" + UUID.randomUUID().toString() + ".zip";
log.info("Subscribing tenant [" + tenantId + "] with username [" + username + "] Cartridge Alias " + alias
+ ", Cartridge Type: " + cartridgeType + ", Repo URL: " + repoURL + ", Policy: " + policy);
// Assign auto scaling only when necessary.
// Muti-tenant cartridge may not need a policy.
Policy autoScalingPolicy = null;
CartridgeInfo cartridgeInfo;
try {
cartridgeInfo = getServiceClient().getCartridgeInfo(cartridgeType);
} catch (UnregisteredCartridgeException e) {
String message = cartridgeType
+ " is not a valid cartridge type. Please try again with a valid cartridge type.";
log.error(message);
throw e;
} catch (Exception e) {
String message = "Error getting info for " + cartridgeType;
log.error(message, e);
throw new ADCException(message, e);
}
validateCartridgeAlias(cartName, cartridgeType);
if (cartridgeType.equals(CartridgeConstants.MYSQL_CARTRIDGE_NAME)) {
autoScalingPolicy = PolicyHolder.getInstance().getDefaultPolicy();
if (autoScalingPolicy == null) {
throw new PolicyException("Could not load default auto-scaling policy.");
}
if (log.isDebugEnabled()) {
log.debug("Selected Policy: " + new Gson().toJson(autoScalingPolicy));
}
dataCartridge = new DataCartridge();
mysqlPassword = generatePassword();
dataCartridge.setPassword(mysqlPassword);
dataCartridge.setDataCartridgeType(cartridgeType);
dataCartridge.setUserName(CartridgeConstants.MYSQL_DEFAULT_USER);
clusterDomain = getDynamicClusterDomain(cartridgeType, cartName, cartridgeInfo);
registerService(cartridgeType,
clusterDomain,
clusterSubDomain,