Search in sources :

Example 1 with ServerInfoResource

use of com.facebook.presto.server.ServerInfoResource in project presto by prestodb.

the class TestServerInfoResource method testServerShutdown.

@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerShutdown() throws Exception {
    try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
        TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
        ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
        Response response = serverInfoResource.updateState(NodeState.SHUTTING_DOWN);
        assertEquals(response.getStatus(), 200);
        NodeState nodeState = serverInfoResource.getServerState();
        assertTrue(nodeState == NodeState.SHUTTING_DOWN);
    }
}
Also used : Response(javax.ws.rs.core.Response) NodeState(com.facebook.presto.spi.NodeState) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ServerInfoResource(com.facebook.presto.server.ServerInfoResource) Test(org.testng.annotations.Test)

Example 2 with ServerInfoResource

use of com.facebook.presto.server.ServerInfoResource in project presto by prestodb.

the class TestServerInfoResource method testServerShutdownFollowedByActive.

@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerShutdownFollowedByActive() throws Exception {
    try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
        TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
        ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
        serverInfoResource.updateState(NodeState.SHUTTING_DOWN);
        Response response = serverInfoResource.updateState(NodeState.ACTIVE);
        assertEquals(response.getStatus(), BAD_REQUEST.getStatusCode());
        assertEquals(response.getEntity(), "Cluster is shutting down");
    }
}
Also used : Response(javax.ws.rs.core.Response) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ServerInfoResource(com.facebook.presto.server.ServerInfoResource) Test(org.testng.annotations.Test)

Example 3 with ServerInfoResource

use of com.facebook.presto.server.ServerInfoResource in project presto by prestodb.

the class TestServerInfoResource method testServerShutdownFollowedByInactive.

@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerShutdownFollowedByInactive() throws Exception {
    try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
        TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
        ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
        serverInfoResource.updateState(NodeState.SHUTTING_DOWN);
        Response response = serverInfoResource.updateState(NodeState.INACTIVE);
        assertEquals(response.getStatus(), BAD_REQUEST.getStatusCode());
        assertEquals(response.getEntity(), "Cluster is shutting down");
    }
}
Also used : Response(javax.ws.rs.core.Response) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ServerInfoResource(com.facebook.presto.server.ServerInfoResource) Test(org.testng.annotations.Test)

Example 4 with ServerInfoResource

use of com.facebook.presto.server.ServerInfoResource in project presto by prestodb.

the class TestServerInfoResource method testServerInactiveThenActive.

@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerInactiveThenActive() throws Exception {
    try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
        TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
        ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
        Response response = serverInfoResource.updateState(NodeState.INACTIVE);
        assertEquals(response.getStatus(), 200);
        NodeState nodeState = serverInfoResource.getServerState();
        assertTrue(nodeState == NodeState.INACTIVE);
        response = serverInfoResource.updateState(NodeState.ACTIVE);
        assertEquals(response.getStatus(), 200);
        nodeState = serverInfoResource.getServerState();
        assertTrue(nodeState == NodeState.ACTIVE);
    }
}
Also used : Response(javax.ws.rs.core.Response) NodeState(com.facebook.presto.spi.NodeState) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ServerInfoResource(com.facebook.presto.server.ServerInfoResource) Test(org.testng.annotations.Test)

Example 5 with ServerInfoResource

use of com.facebook.presto.server.ServerInfoResource in project presto by prestodb.

the class TestServerInfoResource method testServerActive.

@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerActive() throws Exception {
    try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
        TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
        ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
        NodeState nodeState = serverInfoResource.getServerState();
        assertTrue(nodeState == NodeState.ACTIVE);
    }
}
Also used : NodeState(com.facebook.presto.spi.NodeState) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ServerInfoResource(com.facebook.presto.server.ServerInfoResource) Test(org.testng.annotations.Test)

Aggregations

ServerInfoResource (com.facebook.presto.server.ServerInfoResource)5 TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)5 Test (org.testng.annotations.Test)5 Response (javax.ws.rs.core.Response)4 NodeState (com.facebook.presto.spi.NodeState)3