public void processVersionReports(ComponentVersionReports versionReports, String hostname) throws AmbariException {
    Set<Cluster> clusters = clusterFsm.getClustersForHost(hostname);
    for (Cluster cl : clusters) {
      for (Map.Entry<String, List<ComponentVersionReport>> status : versionReports
          .getComponentVersionReports().entrySet()) {
        if (Long.valueOf(status.getKey()).equals(cl.getClusterId())) {
          for (ComponentVersionReport versionReport : status.getValue()) {
            try {
              Service svc = cl.getService(versionReport.getServiceName());

              String componentName = versionReport.getComponentName();
              if (svc.getServiceComponents().containsKey(componentName)) {
                ServiceComponent svcComp = svc.getServiceComponent(
                    componentName);
                ServiceComponentHost scHost = svcComp.getServiceComponentHost(
                    hostname);

                String version = versionReport.getVersion();

                HostComponentVersionAdvertisedEvent event = new HostComponentVersionAdvertisedEvent(cl,
                    scHost, version);
                versionEventPublisher.publish(event);
              }
            } catch (ServiceNotFoundException e) {
              LOG.warn("Received a version report for a non-initialized"
                  + " service"
                  + ", clusterId=" + versionReport.getClusterId()
                  + ", serviceName=" + versionReport.getServiceName());
              continue;
            } catch (ServiceComponentNotFoundException e) {
              LOG.warn("Received a version report for a non-initialized"
                  + " servicecomponent"
                  + ", clusterId=" + versionReport.getClusterId()
                  + ", serviceName=" + versionReport.getServiceName()
                  + ", componentName=" + versionReport.getComponentName());
              continue;
            } catch (ServiceComponentHostNotFoundException e) {
              LOG.warn("Received a version report for a non-initialized"
                  + " hostcomponent"
                  + ", clusterId=" + versionReport.getClusterId()
                  + ", serviceName=" + versionReport.getServiceName()
                  + ", componentName=" + versionReport.getComponentName()
                  + ", hostname=" + hostname);
              continue;
            } catch (RuntimeException e) {
              LOG.warn("Received a version report with invalid payload"
                  + " service"
                  + ", clusterId=" + versionReport.getClusterId()
                  + ", serviceName=" + versionReport.getServiceName()
                  + ", componentName=" + versionReport.getComponentName()
                  + ", hostname=" + hostname
                  + ", error=" + e.getMessage());
              continue;
            }
          }
        }
      }
    }
  }
Process reports of components versions
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java