Skip to content

Commit

Permalink
factor out requestId()
Browse files Browse the repository at this point in the history
  • Loading branch information
squito committed Jun 14, 2018
1 parent 8a18da5 commit 1a222aa
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public long sendRpc(ByteBuffer message, RpcResponseCallback callback) {
logger.trace("Sending RPC to {}", getRemoteAddress(channel));
}

long requestId = Math.abs(UUID.randomUUID().getLeastSignificantBits());
long requestId = requestId();
handler.addRpcRequest(requestId, callback);

channel.writeAndFlush(new RpcRequest(requestId, new NioManagedBuffer(message)))
Expand Down Expand Up @@ -221,7 +221,7 @@ public long uploadStream(
logger.trace("Sending RPC to {}", getRemoteAddress(channel));
}

long requestId = Math.abs(UUID.randomUUID().getLeastSignificantBits());
long requestId = requestId();
handler.addRpcRequest(requestId, callback);

channel.writeAndFlush(new UploadStream(requestId, meta, data))
Expand Down Expand Up @@ -264,6 +264,10 @@ public void operationComplete(Future future) throws Exception {
void handleFailure(String errorMsg, Throwable cause) throws Exception {}
}

private static long requestId() {
return Math.abs(UUID.randomUUID().getLeastSignificantBits());
}

private class RpcChannelListener extends StdChannelListener {
final long rpcRequestId;
final RpcResponseCallback callback;
Expand Down

0 comments on commit 1a222aa

Please sign in to comment.