private void prepareAgentTopology(TopologyUpdateEvent topologyUpdateEvent) {
    if (topologyUpdateEvent.getClusters() != null) {
      for (TopologyCluster topologyCluster : topologyUpdateEvent.getClusters().values()) {
        if (CollectionUtils.isNotEmpty(topologyCluster.getTopologyComponents())) {
          for (TopologyComponent topologyComponent : topologyCluster.getTopologyComponents()) {
            topologyComponent.setHostNames(new HashSet<>());
            topologyComponent.setPublicHostNames(new HashSet<>());
            topologyComponent.setLastComponentState(null);
          }
        }
        if (topologyUpdateEvent.getEventType().equals(UpdateEventType.DELETE)
            && CollectionUtils.isNotEmpty(topologyCluster.getTopologyHosts())) {
          for (TopologyHost topologyHost : topologyCluster.getTopologyHosts()) {
            topologyHost.setHostName(null);
          }
        }
      }
    }
  }
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