@Override
  public void addHost(String hostname) throws AmbariException {
    if (getHostsByName().containsKey(hostname)) {
      throw new AmbariException(MessageFormat.format("Duplicate entry for Host {0}", hostname));
    }

    HostEntity hostEntity = new HostEntity();
    hostEntity.setHostName(hostname);
    hostEntity.setClusterEntities(new ArrayList<>());

    // not stored to DB
    Host host = hostFactory.create(hostEntity);
    host.setAgentVersion(new AgentVersion(""));
    List<DiskInfo> emptyDiskList = new CopyOnWriteArrayList<>();
    host.setDisksInfo(emptyDiskList);
    host.setHealthStatus(new HostHealthStatus(HealthStatus.UNKNOWN, ""));
    host.setHostAttributes(new ConcurrentHashMap<>());
    host.setState(HostState.INIT);

    // the hosts by ID map is updated separately since the host has not yet
    // been persisted yet - the below event is what causes the persist
    getHostsByName().put(hostname, host);
    getHostsById().put(host.getHostId(), host);

    getHostClustersMap().put(hostname,
        Collections.newSetFromMap(new ConcurrentHashMap<>()));

    if (LOG.isDebugEnabled()) {
      LOG.debug("Adding a host to Clusters, hostname={}", hostname);
    }
  }
Register a host by creating a {@link HostEntity} object in the database and setting its state to
{@link HostState#INIT}. This does not add the host the cluster.
@param hostname Host to be added
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java