ivandika3 commented on code in PR #7988:
URL: https://github.com/apache/ozone/pull/7988#discussion_r1996789175
##########
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;
+ }
Review Comment:
Good point, I have added handling for OM node ID mismatch. By right this
shouldn't happen, but this should catch bugs early.
--
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]