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());
}
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();
}
}
Aggregations