org.apache.ratis.proto.RaftProtos.RoleInfoProto Java Examples

The following examples show how to use org.apache.ratis.proto.RaftProtos.RoleInfoProto. 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: ContainerStateMachine.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<TermIndex> notifyInstallSnapshotFromLeader(
    RoleInfoProto roleInfoProto, TermIndex firstTermIndexInLog) {
  ratisServer.handleInstallSnapshotFromLeader(gid, roleInfoProto,
      firstTermIndexInLog);
  final CompletableFuture<TermIndex> future = new CompletableFuture<>();
  future.complete(firstTermIndexInLog);
  return future;
}
 
Example #2
Source File: XceiverServerRatis.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
private void handlePipelineFailure(RaftGroupId groupId,
    RoleInfoProto roleInfoProto) {
  String msg;
  UUID datanode = RatisHelper.toDatanodeId(roleInfoProto.getSelf());
  RaftPeerId id = RaftPeerId.valueOf(roleInfoProto.getSelf().getId());
  switch (roleInfoProto.getRole()) {
  case CANDIDATE:
    msg = datanode + " is in candidate state for " +
        roleInfoProto.getCandidateInfo().getLastLeaderElapsedTimeMs() + "ms";
    break;
  case LEADER:
    StringBuilder sb = new StringBuilder();
    sb.append(datanode).append(" has not seen follower/s");
    for (RaftProtos.ServerRpcProto follower : roleInfoProto.getLeaderInfo()
        .getFollowerInfoList()) {
      if (follower.getLastRpcElapsedTimeMs() > nodeFailureTimeoutMs) {
        sb.append(" ").append(RatisHelper.toDatanodeId(follower.getId()))
            .append(" for ").append(follower.getLastRpcElapsedTimeMs())
            .append("ms");
      }
    }
    msg = sb.toString();
    break;
  default:
    LOG.error("unknown state: {}", roleInfoProto.getRole());
    throw new IllegalStateException("node" + id + " is in illegal role "
        + roleInfoProto.getRole());
  }

  triggerPipelineClose(groupId, msg,
      ClosePipelineInfo.Reason.PIPELINE_FAILED, false);
}
 
Example #3
Source File: OzoneManagerRatisServer.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
/**
 * Get the gorup info (peer role and leader peer id) from Ratis server and
 * update the OM server role.
 */
public void updateServerRole() {
  try {
    GroupInfoReply groupInfo = getGroupInfo();
    RoleInfoProto roleInfoProto = groupInfo.getRoleInfoProto();
    RaftPeerRole thisNodeRole = roleInfoProto.getRole();

    if (thisNodeRole.equals(RaftPeerRole.LEADER)) {
      setServerRole(thisNodeRole, raftPeerId);

    } else if (thisNodeRole.equals(RaftPeerRole.FOLLOWER)) {
      ByteString leaderNodeId = roleInfoProto.getFollowerInfo()
          .getLeaderInfo().getId().getId();
      // There may be a chance, here we get leaderNodeId as null. For
      // example, in 3 node OM Ratis, if 2 OM nodes are down, there will
      // be no leader.
      RaftPeerId leaderPeerId = null;
      if (leaderNodeId != null && !leaderNodeId.isEmpty()) {
        leaderPeerId = RaftPeerId.valueOf(leaderNodeId);
      }

      setServerRole(thisNodeRole, leaderPeerId);

    } else {
      setServerRole(thisNodeRole, null);

    }
  } catch (IOException e) {
    LOG.error("Failed to retrieve RaftPeerRole. Setting cached role to " +
        "{} and resetting leader info.", RaftPeerRole.UNRECOGNIZED, e);
    setServerRole(null, null);
  }
}
 
Example #4
Source File: GroupInfoReply.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
public GroupInfoReply(
        RaftClientRequest request, RoleInfoProto roleInfoProto,
        boolean isRaftStorageHealthy, Collection<CommitInfoProto> commitInfos, RaftGroup group) {
  super(request, commitInfos);
  this.roleInfoProto = roleInfoProto;
  this.isRaftStorageHealthy = isRaftStorageHealthy;
  this.group = group;
}
 
