String domain = null, subDomain = null;
log.debug("************ Target Host: "+targetHost + " -- Tenant id : "+tenantId);
HostContext ctxt = hostCtxts.get(targetHost);
if (ctxt == null) {
DomainMapping domainMapping = mappingCache.getMapping(targetHost);
if (domainMapping == null) {
registryManager = new RegistryManager();
domainMapping = registryManager.getMapping(targetHost);
mappingCache.addValidMapping(targetHost, domainMapping);
}
if (domainMapping != null) {
String actualHost = domainMapping.getActualHost();
// get the HostContext from the actual host name in the case of domain
// mapping.
ctxt = hostCtxts.get(actualHost);
}
}
if (ctxt == null) {
log.debug("Host Context is null.");
// we don't need to do anything
return true;
}
// gets the corresponding domain
domain = ctxt.getDomainFromTenantId(tenantId);
synCtx.setProperty(AutoscaleConstants.TARGET_DOMAIN, domain);
// gets the corresponding sub domain
subDomain = ctxt.getSubDomainFromTenantId(tenantId);
synCtx.setProperty(AutoscaleConstants.TARGET_SUB_DOMAIN, subDomain);
if (appDomainContexts.get(domain) == null) {
// if we do not find a correct context, we just ignore
log.debug("AppDomainContext not found for domain " + domain);