io.atomix.protocols.raft.protocol.HeartbeatResponse Java Examples

The following examples show how to use io.atomix.protocols.raft.protocol.HeartbeatResponse. 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: RaftSessionManager.java    From atomix with Apache License 2.0 5 votes vote down vote up
/**
 * Handles a heartbeat request.
 */
private CompletableFuture<HeartbeatResponse> handleHeartbeat(HeartbeatRequest request) {
  log.trace("Received {}", request);
  boolean newLeader = !Objects.equals(selectorManager.leader(), request.leader());
  selectorManager.resetAll(request.leader(), request.members());
  HeartbeatResponse response = HeartbeatResponse.builder()
      .withStatus(RaftResponse.Status.OK)
      .build();
  if (newLeader) {
    resetAllIndexes();
  }
  log.trace("Sending {}", response);
  return CompletableFuture.completedFuture(response);
}
 
Example #2
Source File: RaftClientMessagingProtocol.java    From submarine with Apache License 2.0 4 votes vote down vote up
@Override
public void registerHeartbeatHandler(Function<HeartbeatRequest,
    CompletableFuture<HeartbeatResponse>> handler) {
  registerHandler("heartbeat", handler);
}
 
Example #3
Source File: LocalRaftClientProtocol.java    From submarine with Apache License 2.0 4 votes vote down vote up
@Override
public void registerHeartbeatHandler(Function<HeartbeatRequest,
    CompletableFuture<HeartbeatResponse>> handler) {
  this.heartbeatHandler = handler;
}
 
Example #4
Source File: RaftServerMessagingProtocol.java    From submarine with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<HeartbeatResponse> heartbeat(MemberId memberId,
                                                      HeartbeatRequest request) {
  return sendAndReceive(memberId, "heartbeat", request);
}
 
Example #5
Source File: LocalRaftServerProtocol.java    From submarine with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<HeartbeatResponse> heartbeat(MemberId memberId,
                                                      HeartbeatRequest request) {
  return getClient(memberId).thenCompose(protocol ->
      protocol.heartbeat(encode(request))).thenApply(this::decode);
}
 
Example #6
Source File: RaftClientMessagingProtocol.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
@Override
public void registerHeartbeatHandler(Function<HeartbeatRequest,
    CompletableFuture<HeartbeatResponse>> handler) {
  registerHandler("heartbeat", handler);
}
 
Example #7
Source File: LocalRaftClientProtocol.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
@Override
public void registerHeartbeatHandler(Function<HeartbeatRequest,
    CompletableFuture<HeartbeatResponse>> handler) {
  this.heartbeatHandler = handler;
}
 
Example #8
Source File: RaftServerMessagingProtocol.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<HeartbeatResponse> heartbeat(MemberId memberId,
                                                      HeartbeatRequest request) {
  return sendAndReceive(memberId, "heartbeat", request);
}
 
Example #9
Source File: LocalRaftServerProtocol.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<HeartbeatResponse> heartbeat(MemberId memberId,
                                                      HeartbeatRequest request) {
  return getClient(memberId).thenCompose(protocol ->
      protocol.heartbeat(encode(request))).thenApply(this::decode);
}
 
Example #10
Source File: RaftServerCommunicator.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<HeartbeatResponse> heartbeat(MemberId memberId, HeartbeatRequest request) {
  return sendAndReceive(context.heartbeatSubject, request, memberId);
}
 
Example #11
Source File: RaftClientCommunicator.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public void registerHeartbeatHandler(Function<HeartbeatRequest, CompletableFuture<HeartbeatResponse>> handler) {
  clusterCommunicator.subscribe(context.heartbeatSubject, serializer::decode, handler, serializer::encode);
}
 
Example #12
Source File: RaftClientMessagingProtocol.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public void registerHeartbeatHandler(Function<HeartbeatRequest, CompletableFuture<HeartbeatResponse>> handler) {
  registerHandler("heartbeat", handler);
}
 
Example #13
Source File: LocalRaftClientProtocol.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public void registerHeartbeatHandler(Function<HeartbeatRequest, CompletableFuture<HeartbeatResponse>> handler) {
  this.heartbeatHandler = handler;
}
 
Example #14
Source File: RaftServerMessagingProtocol.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<HeartbeatResponse> heartbeat(MemberId memberId, HeartbeatRequest request) {
  return sendAndReceive(memberId, "heartbeat", request);
}
 
Example #15
Source File: LocalRaftServerProtocol.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<HeartbeatResponse> heartbeat(MemberId memberId, HeartbeatRequest request) {
  return getClient(memberId).thenCompose(protocol -> protocol.heartbeat(encode(request))).thenApply(this::decode);
}