Example #5
Source File: GroupInfoReply.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("parameternumber")
public GroupInfoReply(
        ClientId clientId, RaftPeerId serverId, RaftGroupId groupId,
        long callId, boolean success, RoleInfoProto roleInfoProto,
        boolean isRaftStorageHealthy, Collection<CommitInfoProto> commitInfos, RaftGroup group) {
  super(clientId, serverId, groupId, callId, success, null, null, 0L, commitInfos);
  this.roleInfoProto = roleInfoProto;
  this.isRaftStorageHealthy = isRaftStorageHealthy;
  this.group = group;
}
 
Example #6
Source File: GroupInfoReply.java    From ratis with Apache License 2.0 5 votes vote down vote up
public GroupInfoReply(
        ClientId clientId, RaftPeerId serverId, RaftGroupId groupId,
        long callId, boolean success, RoleInfoProto roleInfoProto,
        boolean isRaftStorageHealthy, Collection<CommitInfoProto> commitInfos, RaftGroup group) {
  super(clientId, serverId, groupId, callId, success, null, null, 0L, commitInfos);
  this.roleInfoProto = roleInfoProto;
  this.isRaftStorageHealthy = isRaftStorageHealthy;
  this.group = group;
}
 
Example #7
Source File: GroupInfoReply.java    From ratis with Apache License 2.0 5 votes vote down vote up
public GroupInfoReply(
        RaftClientRequest request, RoleInfoProto roleInfoProto,
        boolean isRaftStorageHealthy, Collection<CommitInfoProto> commitInfos, RaftGroup group) {
  super(request, commitInfos);
  this.roleInfoProto = roleInfoProto;
  this.isRaftStorageHealthy = isRaftStorageHealthy;
  this.group = group;
}
 
Example #8
Source File: ContainerStateMachine.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
@Override
public void notifyExtendedNoLeader(RoleInfoProto roleInfoProto) {
  ratisServer.handleNoLeader(gid, roleInfoProto);
}
 
Example #9
Source File: SimpleStateMachine4Testing.java    From ratis with Apache License 2.0 4 votes vote down vote up
@Override
public void notifyExtendedNoLeader(RaftGroup group, RoleInfoProto roleInfoProto) {
  LOG.info("{}: notifyExtendedNoLeader {}, {}", this, group, roleInfoProto);
  leaderElectionTimeoutInfo = roleInfoProto;
}
 
Example #10
Source File: SimpleStateMachine4Testing.java    From ratis with Apache License 2.0 4 votes vote down vote up
@Override
public void notifySlowness(RaftGroup group, RoleInfoProto roleInfoProto) {
  LOG.info("{}: notifySlowness {}, {}", this, group, roleInfoProto);
  slownessInfo = roleInfoProto;
}
 
Example #11
Source File: SimpleStateMachine4Testing.java    From ratis with Apache License 2.0 4 votes vote down vote up
public RoleInfoProto getLeaderElectionTimeoutInfo() {
  return leaderElectionTimeoutInfo;
}
 
Example #12
Source File: SimpleStateMachine4Testing.java    From ratis with Apache License 2.0 4 votes vote down vote up
public RoleInfoProto getSlownessInfo() {
  return slownessInfo;
}
 
Example #13
Source File: GroupInfoReply.java    From ratis with Apache License 2.0 4 votes vote down vote up
public RoleInfoProto getRoleInfoProto() {
  return roleInfoProto;
}
 
Example #14
Source File: SimpleStateMachine4Testing.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
@Override
public void notifyExtendedNoLeader(RoleInfoProto roleInfoProto) {
  LOG.info("{}: notifyExtendedNoLeader {}, {}", this, groupId, roleInfoProto);
  leaderElectionTimeoutInfo = roleInfoProto;
}
 
Example #15
Source File: SimpleStateMachine4Testing.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
@Override
public void notifySlowness(RoleInfoProto roleInfoProto) {
  LOG.info("{}: notifySlowness {}, {}", this, groupId, roleInfoProto);
  slownessInfo = roleInfoProto;
}
 
Example #16
Source File: SimpleStateMachine4Testing.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
public RoleInfoProto getLeaderElectionTimeoutInfo() {
  return leaderElectionTimeoutInfo;
}
 
Example #17
Source File: SimpleStateMachine4Testing.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
public RoleInfoProto getSlownessInfo() {
  return slownessInfo;
}
 
