@Test public void testDereferenceAllConfigLoop() throws IOException { AgentProviderService aps = createAgentProviderService(new Configuration()); Map<String, Map<String, String>> allConfigs = new HashMap<String, Map<String, String>>(); Map<String, String> cfg1 = new HashMap<String, String>(); cfg1.put("a1", "0${@ Map<String, String> cfg2 = new HashMap<String, String>(); cfg2.put("A1", "11${@ allConfigs.put("cfg1", cfg1); allConfigs.put("cfg-2", cfg2); aps.dereferenceAllConfigs(allConfigs); Assert.assertEquals("0${@ Assert.assertEquals("11${@ }
protected void dereferenceAllConfigs(Map<String, Map<String, String>> configurations) { Map<String, String> allConfigs = new HashMap<String, String>(); String lookupFormat = "${@ for (String configType : configurations.keySet()) { Map<String, String> configBucket = configurations.get(configType); for (String configName : configBucket.keySet()) { allConfigs.put(String.format(lookupFormat, configType, configName), configBucket.get(configName)); } } boolean finished = false; while (!finished) { finished = true; for (Map.Entry<String, String> entry : allConfigs.entrySet()) { String configValue = entry.getValue(); for (Map.Entry<String, String> lookUpEntry : allConfigs.entrySet()) { String lookUpValue = lookUpEntry.getValue(); if (lookUpValue.contains("${@ continue; } String lookUpKey = lookUpEntry.getKey(); if (configValue != null && configValue.contains(lookUpKey)) { configValue = configValue.replace(lookUpKey, lookUpValue); } } if (!configValue.equals(entry.getValue())) { finished = false; allConfigs.put(entry.getKey(), configValue); } } } for (String configType : configurations.keySet()) { Map<String, String> configBucket = configurations.get(configType); for (Map.Entry<String, String> entry: configBucket.entrySet()) { String configName = entry.getKey(); String configValue = entry.getValue(); for (Map.Entry<String, String> lookUpEntry : allConfigs.entrySet()) { String lookUpValue = lookUpEntry.getValue(); if (lookUpValue.contains("${@ continue; } String lookUpKey = lookUpEntry.getKey(); if (configValue != null && configValue.contains(lookUpKey)) { configValue = configValue.replace(lookUpKey, lookUpValue); } } configBucket.put(configName, configValue); } } }
AgentProviderService extends AbstractProviderService implements
    ProviderCore,
    AgentKeys,
    SliderKeys, AgentRestOperations { protected void dereferenceAllConfigs(Map<String, Map<String, String>> configurations) { Map<String, String> allConfigs = new HashMap<String, String>(); String lookupFormat = "${@ for (String configType : configurations.keySet()) { Map<String, String> configBucket = configurations.get(configType); for (String configName : configBucket.keySet()) { allConfigs.put(String.format(lookupFormat, configType, configName), configBucket.get(configName)); } } boolean finished = false; while (!finished) { finished = true; for (Map.Entry<String, String> entry : allConfigs.entrySet()) { String configValue = entry.getValue(); for (Map.Entry<String, String> lookUpEntry : allConfigs.entrySet()) { String lookUpValue = lookUpEntry.getValue(); if (lookUpValue.contains("${@ continue; } String lookUpKey = lookUpEntry.getKey(); if (configValue != null && configValue.contains(lookUpKey)) { configValue = configValue.replace(lookUpKey, lookUpValue); } } if (!configValue.equals(entry.getValue())) { finished = false; allConfigs.put(entry.getKey(), configValue); } } } for (String configType : configurations.keySet()) { Map<String, String> configBucket = configurations.get(configType); for (Map.Entry<String, String> entry: configBucket.entrySet()) { String configName = entry.getKey(); String configValue = entry.getValue(); for (Map.Entry<String, String> lookUpEntry : allConfigs.entrySet()) { String lookUpValue = lookUpEntry.getValue(); if (lookUpValue.contains("${@ continue; } String lookUpKey = lookUpEntry.getKey(); if (configValue != null && configValue.contains(lookUpKey)) { configValue = configValue.replace(lookUpKey, lookUpValue); } } configBucket.put(configName, configValue); } } } }
AgentProviderService extends AbstractProviderService implements
    ProviderCore,
    AgentKeys,
    SliderKeys, AgentRestOperations { protected void dereferenceAllConfigs(Map<String, Map<String, String>> configurations) { Map<String, String> allConfigs = new HashMap<String, String>(); String lookupFormat = "${@ for (String configType : configurations.keySet()) { Map<String, String> configBucket = configurations.get(configType); for (String configName : configBucket.keySet()) { allConfigs.put(String.format(lookupFormat, configType, configName), configBucket.get(configName)); } } boolean finished = false; while (!finished) { finished = true; for (Map.Entry<String, String> entry : allConfigs.entrySet()) { String configValue = entry.getValue(); for (Map.Entry<String, String> lookUpEntry : allConfigs.entrySet()) { String lookUpValue = lookUpEntry.getValue(); if (lookUpValue.contains("${@ continue; } String lookUpKey = lookUpEntry.getKey(); if (configValue != null && configValue.contains(lookUpKey)) { configValue = configValue.replace(lookUpKey, lookUpValue); } } if (!configValue.equals(entry.getValue())) { finished = false; allConfigs.put(entry.getKey(), configValue); } } } for (String configType : configurations.keySet()) { Map<String, String> configBucket = configurations.get(configType); for (Map.Entry<String, String> entry: configBucket.entrySet()) { String configName = entry.getKey(); String configValue = entry.getValue(); for (Map.Entry<String, String> lookUpEntry : allConfigs.entrySet()) { String lookUpValue = lookUpEntry.getValue(); if (lookUpValue.contains("${@ continue; } String lookUpKey = lookUpEntry.getKey(); if (configValue != null && configValue.contains(lookUpKey)) { configValue = configValue.replace(lookUpKey, lookUpValue); } } configBucket.put(configName, configValue); } } } AgentProviderService(); }
AgentProviderService extends AbstractProviderService implements
    ProviderCore,
    AgentKeys,
    SliderKeys, AgentRestOperations { protected void dereferenceAllConfigs(Map<String, Map<String, String>> configurations) { Map<String, String> allConfigs = new HashMap<String, String>(); String lookupFormat = "${@ for (String configType : configurations.keySet()) { Map<String, String> configBucket = configurations.get(configType); for (String configName : configBucket.keySet()) { allConfigs.put(String.format(lookupFormat, configType, configName), configBucket.get(configName)); } } boolean finished = false; while (!finished) { finished = true; for (Map.Entry<String, String> entry : allConfigs.entrySet()) { String configValue = entry.getValue(); for (Map.Entry<String, String> lookUpEntry : allConfigs.entrySet()) { String lookUpValue = lookUpEntry.getValue(); if (lookUpValue.contains("${@ continue; } String lookUpKey = lookUpEntry.getKey(); if (configValue != null && configValue.contains(lookUpKey)) { configValue = configValue.replace(lookUpKey, lookUpValue); } } if (!configValue.equals(entry.getValue())) { finished = false; allConfigs.put(entry.getKey(), configValue); } } } for (String configType : configurations.keySet()) { Map<String, String> configBucket = configurations.get(configType); for (Map.Entry<String, String> entry: configBucket.entrySet()) { String configName = entry.getKey(); String configValue = entry.getValue(); for (Map.Entry<String, String> lookUpEntry : allConfigs.entrySet()) { String lookUpValue = lookUpEntry.getValue(); if (lookUpValue.contains("${@ continue; } String lookUpKey = lookUpEntry.getKey(); if (configValue != null && configValue.contains(lookUpKey)) { configValue = configValue.replace(lookUpKey, lookUpValue); } } configBucket.put(configName, configValue); } } } AgentProviderService(); @Override String getHumanName(); @Override List<ProviderRole> getRoles(); @Override Configuration loadProviderConfigurationInformation(File confDir); @Override void validateInstanceDefinition(AggregateConf instanceDefinition); @Override void initializeApplicationConfiguration(
      AggregateConf instanceDefinition, SliderFileSystem fileSystem,
      String roleGroup); @Override void buildContainerLaunchContext(ContainerLauncher launcher,
                                          AggregateConf instanceDefinition,
                                          Container container,
                                          ProviderRole providerRole,
                                          SliderFileSystem fileSystem,
                                          Path generatedConfPath,
                                          MapOperations resourceComponent,
                                          MapOperations appComponent,
                                          Path containerTmpDirPath); @Override void rebuildContainerDetails(List<Container> liveContainers,
                                      String applicationId, Map<Integer, ProviderRole> providerRoleMap); @Override boolean isSupportedRole(String role); @Override RegistrationResponse handleRegistration(Register registration); @Override HeartBeatResponse handleHeartBeat(HeartBeat heartBeat); @Override Map<String, MonitorDetail> buildMonitorDetails(ClusterDescription clusterDesc); @Override void applyInitialRegistryDefinitions(URL amWebURI,
      URL agentOpsURI,
      URL agentStatusURI,
      ServiceRecord serviceRecord); @Override void notifyContainerCompleted(ContainerId containerId); void setInUpgradeMode(boolean inUpgradeMode); void addUpgradeContainers(Set<String> upgradeContainers); void setAppStopInitiated(boolean appStopInitiated); Map<String, String> buildProviderStatus(); }
AgentProviderService extends AbstractProviderService implements
    ProviderCore,
    AgentKeys,
    SliderKeys, AgentRestOperations { protected void dereferenceAllConfigs(Map<String, Map<String, String>> configurations) { Map<String, String> allConfigs = new HashMap<String, String>(); String lookupFormat = "${@ for (String configType : configurations.keySet()) { Map<String, String> configBucket = configurations.get(configType); for (String configName : configBucket.keySet()) { allConfigs.put(String.format(lookupFormat, configType, configName), configBucket.get(configName)); } } boolean finished = false; while (!finished) { finished = true; for (Map.Entry<String, String> entry : allConfigs.entrySet()) { String configValue = entry.getValue(); for (Map.Entry<String, String> lookUpEntry : allConfigs.entrySet()) { String lookUpValue = lookUpEntry.getValue(); if (lookUpValue.contains("${@ continue; } String lookUpKey = lookUpEntry.getKey(); if (configValue != null && configValue.contains(lookUpKey)) { configValue = configValue.replace(lookUpKey, lookUpValue); } } if (!configValue.equals(entry.getValue())) { finished = false; allConfigs.put(entry.getKey(), configValue); } } } for (String configType : configurations.keySet()) { Map<String, String> configBucket = configurations.get(configType); for (Map.Entry<String, String> entry: configBucket.entrySet()) { String configName = entry.getKey(); String configValue = entry.getValue(); for (Map.Entry<String, String> lookUpEntry : allConfigs.entrySet()) { String lookUpValue = lookUpEntry.getValue(); if (lookUpValue.contains("${@ continue; } String lookUpKey = lookUpEntry.getKey(); if (configValue != null && configValue.contains(lookUpKey)) { configValue = configValue.replace(lookUpKey, lookUpValue); } } configBucket.put(configName, configValue); } } } AgentProviderService(); @Override String getHumanName(); @Override List<ProviderRole> getRoles(); @Override Configuration loadProviderConfigurationInformation(File confDir); @Override void validateInstanceDefinition(AggregateConf instanceDefinition); @Override void initializeApplicationConfiguration(
      AggregateConf instanceDefinition, SliderFileSystem fileSystem,
      String roleGroup); @Override void buildContainerLaunchContext(ContainerLauncher launcher,
                                          AggregateConf instanceDefinition,
                                          Container container,
                                          ProviderRole providerRole,
                                          SliderFileSystem fileSystem,
                                          Path generatedConfPath,
                                          MapOperations resourceComponent,
                                          MapOperations appComponent,
                                          Path containerTmpDirPath); @Override void rebuildContainerDetails(List<Container> liveContainers,
                                      String applicationId, Map<Integer, ProviderRole> providerRoleMap); @Override boolean isSupportedRole(String role); @Override RegistrationResponse handleRegistration(Register registration); @Override HeartBeatResponse handleHeartBeat(HeartBeat heartBeat); @Override Map<String, MonitorDetail> buildMonitorDetails(ClusterDescription clusterDesc); @Override void applyInitialRegistryDefinitions(URL amWebURI,
      URL agentOpsURI,
      URL agentStatusURI,
      ServiceRecord serviceRecord); @Override void notifyContainerCompleted(ContainerId containerId); void setInUpgradeMode(boolean inUpgradeMode); void addUpgradeContainers(Set<String> upgradeContainers); void setAppStopInitiated(boolean appStopInitiated); Map<String, String> buildProviderStatus();  }