peterxcli commented on code in PR #7988:
URL: https://github.com/apache/ozone/pull/7988#discussion_r1996668448
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerProtocolServerSideTranslatorPB.java:
##########
@@ -219,14 +219,35 @@ private OMResponse submitReadRequestToOM(OMRequest
request)
throws ServiceException {
// Check if this OM is the leader.
RaftServerStatus raftServerStatus = omRatisServer.checkLeaderStatus();
- if (raftServerStatus == LEADER_AND_READY ||
- request.getCmdType().equals(PrepareStatus)) {
+ if (raftServerStatus == LEADER_AND_READY ||
request.getCmdType().equals(PrepareStatus) ||
+ (raftServerStatus == NOT_LEADER &&
allowSnapshotReadFromFollower(request))) {
return handler.handleReadRequest(request);
} else {
throw createLeaderErrorException(raftServerStatus);
}
}
+ private boolean allowSnapshotReadFromFollower(OMRequest omRequest) {
+ if (!omRequest.hasOmNodeId()) {
+ return false;
+ }
+
+ if (!omRequest.getOmNodeId().equals(ozoneManager.getOMNodeId())) {
+ return false;
+ }
+
+ switch (omRequest.getCmdType()) {
+ case SnapshotDiff:
+ case ListSnapshot:
+ case GetSnapshotInfo:
+ case ListSnapshotDiffJobs:
+ case CancelSnapshotDiff:
+ return true;
+ default:
+ return false;
+ }
+ }
+
Review Comment:
Thanks for the clarification.
Could you help to resolve this conversion, as this is quite long😅
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]