Example #18
Source File: GroupInfoReply.java    From incubator-ratis with Apache License 2.0 4 votes vote down vote up
public RoleInfoProto getRoleInfoProto() {
  return roleInfoProto;
}
 
Example #19
Source File: XceiverServerRatis.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
void handleNoLeader(RaftGroupId groupId, RoleInfoProto roleInfoProto) {
  handlePipelineFailure(groupId, roleInfoProto);
}
 
Example #20
Source File: XceiverServerRatis.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
void handleNodeSlowness(RaftGroupId groupId, RoleInfoProto roleInfoProto) {
  handlePipelineFailure(groupId, roleInfoProto);
}
 
Example #21
Source File: ContainerStateMachine.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
@Override
public void notifySlowness(RoleInfoProto roleInfoProto) {
  ratisServer.handleNodeSlowness(gid, roleInfoProto);
}
 
Example #22
Source File: XceiverServerRatis.java    From hadoop-ozone with Apache License 2.0 3 votes vote down vote up
/**
 * The fact that the snapshot contents cannot be used to actually catch up
 * the follower, it is the reason to initiate close pipeline and
 * not install the snapshot. The follower will basically never be able to
 * catch up.
 *
 * @param groupId raft group information
 * @param roleInfoProto information about the current node role and
 *                      rpc delay information.
 * @param firstTermIndexInLog After the snapshot installation is complete,
 * return the last included term index in the snapshot.
 */
void handleInstallSnapshotFromLeader(RaftGroupId groupId,
                                     RoleInfoProto roleInfoProto,
                                     TermIndex firstTermIndexInLog) {
  LOG.warn("Install snapshot notification received from Leader with " +
      "termIndex: {}, terminating pipeline: {}",
      firstTermIndexInLog, groupId);
  handlePipelineFailure(groupId, roleInfoProto);
}
 
Example #23
Source File: StateMachine.java    From incubator-ratis with Apache License 2.0 2 votes vote down vote up
/**
 * Notify the Follower's state machine that the leader has purged entries
 * from its log and hence to catch up, the Follower state machine would have
 * to install the latest snapshot.
 * @param firstTermIndexInLog TermIndex of the first append entry available
 *                           in the Leader's log.
 * @param roleInfoProto information about the current node role and
 *                            rpc delay information
 * @return After the snapshot installation is complete, return the last
 * included term index in the snapshot.
 */
default CompletableFuture<TermIndex> notifyInstallSnapshotFromLeader(
    RoleInfoProto roleInfoProto, TermIndex firstTermIndexInLog) {
  return CompletableFuture.completedFuture(null);
}
 
Example #24
Source File: StateMachine.java    From incubator-ratis with Apache License 2.0 votes vote down vote up
/**
 * Notify the Leader's state machine that a leader has not been elected for a long time
 * this notification is based on "raft.server.leader.election.timeout"
 *
 * @param roleInfoProto information about the current node role and rpc delay information
 */
default void notifyExtendedNoLeader(RoleInfoProto roleInfoProto) {

}
 
Example #25
Source File: StateMachine.java    From incubator-ratis with Apache License 2.0 votes vote down vote up
/**
 * Notify the Leader's state machine that one of the followers is slow
 * this notification is based on "raft.server.rpc.slowness.timeout"
 *
 * @param roleInfoProto information about the current node role and rpc delay information
 */
default void notifySlowness(RoleInfoProto roleInfoProto) {

}
 
Example #26
Source File: StateMachine.java    From ratis with Apache License 2.0 votes vote down vote up
/**
 * Notify the Leader's state machine that one of the followers is slow
 * this notification is based on "raft.server.rpc.slowness.timeout"
 *
 * @param group raft group information
 * @param roleInfoProto information about the current node role and rpc delay information
 */
default void notifySlowness(RaftGroup group, RoleInfoProto roleInfoProto) {

}
 
Example #27
Source File: StateMachine.java    From ratis with Apache License 2.0 votes vote down vote up
/**
 * Notify the Leader's state machine that a leader has not been elected for a long time
 * this notification is based on "raft.server.leader.election.timeout"
 *
 * @param group raft group information
 * @param roleInfoProto information about the current node role and rpc delay information
 */
default void notifyExtendedNoLeader(RaftGroup group, RoleInfoProto roleInfoProto) {

}