try {
final SettableFuture<Object> future = SettableFuture.create();
TChannelBufferOutputTransport outTransport = new TChannelBufferOutputTransport();
TProtocol outProtocol = protocolFactory.getOutputProtocolFactory().getProtocol(outTransport);
writeArguments(outProtocol, sequenceId, args);
// send message and setup listener to handle the response
channel.sendAsynchronousRequest(outTransport.getOutputBuffer(), false, new NiftyClientChannel.Listener() {
@Override
public void onRequestSent() {}
@Override
public void onResponseReceived(ChannelBuffer message) {
try {
TTransport inputTransport = new TChannelBufferInputTransport(message);
TProtocol inputProtocol = protocolFactory.getInputProtocolFactory().getProtocol(inputTransport);
waitForResponse(inputProtocol, sequenceId);
Object results = readResponse(inputProtocol);
stats.addSuccessTime(nanosSince(start));
future.set(results);
} catch (Exception e) {