Search in sources :

Example 1 with ThriftTaskClient

use of com.facebook.presto.server.thrift.ThriftTaskClient 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)1 SimpleAddressSelector (com.facebook.drift.client.address.SimpleAddressSelector)1 ThriftCodecManager (com.facebook.drift.codec.ThriftCodecManager)1 DriftNettyClientConfig (com.facebook.drift.transport.netty.client.DriftNettyClientConfig)1 OutputBufferId (com.facebook.presto.execution.buffer.OutputBuffers.OutputBufferId)1 ThriftBufferResult (com.facebook.presto.execution.buffer.ThriftBufferResult)1 ThriftTaskClient (com.facebook.presto.server.thrift.ThriftTaskClient)1 Test (org.testng.annotations.Test)1