@Override
  public void addHost(Host host) throws AmbariException {
    hostLock.writeLock().lock();
    try {
      if (m_hosts.containsKey(host.getHostId())) {
        String message = String.format(
            "Host %s is already associated with the configuration group %s", host.getHostName(),
            configGroupName);

        throw new DuplicateResourceException(message);
      }

      // ensure that we only update the in-memory structure if the merge was
      // successful
      ConfigGroupEntity configGroupEntity = getConfigGroupEntity();
      persistHostMapping(Collections.singletonList(host), configGroupEntity);
      m_hosts.putIfAbsent(host.getHostId(), host);
    } finally {
      hostLock.writeLock().unlock();
    }
  }
Persist config group config mapping and create configs if not in DB

@param clusterEntity
@throws Exception
ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java