Container currentContainer = fabricService.get().getCurrentContainer();
if (currentContainer == null) {
LOGGER.warn("No current container yet so cannot update!");
return;
}
Profile overlayProfile = currentContainer.getOverlayProfile();
Profile effectiveProfile = Profiles.getEffectiveProfile(fabricService.get(), overlayProfile);
Map<String, Map<String, String>> configurations = effectiveProfile.getConfigurations();
List<Configuration> zkConfigs = asList(configAdmin.get().listConfigurations("(" + FABRIC_ZOOKEEPER_PID + "=*)"));
// FABRIC-803: the agent may use the configuration provided by features definition if not managed
// by fabric. However, in order for this to work, we need to make sure managed configurations
// are all registered before the agent kicks in. Hence, the agent configuration is updated
// after all other configurations.
// Process all configurations but agent
for (String pid : configurations.keySet()) {
if (!pid.equals(Constants.AGENT_PID)) {
Hashtable<String, Object> c = new Hashtable<String, Object>();
c.putAll(configurations.get(pid));
updateConfig(zkConfigs, pid, c);
}
}
// Process agent configuration last
for (String pid : configurations.keySet()) {
if (pid.equals(Constants.AGENT_PID)) {
Hashtable<String, Object> c = new Hashtable<String, Object>();
c.putAll(configurations.get(pid));
c.put(Profile.HASH, String.valueOf(effectiveProfile.getProfileHash()));
updateConfig(zkConfigs, pid, c);
}
}
for (Configuration config : zkConfigs) {
LOGGER.info("Deleting configuration {}", config.getPid());