Java Code Examples for org.apache.ratis.protocol.RaftClientRequest#Type
The following examples show how to use
org.apache.ratis.protocol.RaftClientRequest#Type .
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: OrderedAsync.java From incubator-ratis with Apache License 2.0 | 6 votes |
CompletableFuture<RaftClientReply> send(RaftClientRequest.Type type, Message message, RaftPeerId server) { if (!type.is(TypeCase.WATCH) && !type.is(TypeCase.STREAM)) { Objects.requireNonNull(message, "message == null"); } try { requestSemaphore.acquire(); } catch (InterruptedException e) { return JavaUtils.completeExceptionally(IOUtils.toInterruptedIOException( "Interrupted when sending " + type + ", message=" + message, e)); } final long callId = RaftClientImpl.nextCallId(); final LongFunction<PendingOrderedRequest> constructor = seqNum -> new PendingOrderedRequest(callId, seqNum, slidingWindowEntry -> client.newRaftClientRequest(server, callId, message, type, slidingWindowEntry)); return getSlidingWindow(server).submitNewRequest(constructor, this::sendRequestWithRetry ).getReplyFuture( ).thenApply(reply -> RaftClientImpl.handleRaftException(reply, CompletionException::new) ).whenComplete((r, e) -> requestSemaphore.release()); }
Example 2
Source File: XceiverServerRatis.java From hadoop-ozone with Apache License 2.0 | 5 votes |
private RaftClientRequest createRaftClientRequest( ContainerCommandRequestProto request, HddsProtos.PipelineID pipelineID, RaftClientRequest.Type type) { return new RaftClientRequest(clientId, server.getId(), RaftGroupId.valueOf(PipelineID.getFromProtobuf(pipelineID).getId()), nextCallId(), ContainerCommandRequestMessage.toMessage(request, null), type, null); }
Example 3
Source File: UnorderedAsync.java From incubator-ratis with Apache License 2.0 | 5 votes |
static CompletableFuture<RaftClientReply> send(RaftClientRequest.Type type, RaftClientImpl client) { final long callId = RaftClientImpl.nextCallId(); final PendingClientRequest pending = new PendingUnorderedRequest( () -> client.newRaftClientRequest(null, callId, null, type, null)); sendRequestWithRetry(pending, client); return pending.getReplyFuture() .thenApply(reply -> RaftClientImpl.handleRaftException(reply, CompletionException::new)); }
Example 4
Source File: TestRetryPolicy.java From incubator-ratis with Apache License 2.0 | 4 votes |
private static RaftClientRequest newRaftClientRequest(RaftClientRequest.Type type) { return new RaftClientRequest(ClientId.randomId(), RaftPeerId.valueOf("s0"), RaftGroupId.randomId(), 1L, type); }
Example 5
Source File: RaftClientTestUtil.java From incubator-ratis with Apache License 2.0 | 4 votes |
static RaftClientRequest newRaftClientRequest(RaftClient client, RaftPeerId server, long callId, Message message, RaftClientRequest.Type type, SlidingWindowEntry slidingWindowEntry) { return ((RaftClientImpl)client).newRaftClientRequest(server, callId, message, type, slidingWindowEntry); }