@Override protected Void execute(StopContainerCmd command) { WebTarget webResource = getBaseResource() .path("/containers/{id}/stop") .resolveTemplate("id", command.getContainerId()) .queryParam("t", String.valueOf(command.getTimeout())); LOGGER.trace("POST: {}", webResource); webResource.request().accept(MediaType.APPLICATION_JSON).post(null).close(); return null; }
@Override public void stopContainer(InstanceStopRequest request, InstanceStopResponse response) { logger.info(String.format("begin stopContainer: %s", request)); try { // 1. create cmd StopContainerCmd stopContainerCmd = dockerClient.stopContainerCmd(request.getContainerId()); // 2. invoke post processors before stopContainer container // 3. exec cmd stopContainerCmd.exec(); // 4. invoke post processors after stopContainer container response.success(); } catch (Exception e) { response.fail(e.toString()); logger.error(String.format("stopContainer error: %s", request), e); } logger.info(String.format("end stopContainer: %s", response)); }