use of org.apache.samza.job.yarn.YarnContainer in project samza by apache.
the class YarnContainerHeartbeatServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
ContainerId yarnContainerId;
PrintWriter printWriter = resp.getWriter();
String containerIdParam = req.getParameter(YARN_CONTAINER_ID);
ContainerHeartbeatResponse response;
resp.setContentType(APPLICATION_JSON);
boolean alive = false;
try {
yarnContainerId = ContainerId.fromString(containerIdParam);
for (YarnContainer yarnContainer : yarnAppState.runningYarnContainers.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());
}
}
Aggregations