@PUT @Path("state") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) public Response updateState(NodeState state) throws WebApplicationException { requireNonNull(state, "state is null"); switch (state) { case SHUTTING_DOWN: shutdownHandler.requestShutdown(); return Response.ok().build(); case ACTIVE: case INACTIVE: throw new WebApplicationException(Response .status(BAD_REQUEST) .type(MediaType.TEXT_PLAIN) .entity(format("Invalid state transition to %s", state)) .build()); default: return Response.status(BAD_REQUEST) .type(TEXT_PLAIN) .entity(format("Invalid state %s", state)) .build(); } }
if (isShutdownRequested()) { return; setShutdownRequested(true); List<TaskInfo> activeTasks = getActiveTasks(); while (activeTasks.size() > 0) { CountDownLatch countDownLatch = new CountDownLatch(activeTasks.size()); activeTasks = getActiveTasks();
@GET @Path("state") @Produces(APPLICATION_JSON) public NodeState getServerState() { if (shutdownHandler.isShutdownRequested()) { return SHUTTING_DOWN; } else { return ACTIVE; } }
@GET @Path("state") @Produces(APPLICATION_JSON) public NodeState getServerState() { if (shutdownHandler.isShutdownRequested()) { return SHUTTING_DOWN; } else { return ACTIVE; } } }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testCoordinatorShutdown() throws Exception { try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) { TestingPrestoServer coordinator = queryRunner.getServers() .stream() .filter(TestingPrestoServer::isCoordinator) .findFirst() .get(); coordinator.getGracefulShutdownHandler().requestShutdown(); } } }
if (isShutdownRequested()) { return; setShutdownRequested(true); List<TaskInfo> activeTasks = getActiveTasks(); while (activeTasks.size() > 0) { CountDownLatch countDownLatch = new CountDownLatch(activeTasks.size()); activeTasks = getActiveTasks();
worker.getGracefulShutdownHandler().requestShutdown();
@PUT @Path("state") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) public Response updateState(NodeState state) throws WebApplicationException { switch (state) { case SHUTTING_DOWN: shutdownHandler.requestShutdown(); return Response.ok().build(); case ACTIVE: case INACTIVE: throw new WebApplicationException(Response .status(BAD_REQUEST) .type(MediaType.TEXT_PLAIN) .entity(format("Invalid state transition to %s", state)) .build()); default: return Response.status(BAD_REQUEST) .type(TEXT_PLAIN) .entity(format("Invalid state %s", state)) .build(); } }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testCoordinatorShutdown() throws Exception { try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) { TestingPrestoServer coordinator = queryRunner.getServers() .stream() .filter(TestingPrestoServer::isCoordinator) .findFirst() .get(); coordinator.getGracefulShutdownHandler().requestShutdown(); } } }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testCoordinatorShutdown() throws Exception { try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) { TestingPrestoServer coordinator = queryRunner.getServers() .stream() .filter(TestingPrestoServer::isCoordinator) .findFirst() .get(); coordinator.getGracefulShutdownHandler().requestShutdown(); } } }
worker.getGracefulShutdownHandler().requestShutdown();
worker.getGracefulShutdownHandler().requestShutdown();