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,
createPayload(cartridgeInfo, cartName, autoScalingPolicy, repoURL, mysqlPassword, "localhost", payloadZipFileName, tenantId, tenantDomain),
"*",
cartName + "." + cartridgeInfo.getHostName(),
setRegisterServiceProperties(autoScalingPolicy, tenantId,cartName));
deletePayloadFile(payloadZipFileName);
} else {
if (!new Boolean(System.getProperty(CartridgeConstants.FEATURE_INTERNAL_REPO_ENABLED))) {
if (log.isDebugEnabled()) {
log.debug("Internal repo feature is not enabled.");
}
if (repoURL == null || repoURL.trim().length() == 0) {
throw new RepositoryRequiredException("External repository required for subscription");
}
}
if (repoURL != null && repoURL.trim().length() > 0) {
if (log.isDebugEnabled()) {
log.debug("Repo URL entered: " + repoURL);
}
// Validate Remote Repository.
validateRepository(repoURL, repoUsername, repoPassword, privateRepo,
new Boolean(System.getProperty(CartridgeConstants.FEATURE_EXTERNAL_REPO_VAIDATION_ENABLED)));
}
try {
repository = manageRepository(repoURL, repoUsername, repoPassword, cartName, cartridgeInfo, username,
tenantDomain);
} catch (Exception e) {
log.error(e.getMessage());
throw new ADCException(e);
}
// TODO: Check logic here
if (!cartridgeInfo.getMultiTenant()) {
if (policy != null && policy.trim().length() > 0) {
autoScalingPolicy = PolicyHolder.getInstance().getPolicy(policy);
} else {
autoScalingPolicy = PolicyHolder.getInstance().getDefaultPolicy();
}
if (autoScalingPolicy == null) {
throw new PolicyException("Could not load auto-scaling policy.");
}
if (log.isDebugEnabled()) {
log.debug("Selected Policy: " + new Gson().toJson(autoScalingPolicy));
}