/** Parse and populate child configuration modules. */
  private void populateConfigurationModules() {
    ConfigurationDirectory configDirectory =
        serviceDirectory.getConfigurationDirectory(serviceInfo.getConfigDir());

    if (configDirectory != null) {
      for (ConfigurationModule config : configDirectory.getConfigurationModules()) {
        ConfigurationInfo info = config.getModuleInfo();
        if (isValid()) {
          setValid(config.isValid() && info.isValid());
          if (!isValid()) {
            setErrors(config.getErrors());
            setErrors(info.getErrors());
          }
        }
        serviceInfo.getProperties().addAll(info.getProperties());
        serviceInfo.setTypeAttributes(config.getConfigType(), info.getAttributes());
        configurationModules.put(config.getConfigType(), config);
      }

      for (String excludedType : serviceInfo.getExcludedConfigTypes()) {
        if (!configurationModules.containsKey(excludedType)) {
          ConfigurationInfo configInfo =
              new ConfigurationInfo(
                  Collections.<PropertyInfo>emptyList(), Collections.<String, String>emptyMap());
          ConfigurationModule config = new ConfigurationModule(excludedType, configInfo);

          config.setDeleted(true);
          configurationModules.put(excludedType, config);
        }
      }
    }
  }
  /**
   * Merge configurations with the parent configurations. This will update the child configuration
   * module set as well as the underlying info instances.
   *
   * @param parent parent service module
   * @param allStacks all stack modules
   * @param commonServices common service modules
   */
  private void mergeConfigurations(
      ServiceModule parent,
      Map<String, StackModule> allStacks,
      Map<String, ServiceModule> commonServices)
      throws AmbariException {
    serviceInfo.getProperties().clear();
    serviceInfo.setAllConfigAttributes(new HashMap<String, Map<String, Map<String, String>>>());

    Collection<ConfigurationModule> mergedModules =
        mergeChildModules(
            allStacks, commonServices, configurationModules, parent.configurationModules);

    for (ConfigurationModule module : mergedModules) {
      configurationModules.put(module.getId(), module);
      if (!module.isDeleted()) {
        serviceInfo.getProperties().addAll(module.getModuleInfo().getProperties());
        serviceInfo.setTypeAttributes(
            module.getConfigType(), module.getModuleInfo().getAttributes());
      }
    }
  }