// Stop server
serverLifeCycleManager.stop();
}
private static void sendClientRequest(Injector clientInjector, int serverPort) throws InterruptedException, ExecutionException {
ThriftClientManager clientManager = clientInjector.getInstance(ThriftClientManager.class);
ThriftClient<HeaderUsageExampleClient> clientFactory = clientInjector.getInstance(Key.get(new TypeLiteral<ThriftClient<HeaderUsageExampleClient>>() {
}));
HeaderUsageExampleClient client = clientFactory.open(new HeaderClientConnector(HostAndPort.fromParts("localhost", serverPort))).get();
TProtocol outputProtocol = clientManager.getOutputProtocol(client);
TTransport outputTransport = outputProtocol.getTransport();
if (outputTransport instanceof THeaderTransport) {
LOG.info("adding headers to next client request");
THeaderTransport headerTransport = (THeaderTransport) outputTransport;
headerTransport.setHeader("header_from", "client");
}
else {
LOG.info("output transport for client was not THeaderTransport, client cannot send headers");
}
client.headerUsageExampleMethod();
TProtocol inputProtocol = clientManager.getInputProtocol(client);
TTransport inputTransport = inputProtocol.getTransport();
if (inputTransport instanceof THeaderTransport) {
LOG.info("headers received from the server in the response:");
THeaderTransport headerTransport = (THeaderTransport) outputTransport;
for (String key : headerTransport.getReadHeaders().keySet()) {