use of org.apache.ratis.proto.netty.NettyProtos.RaftNettyServerReplyProto in project incubator-ratis by apache.
the class NettyRpcProxy method send.
public RaftNettyServerReplyProto send(RaftRpcRequestProto request, RaftNettyServerRequestProto proto) throws IOException {
final CompletableFuture<RaftNettyServerReplyProto> reply = new CompletableFuture<>();
final ChannelFuture channelFuture = connection.offer(proto, reply);
try {
channelFuture.sync();
TimeDuration newDuration = requestTimeoutDuration.add(request.getTimeoutMs(), TimeUnit.MILLISECONDS);
return reply.get(newDuration.getDuration(), newDuration.getUnit());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw IOUtils.toInterruptedIOException(ProtoUtils.toString(request) + " sending from " + peer + " is interrupted.", e);
} catch (ExecutionException e) {
throw IOUtils.toIOException(e);
} catch (TimeoutException e) {
throw new TimeoutIOException(e.getMessage(), e);
}
}
Aggregations