@Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    ContainerId yarnContainerId;
    PrintWriter printWriter = resp.getWriter();
    String containerIdParam = req.getParameter(CoordinationConstants.YARN_EXECUTION_ENVIRONMENT_CONTAINER_ID);
    ContainerHeartbeatResponse response;
    resp.setContentType(APPLICATION_JSON);
    boolean alive = false;
    try {
      yarnContainerId = ContainerId.fromString(containerIdParam);
      for (YarnContainer yarnContainer : yarnAppState.runningProcessors.values()) {
        if (yarnContainer.id().compareTo(yarnContainerId) == 0) {
          alive = true;
          break;
        }
      }
      if (!alive) {
        heartbeatsExpiredCount.inc();
      }
      response = new ContainerHeartbeatResponse(alive);
      printWriter.write(mapper.writeValueAsString(response));
    } catch (IllegalArgumentException e) {
      LOG.error("Container ID {} passed is invalid", containerIdParam);
      resp.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
    }
  }
Responds to heartbeat requests from the containers with a {@link ContainerHeartbeatResponse}.
The heartbeat request contains the <code> executionContainerId </code>
which in YARN's case is the YARN container Id.
This servlet validates the container Id against the list
of running containers maintained in the {@link YarnAppState}.
The returned {@link ContainerHeartbeatResponse#isAlive()} is
<code> true </code> iff. the container Id exists in {@link YarnAppState#runningProcessors}.
samza-yarn/src/main/java/org/apache/samza/webapp/YarnContainerHeartbeatServlet.java