/** * Deregisters the host from the cluster. Will delete just about everything the cluster knows * about it. * * @param host The host to deregister. * * @return The response. */ @DELETE @Path("{id}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public HostDeregisterResponse delete(@PathParam("id") final String host) { try { model.deregisterHost(host); return new HostDeregisterResponse(HostDeregisterResponse.Status.OK, host); } catch (HostNotFoundException e) { throw notFound(new HostDeregisterResponse(HostDeregisterResponse.Status.NOT_FOUND, host)); } catch (HostStillInUseException e) { throw badRequest(new HostDeregisterResponse(HostDeregisterResponse.Status.JOBS_STILL_DEPLOYED, host)); } }
@Override void processItem(final String agent) { try { if (masterModel.isHostUp(agent)) { // Host UP -- nothing to do return; } final AgentInfo agentInfo = masterModel.getAgentInfo(agent); if (agentInfo == null) { return; } final long downSince = agentInfo.getStartTime() + agentInfo.getUptime(); final long downDurationMillis = clock.now().getMillis() - downSince; if (downDurationMillis >= timeoutMillis) { try { log.info("Reaping dead agent '{}' (DOWN for {} hours)", agent, DurationFormatUtils.formatDurationHMS(downDurationMillis)); masterModel.deregisterHost(agent); } catch (Exception e) { log.warn("Failed to reap agent '{}'", agent, e); } } } catch (Exception e) { log.warn("Failed to determine if agent '{}' should be reaped", agent, e); } } }
/** * Deregisters the host from the cluster. Will delete just about everything the cluster knows * about it. * @param host The host to deregister. * @return The response. */ @DELETE @Path("{id}") @Produces(APPLICATION_JSON) @Timed @ExceptionMetered public HostDeregisterResponse delete(@PathParam("id") final String host) { try { model.deregisterHost(host); return new HostDeregisterResponse(HostDeregisterResponse.Status.OK, host); } catch (HostNotFoundException e) { throw notFound(new HostDeregisterResponse(HostDeregisterResponse.Status.NOT_FOUND, host)); } catch (HostStillInUseException e) { throw badRequest(new HostDeregisterResponse(HostDeregisterResponse.Status.JOBS_STILL_DEPLOYED, host)); } }