Search in sources :

Example 1 with MessageStreamRequestTypeProto

use of org.apache.ratis.proto.RaftProtos.MessageStreamRequestTypeProto in project incubator-ratis by apache.

the class MessageStreamRequests method streamEndOfRequestAsync.

CompletableFuture<ByteString> streamEndOfRequestAsync(RaftClientRequest request) {
    final MessageStreamRequestTypeProto stream = request.getType().getMessageStream();
    Preconditions.assertTrue(stream.getEndOfRequest());
    final ClientInvocationId key = ClientInvocationId.valueOf(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());
}
Also used : MessageStreamRequestTypeProto(org.apache.ratis.proto.RaftProtos.MessageStreamRequestTypeProto) ClientInvocationId(org.apache.ratis.protocol.ClientInvocationId) StreamException(org.apache.ratis.protocol.exceptions.StreamException)

Example 2 with MessageStreamRequestTypeProto

use of org.apache.ratis.proto.RaftProtos.MessageStreamRequestTypeProto in project incubator-ratis by apache.

the class MessageStreamRequests method streamAsync.

CompletableFuture<?> streamAsync(RaftClientRequest request) {
    final MessageStreamRequestTypeProto stream = request.getType().getMessageStream();
    Preconditions.assertTrue(!stream.getEndOfRequest());
    final ClientInvocationId key = ClientInvocationId.valueOf(request.getClientId(), stream.getStreamId());
    final PendingStream pending = streams.computeIfAbsent(key);
    return pending.append(stream.getMessageId(), request.getMessage());
}
Also used : MessageStreamRequestTypeProto(org.apache.ratis.proto.RaftProtos.MessageStreamRequestTypeProto) ClientInvocationId(org.apache.ratis.protocol.ClientInvocationId)

Aggregations

MessageStreamRequestTypeProto (org.apache.ratis.proto.RaftProtos.MessageStreamRequestTypeProto)2 ClientInvocationId (org.apache.ratis.protocol.ClientInvocationId)2 StreamException (org.apache.ratis.protocol.exceptions.StreamException)1