private void addRequestId(HostRoleCommand hostRoleCommand) {
    Long requestId = hostRoleCommand.getRequestId();
    StageEntityPK stageEntityPK = new StageEntityPK();
    stageEntityPK.setRequestId(hostRoleCommand.getRequestId());
    stageEntityPK.setStageId(hostRoleCommand.getStageId());
    if (activeRequestMap.containsKey(requestId)) {
      activeRequestMap.get(requestId).addStageEntityPK(stageEntityPK);
    } else {
      RequestEntity requestEntity = requestDAO.findByPK(requestId);
      // Request entity of the hostrolecommand should be persisted before publishing task create event
      assert requestEntity != null;
      Set<StageEntityPK> stageEntityPKs =  Sets.newHashSet(stageEntityPK);
      ActiveRequest request = new ActiveRequest(requestEntity.getStatus(),requestEntity.getDisplayStatus(),
          stageEntityPKs, requestEntity.getClusterId());
      activeRequestMap.put(requestId, request);
    }
  }
Adds new request id to be tracked as running request in {@link #activeRequestMap}
@param hostRoleCommand newly created {@link HostRoleCommand} in {@link #activeTasksMap}
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListener.java