public static void checkDBConfigsConsistency() throws AmbariException {
    LOG.info("Checking DB configs consistency");

    boolean checkPassed = true;

    if (ambariMetaInfo == null) {
      ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
    }

    ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
    List<ClusterEntity> clusters = clusterDAO.findAll();
    if (clusters != null) {
      for (ClusterEntity clusterEntity : clusters) {
        Collection<ClusterConfigEntity> clusterConfigEntities = clusterEntity.getClusterConfigEntities();
        if (null == clusterConfigEntities) {
          return;
        }

        Map<String, Integer> selectedCountForType = new HashMap<>();
        for (ClusterConfigEntity configEntity : clusterConfigEntities) {
          String typeName = configEntity.getType();
          if (configEntity.isSelected()) {
            int selectedCount = selectedCountForType.get(typeName) != null
                ? selectedCountForType.get(typeName) : 0;
            selectedCountForType.put(typeName, selectedCount + 1);
          } else {
            if (!selectedCountForType.containsKey(typeName)) {
              selectedCountForType.put(typeName, 0);
            }
          }
        }

        // Check that every config type from stack is present
        Collection<ClusterServiceEntity> clusterServiceEntities = clusterEntity.getClusterServiceEntities();
        ClusterStateEntity clusterStateEntity = clusterEntity.getClusterStateEntity();
        if (clusterStateEntity != null) {
          StackEntity currentStack = clusterStateEntity.getCurrentStack();
          StackInfo stack = ambariMetaInfo.getStack(currentStack.getStackName(),
              currentStack.getStackVersion());

          for (ClusterServiceEntity clusterServiceEntity : clusterServiceEntities) {
            if (!State.INIT.equals(
                clusterServiceEntity.getServiceDesiredStateEntity().getDesiredState())) {
              String serviceName = clusterServiceEntity.getServiceName();
              ServiceInfo serviceInfo = ambariMetaInfo.getService(stack.getName(),
                  stack.getVersion(), serviceName);

              for (String configTypeName : serviceInfo.getConfigTypeAttributes().keySet()) {
                if (selectedCountForType.get(configTypeName) == null) {
                  checkPassed = false;
                  LOG.error("Configuration {} is missing for service {}", configTypeName,
                      serviceName);
                } else {
                  // Check that for each config type exactly one is selected
                  if (selectedCountForType.get(configTypeName) == 0) {
                    checkPassed = false;
                    LOG.error("Configuration {} has no enabled entries for service {}",
                        configTypeName, serviceName);
                  } else if (selectedCountForType.get(configTypeName) > 1) {
                    checkPassed = false;
                    LOG.error("Configuration {} has more than 1 enabled entry for service {}",
                        configTypeName, serviceName);
                  }
                }
              }
            }
          }
        }
      }
    }

    if (checkPassed) {
      LOG.info("DB configs consistency check passed.");
    } else {
      String errorMessage = "DB configs consistency check failed. Run \"ambari-server start --skip-database-validation\" to skip validation.";
      LOG.error(errorMessage);
      throw new AmbariException(errorMessage);
    }
  }
Validates configuration consistency by ensuring that configuration types
only have a single entry in {@link ClusterConfigEntity} which is enabled.
Additionally will check to ensure that every installed service's
configurations are present in the configuration table.

@throws AmbariException
          if check failed
@see ClusterConfigEntity#isSelected()
ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java