@Override
  protected boolean handleUpdate(TopologyUpdateEvent update) throws AmbariException {
    TopologyUpdateHandlingReport report = new TopologyUpdateHandlingReport();
    UpdateEventType eventType = update.getEventType();
    for (Map.Entry<String, TopologyCluster> updatedCluster : update.getClusters().entrySet()) {
      String clusterId = updatedCluster.getKey();
      TopologyCluster cluster = updatedCluster.getValue();
      if (getData().getClusters().containsKey(clusterId)) {
        if (eventType.equals(UpdateEventType.DELETE) &&
            CollectionUtils.isEmpty(cluster.getTopologyComponents()) &&
            CollectionUtils.isEmpty(cluster.getTopologyHosts())) {
          getData().getClusters().remove(clusterId);
          report.mappingWasChanged();
        } else {
          getData().getClusters().get(clusterId).update(
              update.getClusters().get(clusterId).getTopologyComponents(),
              update.getClusters().get(clusterId).getTopologyHosts(),
              eventType, report);
        }
      } else {
        if (eventType.equals(UpdateEventType.UPDATE)) {
          getData().getClusters().put(clusterId, cluster);
          report.mappingWasChanged();
        } else {
          throw new ClusterNotFoundException(Long.parseLong(clusterId));
        }
      }
    }
    stackAdvisorHelper.clearCaches(report.getUpdatedHostNames());
    return report.wasChanged();
  }
Is used during agent registering to provide base info about clusters topology.
@return filled TopologyUpdateEvent with info about all components and hosts in all clusters
ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/TopologyHolder.java