in software/webapp/src/main/java/org/apache/brooklyn/entity/dns/geoscaling/GeoscalingDnsServiceImpl.java [160:202]
protected void reconfigureService(Collection<HostGeoInfo> targetHosts) {
if (!isConfigured) {
this.rememberedTargetHosts = MutableSet.copyOf(targetHosts);
return;
}
webClient.login(username, password);
Domain primaryDomain = webClient.getPrimaryDomain(primaryDomainName);
if (primaryDomain==null)
throw new NullPointerException(this+" got null from web client for primary domain "+primaryDomainName);
SmartSubdomain smartSubdomain = primaryDomain.getSmartSubdomain(smartSubdomainName);
if (smartSubdomain == null) {
log.info("GeoScaling {} smart subdomain '{}.{}' does not exist, creating it now", new Object[] {this, smartSubdomainName, primaryDomainName});
// TODO use WithMutexes to ensure this is single-entrant
primaryDomain.createSmartSubdomain(smartSubdomainName);
smartSubdomain = primaryDomain.getSmartSubdomain(smartSubdomainName);
}
if (smartSubdomain != null) {
log.debug("GeoScaling {} being reconfigured to use {}", this, targetHosts);
String script = GeoscalingScriptGenerator.generateScriptString(targetHosts);
smartSubdomain.configure(PROVIDE_CITY_INFO, script);
if (targetHosts.isEmpty()) {
setServiceState(Lifecycle.CREATED);
sensors().set(ROOT_URL, null);
sensors().set(MAIN_URI, null);
} else {
setServiceState(Lifecycle.RUNNING);
String domain = getAttribute(MANAGED_DOMAIN);
if (!Strings.isEmpty(domain)) {
sensors().set(ROOT_URL, "http://"+domain+"/");
sensors().set(MAIN_URI, URI.create("http://"+domain+"/"));
}
}
} else {
log.warn("Failed to retrieve or create GeoScaling smart subdomain '"+smartSubdomainName+"."+primaryDomainName+
"', aborting attempt to configure service");
setServiceState(Lifecycle.ON_FIRE);
}
webClient.logout();
}