Java源码示例:io.atomix.protocols.raft.protocol.JoinResponse
示例1
@Override
public CompletableFuture<JoinResponse> onJoin(JoinRequest request) {
raft.checkThread();
logRequest(request);
if (raft.getLeader() == null) {
return CompletableFuture.completedFuture(logResponse(JoinResponse.builder()
.withStatus(RaftResponse.Status.ERROR)
.withError(RaftError.Type.NO_LEADER)
.build()));
} else {
return forward(request, raft.getProtocol()::join)
.exceptionally(error -> JoinResponse.builder()
.withStatus(RaftResponse.Status.ERROR)
.withError(RaftError.Type.NO_LEADER)
.build())
.thenApply(this::logResponse);
}
}
示例2
@Override
public CompletableFuture<JoinResponse> onJoin(JoinRequest request) {
logRequest(request);
return Futures.completedFuture(logResponse(JoinResponse.builder()
.withStatus(Status.ERROR)
.withError(RaftError.Type.UNAVAILABLE)
.build()));
}
示例3
@Override
public CompletableFuture<JoinResponse> join(MemberId memberId, JoinRequest request) {
return sendAndReceive(memberId, "join", request);
}
示例4
@Override
public void registerJoinHandler(Function<JoinRequest,
CompletableFuture<JoinResponse>> handler) {
registerHandler("join", handler);
}
示例5
@Override
public CompletableFuture<JoinResponse> join(MemberId memberId, JoinRequest request) {
return getServer(memberId).thenCompose(listener ->
listener.join(encode(request))).thenApply(this::decode);
}
示例6
@Override
public void registerJoinHandler(Function<JoinRequest,
CompletableFuture<JoinResponse>> handler) {
this.joinHandler = handler;
}
示例7
@Override
public CompletableFuture<JoinResponse> join(MemberId memberId, JoinRequest request) {
return sendAndReceive(memberId, "join", request);
}
示例8
@Override
public void registerJoinHandler(Function<JoinRequest,
CompletableFuture<JoinResponse>> handler) {
registerHandler("join", handler);
}
示例9
@Override
public CompletableFuture<JoinResponse> join(MemberId memberId, JoinRequest request) {
return getServer(memberId).thenCompose(listener ->
listener.join(encode(request))).thenApply(this::decode);
}
示例10
@Override
public void registerJoinHandler(Function<JoinRequest,
CompletableFuture<JoinResponse>> handler) {
this.joinHandler = handler;
}
示例11
@Override
public CompletableFuture<JoinResponse> join(MemberId memberId, JoinRequest request) {
return sendAndReceive(context.joinSubject, request, memberId);
}
示例12
@Override
public void registerJoinHandler(Function<JoinRequest, CompletableFuture<JoinResponse>> handler) {
clusterCommunicator.subscribe(context.joinSubject, serializer::decode, handler, serializer::encode);
}
示例13
@Override
public CompletableFuture<JoinResponse> join(MemberId memberId, JoinRequest request) {
return sendAndReceive(memberId, "join", request);
}
示例14
@Override
public void registerJoinHandler(Function<JoinRequest, CompletableFuture<JoinResponse>> handler) {
registerHandler("join", handler);
}
示例15
@Override
public CompletableFuture<JoinResponse> join(MemberId memberId, JoinRequest request) {
return getServer(memberId).thenCompose(listener -> listener.join(encode(request))).thenApply(this::decode);
}
示例16
@Override
public void registerJoinHandler(Function<JoinRequest, CompletableFuture<JoinResponse>> handler) {
this.joinHandler = handler;
}
示例17
/**
* Handles a join request.
*
* @param request The request to handle.
* @return A completable future to be completed with the request response.
*/
CompletableFuture<JoinResponse> onJoin(JoinRequest request);