Search in sources :

Example 1 with SimpleAddressSelector

use of com.facebook.drift.client.address.SimpleAddressSelector in project presto by prestodb.

the class TestThriftServerInfoIntegration method testServer.

@Test
public void testServer() {
    AddressSelector<SimpleAddressSelector.SimpleAddress> addressSelector = new SimpleAddressSelector(ImmutableSet.of(HostAndPort.fromParts("localhost", thriftServerPort)), true);
    try (DriftNettyMethodInvokerFactory<?> invokerFactory = createStaticDriftNettyMethodInvokerFactory(new DriftNettyClientConfig())) {
        DriftClientFactory clientFactory = new DriftClientFactory(new ThriftCodecManager(), invokerFactory, addressSelector, NORMAL_RESULT);
        ThriftServerInfoClient client = clientFactory.createDriftClient(ThriftServerInfoClient.class).get();
        // get buffer result
        NodeState state = NodeState.valueOf(client.getServerState().get());
        assertEquals(state, ACTIVE);
    } catch (Exception e) {
        fail();
    }
}
Also used : NodeState(com.facebook.presto.spi.NodeState) ThriftServerInfoClient(com.facebook.presto.server.thrift.ThriftServerInfoClient) SimpleAddressSelector(com.facebook.drift.client.address.SimpleAddressSelector) DriftNettyClientConfig(com.facebook.drift.transport.netty.client.DriftNettyClientConfig) DriftClientFactory(com.facebook.drift.client.DriftClientFactory) ThriftCodecManager(com.facebook.drift.codec.ThriftCodecManager) Test(org.testng.annotations.Test)

Example 2 with SimpleAddressSelector

use of com.facebook.drift.client.address.SimpleAddressSelector in project presto by prestodb.

the class TestThriftTaskIntegration method testServer.

@Test
public void testServer() {
    AddressSelector<SimpleAddressSelector.SimpleAddress> addressSelector = new SimpleAddressSelector(ImmutableSet.of(HostAndPort.fromParts("localhost", thriftServerPort)), true);
    try (DriftNettyMethodInvokerFactory<?> invokerFactory = createStaticDriftNettyMethodInvokerFactory(new DriftNettyClientConfig())) {
        DriftClientFactory clientFactory = new DriftClientFactory(new ThriftCodecManager(), invokerFactory, addressSelector, NORMAL_RESULT);
        ThriftTaskClient client = clientFactory.createDriftClient(ThriftTaskClient.class).get();
        // get buffer result
        ListenableFuture<ThriftBufferResult> result = client.getResults(TaskId.valueOf("queryid.0.0.0"), new OutputBufferId(1), 0, 100);
        assertTrue(result.get().isBufferComplete());
        assertTrue(result.get().getSerializedPages().isEmpty());
        assertEquals(result.get().getToken(), 1);
        assertEquals(result.get().getTaskInstanceId(), "test");
        // ack buffer result
        // sync
        client.acknowledgeResults(TaskId.valueOf("queryid.0.0.0"), new OutputBufferId(1), 42).get();
        // fire and forget
        client.acknowledgeResults(TaskId.valueOf("queryid.0.0.0"), new OutputBufferId(1), 42);
        // abort buffer result
        client.abortResults(TaskId.valueOf("queryid.0.0.0"), new OutputBufferId(1)).get();
    } catch (Exception e) {
        fail();
    }
}
Also used : ThriftTaskClient(com.facebook.presto.server.thrift.ThriftTaskClient) SimpleAddressSelector(com.facebook.drift.client.address.SimpleAddressSelector) OutputBufferId(com.facebook.presto.execution.buffer.OutputBuffers.OutputBufferId) DriftNettyClientConfig(com.facebook.drift.transport.netty.client.DriftNettyClientConfig) ThriftBufferResult(com.facebook.presto.execution.buffer.ThriftBufferResult) DriftClientFactory(com.facebook.drift.client.DriftClientFactory) ThriftCodecManager(com.facebook.drift.codec.ThriftCodecManager) Test(org.testng.annotations.Test)

Aggregations

DriftClientFactory (com.facebook.drift.client.DriftClientFactory)2 SimpleAddressSelector (com.facebook.drift.client.address.SimpleAddressSelector)2 ThriftCodecManager (com.facebook.drift.codec.ThriftCodecManager)2 DriftNettyClientConfig (com.facebook.drift.transport.netty.client.DriftNettyClientConfig)2 Test (org.testng.annotations.Test)2 OutputBufferId (com.facebook.presto.execution.buffer.OutputBuffers.OutputBufferId)1 ThriftBufferResult (com.facebook.presto.execution.buffer.ThriftBufferResult)1 ThriftServerInfoClient (com.facebook.presto.server.thrift.ThriftServerInfoClient)1 ThriftTaskClient (com.facebook.presto.server.thrift.ThriftTaskClient)1 NodeState (com.facebook.presto.spi.NodeState)1