private void loadClustersAndHosts() {
    LOG.info("Initializing cluster and host data.");

    ConcurrentHashMap<String, Cluster> clustersByNameTemp = new ConcurrentHashMap<>();
    ConcurrentHashMap<Long, Cluster> clustersByIdTemp = new ConcurrentHashMap<>();
    ConcurrentHashMap<String, Host> hostsByNameTemp = new ConcurrentHashMap<>();
    ConcurrentHashMap<Long, Host> hostsByIdTemp = new ConcurrentHashMap<>();
    ConcurrentHashMap<String, Set<Cluster>> hostClustersMapTemp = new ConcurrentHashMap<>();
    ConcurrentHashMap<String, Set<Host>> clusterHostsMap1Temp = new ConcurrentHashMap<>();

    List<HostEntity> hostEntities = hostDAO.findAll();
    for (HostEntity hostEntity : hostEntities) {
      Host host = hostFactory.create(hostEntity);
      hostsByNameTemp.put(hostEntity.getHostName(), host);
      hostsByIdTemp.put(hostEntity.getHostId(), host);
    }
    hostsByName = hostsByNameTemp;
    hostsById = hostsByIdTemp;

    for (ClusterEntity clusterEntity : clusterDAO.findAll()) {
      Cluster currentCluster = clusterFactory.create(clusterEntity);
      clustersByNameTemp.put(clusterEntity.getClusterName(), currentCluster);
      clustersByIdTemp.put(currentCluster.getClusterId(), currentCluster);
      clusterHostsMap1Temp.put(currentCluster.getClusterName(), Collections.newSetFromMap(new ConcurrentHashMap<>()));
    }
    clustersByName = clustersByNameTemp;
    clustersById = clustersByIdTemp;

    for (HostEntity hostEntity : hostEntities) {
      Set<Cluster> cSet = Collections.newSetFromMap(new ConcurrentHashMap<Cluster, Boolean>());
      hostClustersMapTemp.put(hostEntity.getHostName(), cSet);

      Host host = getHostsByName().get(hostEntity.getHostName());
      for (ClusterEntity clusterEntity : hostEntity.getClusterEntities()) {
        clusterHostsMap1Temp.get(clusterEntity.getClusterName()).add(host);
        cSet.add(clustersByName.get(clusterEntity.getClusterName()));
      }
    }
    hostClustersMap = hostClustersMapTemp;
    clusterHostsMap1 = clusterHostsMap1Temp;
    // init host configs
    for (Long hostId : hostsById.keySet()) {
      try {
        m_agentConfigsHolder.get().initializeDataIfNeeded(hostId, true);
      } catch (AmbariRuntimeException e) {
        LOG.error("Agent configs initialization was failed", e);
      }
    }
  }
Initializes all of the in-memory state collections that this class
unfortunately uses.
<p>
This method should be called only once, when the data is first needed.
<p/>
Because some of these stateful initializations may actually reference this
{@link Clusters} instance, we must do this after the object has been
instantiated and injected.
ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java