private PreUpgradeCheckStatus pollRequestStatus(long requestId, Set<String> failedHosts) throws Exception {

    List<RequestEntity> requestEntities = requestDAO.findByPks(Collections.singleton(requestId), true);
    if (requestEntities != null && requestEntities.size() > 0) {

      RequestEntity requestEntity = requestEntities.iterator().next();
      HostRoleStatus requestStatus = requestEntity.getStatus();

      if (HostRoleStatus.COMPLETED.equals(requestStatus)) {
        return PreUpgradeCheckStatus.SUCCESS;
      }

      else if (requestStatus.isFailedState()) {
        failedHosts.addAll(getPreUpgradeCheckFailedHosts(requestEntity));
        LOG.debug("Hadoop Sink version check failed on the following hosts : " + failedHosts.stream().collect(Collectors.joining(",")));
        return PreUpgradeCheckStatus.FAILED;
      } else {
        return PreUpgradeCheckStatus.RUNNING;
      }
    } else {
      LOG.error("Unable to find RequestEntity for created request.");
    }
    return PreUpgradeCheckStatus.FAILED;
  }
Get the status of the requestId and also the set of failed hosts if any.
@param requestId RequestId to track.
@param failedHosts populate this argument for failed hosts.
@return Status of the request.
@throws Exception
ambari-server/src/main/java/org/apache/ambari/server/checks/AmbariMetricsHadoopSinkVersionCompatibilityCheck.java