Java Code Examples for org.apache.ratis.protocol.RaftClientRequest#getClientId()

The following examples show how to use org.apache.ratis.protocol.RaftClientRequest#getClientId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamRequests.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
CompletableFuture<?> streamAsync(RaftClientRequest request) {
  final StreamRequestTypeProto stream = request.getType().getStream();
  Preconditions.assertTrue(!stream.getEndOfRequest());
  final Key key = new Key(request.getClientId(), stream.getStreamId());
  final PendingStream pending = streams.computeIfAbsent(key);
  return pending.append(stream.getMessageId(), request.getMessage());
}
 
Example 2
Source File: StreamRequests.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
CompletableFuture<ByteString> streamEndOfRequestAsync(RaftClientRequest request) {
  final StreamRequestTypeProto stream = request.getType().getStream();
  Preconditions.assertTrue(stream.getEndOfRequest());
  final Key key = new Key(request.getClientId(), stream.getStreamId());

  final PendingStream pending = streams.remove(key);
  if (pending == null) {
    return JavaUtils.completeExceptionally(new StreamException(name + ": " + key + " not found"));
  }
  return pending.getBytes(stream.getMessageId(), request.getMessage());
}