*
* @param alias name of the cartridge to be unsubscribed
*/
public void unsubscribe(String alias) throws ADCException, NotSubscribedException {
checkSuperTenant();
CartridgeSubscription subscription = null;
try {
subscription = PersistenceManager.getSubscription(tenantDomain, alias);
} catch (Exception e) {
String msg = "Failed to get subscription for " + tenantDomain + " and alias " + alias;
log.error(msg, e);
throw new ADCException(msg, e);
}
if (subscription == null) {
String msg = "Tenant " + tenantDomain + " is not subscribed for " + alias;
log.error(msg);
throw new NotSubscribedException("You have not subscribed for " + alias, alias);
}
try {
String clusterDomain = subscription.getClusterDomain();
String clusterSubDomain = subscription.getClusterSubdomain();
if (log.isDebugEnabled()) {
log.debug("Finding cartridge information for " + subscription.getCartridge());
}
CartridgeInfo cartridgeInfo = ApplicationManagementUtil.getServiceClient().getCartridgeInfo(subscription.getCartridge());
if (log.isDebugEnabled()) {
log.debug("Found " + cartridgeInfo.getDisplayName() + " for " + subscription.getCartridge());
}
if (!cartridgeInfo.getMultiTenant()) {
log.info("Terminating all instances of " + clusterDomain + " " + clusterSubDomain);
ApplicationManagementUtil.getServiceClient().terminateAllInstances(clusterDomain, clusterSubDomain);
log.info("All instances terminated.");
log.info("Unregistering services...");
ApplicationManagementUtil.getServiceClient().unregisterService(clusterDomain, clusterSubDomain);
log.info("Successfully terminated instances ..");
} else {
if (log.isInfoEnabled()) {
log.info("Cartridge "
+ subscription.getCartridge()
+ " is a multi-tenant cartridge and therefore will not terminate all instances and unregister services");
}
}
new RepositoryFactory().destroyRepository(alias, tenantDomain, getUsername());
log.info("Repo is destroyed successfully.. ");
PersistenceManager.updateSubscriptionState(subscription.getSubscriptionId(), "UNSUBSCRIBED");
new DNSManager().removeSubDomain(subscription.getHostName());
registryManager.removeDomainMappingFromRegistry(subscription.getHostName());
TopologyManagementService topologyMgtService = DataHolder.getTopologyMgtService();
String[] ips = topologyMgtService.getActiveIPs(subscription.getCartridge(),
subscription.getClusterDomain(), subscription.getClusterSubdomain());
PersistenceManager.updateInstanceState("INACTIVE", ips, subscription.getClusterDomain(), subscription.getClusterSubdomain(), subscription.getCartridge());
} catch (ADCException e) {
log.error(e.getMessage(), e);
throw e;
} catch (Exception e1) {