Search in sources :

Example 1 with ThriftBufferResult

use of com.facebook.presto.execution.buffer.ThriftBufferResult in project presto by prestodb.

the class ThriftTaskService method getResults.

@ThriftMethod
public ListenableFuture<ThriftBufferResult> getResults(TaskId taskId, OutputBufferId bufferId, long token, long maxSizeInBytes) {
    requireNonNull(taskId, "taskId is null");
    requireNonNull(bufferId, "bufferId is null");
    ListenableFuture<BufferResult> bufferResultFuture = taskManager.getTaskResults(taskId, bufferId, token, new DataSize(maxSizeInBytes, BYTE));
    Duration waitTime = randomizeWaitTime(DEFAULT_MAX_WAIT_TIME);
    bufferResultFuture = addTimeout(bufferResultFuture, () -> BufferResult.emptyResults(taskManager.getTaskInstanceId(taskId), token, false), waitTime, timeoutExecutor);
    return Futures.transform(bufferResultFuture, ThriftBufferResult::fromBufferResult, directExecutor());
}
Also used : ThriftBufferResult(com.facebook.presto.execution.buffer.ThriftBufferResult) BufferResult(com.facebook.presto.execution.buffer.BufferResult) DataSize(io.airlift.units.DataSize) Duration(io.airlift.units.Duration) ThriftBufferResult(com.facebook.presto.execution.buffer.ThriftBufferResult) ThriftMethod(com.facebook.drift.annotations.ThriftMethod)

Example 2 with ThriftBufferResult

use of com.facebook.presto.execution.buffer.ThriftBufferResult 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

ThriftBufferResult (com.facebook.presto.execution.buffer.ThriftBufferResult)2 ThriftMethod (com.facebook.drift.annotations.ThriftMethod)1 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 BufferResult (com.facebook.presto.execution.buffer.BufferResult)1 OutputBufferId (com.facebook.presto.execution.buffer.OutputBuffers.OutputBufferId)1 ThriftTaskClient (com.facebook.presto.server.thrift.ThriftTaskClient)1 DataSize (io.airlift.units.DataSize)1 Duration (io.airlift.units.Duration)1 Test (org.testng.annotations.Test)1