private void removeTasks(Long requestId) {
    Iterator<Map.Entry<Long, HostRoleCommand>> iter = activeTasksMap.entrySet().iterator();
    while (iter.hasNext()) {
      Map.Entry<Long, HostRoleCommand> entry = iter.next();
      HostRoleCommand hrc = entry.getValue();
      if (hrc.getRequestId() == requestId) {
        if (!hrc.getStatus().isCompletedState()) {
          LOG.error(String.format("Task %d should have been completed before being removed from running task cache(activeTasksMap)", hrc.getTaskId()));
        }
        iter.remove();
      }
    }
  }
Removes list of {@link HostRoleCommand} entries from {@link #activeTasksMap}
@param requestId request id
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListener.java