org.apache.ratis.protocol.GroupInfoReply Java Examples
The following examples show how to use
org.apache.ratis.protocol.GroupInfoReply.
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: TestRatisPipelineLeader.java From hadoop-ozone with Apache License 2.0 | 6 votes |
private boolean verifyLeaderInfo(Pipeline ratisPipeline) throws Exception { Optional<HddsDatanodeService> hddsDatanodeService = cluster.getHddsDatanodes().stream().filter(s -> s.getDatanodeStateMachine().getDatanodeDetails().getUuid() .equals(ratisPipeline.getLeaderId())).findFirst(); Assert.assertTrue(hddsDatanodeService.isPresent()); XceiverServerRatis serverRatis = (XceiverServerRatis) hddsDatanodeService.get() .getDatanodeStateMachine().getContainer().getWriteChannel(); GroupInfoRequest groupInfoRequest = new GroupInfoRequest( ClientId.randomId(), serverRatis.getServer().getId(), RaftGroupId.valueOf(ratisPipeline.getId().getId()), 100); GroupInfoReply reply = serverRatis.getServer().getGroupInfo(groupInfoRequest); return reply.getRoleInfoProto().hasLeaderInfo() && ratisPipeline.getLeaderId().toString().equals( reply.getRoleInfoProto().getSelf().getId().toStringUtf8()); }
Example #2
Source File: XceiverServerRatis.java From hadoop-ozone with Apache License 2.0 | 5 votes |
public long getMinReplicatedIndex(PipelineID pipelineID) throws IOException { Long minIndex; GroupInfoReply reply = getServer() .getGroupInfo(createGroupInfoRequest(pipelineID.getProtobuf())); minIndex = RatisHelper.getMinReplicatedIndex(reply.getCommitInfos()); return minIndex == null ? -1 : minIndex.longValue(); }
Example #3
Source File: OzoneManagerRatisServer.java From hadoop-ozone with Apache License 2.0 | 5 votes |
/** * 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: CombinedClientProtocolClientSideTranslatorPB.java From incubator-ratis with Apache License 2.0 | 5 votes |
@Override public GroupInfoReply getGroupInfo(GroupInfoRequest request) throws IOException { return handleRequest(request, ClientProtoUtils::toGroupInfoRequestProto, ClientProtoUtils::toGroupInfoReply, p -> getProtocol().groupInfo(null, p)); }
Example #5
Source File: CombinedClientProtocolClientSideTranslatorPB.java From ratis with Apache License 2.0 | 5 votes |
@Override public GroupInfoReply getGroupInfo(GroupInfoRequest request) throws IOException { return handleRequest(request, ClientProtoUtils::toGroupInfoRequestProto, ClientProtoUtils::toGroupInfoReply, p -> getProtocol().groupInfo(null, p)); }
Example #6
Source File: OzoneManagerRatisServer.java From hadoop-ozone with Apache License 2.0 | 4 votes |
private GroupInfoReply getGroupInfo() throws IOException { GroupInfoRequest groupInfoRequest = new GroupInfoRequest(clientId, raftPeerId, raftGroupId, nextCallId()); GroupInfoReply groupInfo = server.getGroupInfo(groupInfoRequest); return groupInfo; }
Example #7
Source File: NettyRpcService.java From incubator-ratis with Apache License 2.0 | 4 votes |
RaftNettyServerReplyProto handle(RaftNettyServerRequestProto proto) { RaftRpcRequestProto rpcRequest = null; try { switch (proto.getRaftNettyServerRequestCase()) { case REQUESTVOTEREQUEST: final RequestVoteRequestProto request = proto.getRequestVoteRequest(); rpcRequest = request.getServerRequest(); final RequestVoteReplyProto reply = server.requestVote(request); return RaftNettyServerReplyProto.newBuilder() .setRequestVoteReply(reply) .build(); case APPENDENTRIESREQUEST: final AppendEntriesRequestProto appendEntriesRequest = proto.getAppendEntriesRequest(); rpcRequest = appendEntriesRequest.getServerRequest(); final AppendEntriesReplyProto appendEntriesReply = server.appendEntries(appendEntriesRequest); return RaftNettyServerReplyProto.newBuilder() .setAppendEntriesReply(appendEntriesReply) .build(); case INSTALLSNAPSHOTREQUEST: final InstallSnapshotRequestProto installSnapshotRequest = proto.getInstallSnapshotRequest(); rpcRequest = installSnapshotRequest.getServerRequest(); final InstallSnapshotReplyProto installSnapshotReply = server.installSnapshot(installSnapshotRequest); return RaftNettyServerReplyProto.newBuilder() .setInstallSnapshotReply(installSnapshotReply) .build(); case RAFTCLIENTREQUEST: final RaftClientRequestProto raftClientRequest = proto.getRaftClientRequest(); rpcRequest = raftClientRequest.getRpcRequest(); final RaftClientReply raftClientReply = server.submitClientRequest( ClientProtoUtils.toRaftClientRequest(raftClientRequest)); return RaftNettyServerReplyProto.newBuilder() .setRaftClientReply(ClientProtoUtils.toRaftClientReplyProto(raftClientReply)) .build(); case SETCONFIGURATIONREQUEST: final SetConfigurationRequestProto configurationRequest = proto.getSetConfigurationRequest(); rpcRequest = configurationRequest.getRpcRequest(); final RaftClientReply configurationReply = server.setConfiguration( ClientProtoUtils.toSetConfigurationRequest(configurationRequest)); return RaftNettyServerReplyProto.newBuilder() .setRaftClientReply(ClientProtoUtils.toRaftClientReplyProto(configurationReply)) .build(); case GROUPMANAGEMENTREQUEST: final GroupManagementRequestProto groupManagementRequest = proto.getGroupManagementRequest(); rpcRequest = groupManagementRequest.getRpcRequest(); final RaftClientReply groupManagementReply = server.groupManagement( ClientProtoUtils.toGroupManagementRequest(groupManagementRequest)); return RaftNettyServerReplyProto.newBuilder() .setRaftClientReply(ClientProtoUtils.toRaftClientReplyProto(groupManagementReply)) .build(); case GROUPLISTREQUEST: final GroupListRequestProto groupListRequest = proto.getGroupListRequest(); rpcRequest = groupListRequest.getRpcRequest(); final GroupListReply groupListReply = server.getGroupList( ClientProtoUtils.toGroupListRequest(groupListRequest)); return RaftNettyServerReplyProto.newBuilder() .setGroupListReply(ClientProtoUtils.toGroupListReplyProto(groupListReply)) .build(); case GROUPINFOREQUEST: final GroupInfoRequestProto groupInfoRequest = proto.getGroupInfoRequest(); rpcRequest = groupInfoRequest.getRpcRequest(); final GroupInfoReply groupInfoReply = server.getGroupInfo( ClientProtoUtils.toGroupInfoRequest(groupInfoRequest)); return RaftNettyServerReplyProto.newBuilder() .setGroupInfoReply(ClientProtoUtils.toGroupInfoReplyProto(groupInfoReply)) .build(); case RAFTNETTYSERVERREQUEST_NOT_SET: throw new IllegalArgumentException("Request case not set in proto: " + proto.getRaftNettyServerRequestCase()); default: throw new UnsupportedOperationException("Request case not supported: " + proto.getRaftNettyServerRequestCase()); } } catch (IOException ioe) { return toRaftNettyServerReplyProto( Objects.requireNonNull(rpcRequest, "rpcRequest = null"), ioe); } }