use of com.facebook.drift.client.DriftClientFactory 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();
}
}
use of com.facebook.drift.client.DriftClientFactory 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