hanishakoneru commented on a change in pull request #276: HDDS-2637. Handle
LeaderNot ready exception in OzoneManager StateMachine and upgrade ratis to
latest version.
URL: https://github.com/apache/hadoop-ozone/pull/276#discussion_r351542904
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java
##########
@@ -156,24 +159,48 @@ private OMResponse processReply(OMRequest omRequest,
RaftClientReply reply)
// NotLeader exception is thrown only when the raft server to which the
// request is submitted is not the leader. This can happen first time
// when client is submitting request to OM.
- NotLeaderException notLeaderException = reply.getNotLeaderException();
- if (notLeaderException != null) {
- throw new ServiceException(notLeaderException);
- }
- StateMachineException stateMachineException =
- reply.getStateMachineException();
- if (stateMachineException != null) {
- OMResponse.Builder omResponse = OMResponse.newBuilder();
- omResponse.setCmdType(omRequest.getCmdType());
- omResponse.setSuccess(false);
- omResponse.setMessage(stateMachineException.getCause().getMessage());
- omResponse.setStatus(parseErrorStatus(
- stateMachineException.getCause().getMessage()));
- if (LOG.isDebugEnabled()) {
- LOG.debug("Error while executing ratis request. " +
- "stateMachineException: ", stateMachineException);
+
+ if (!reply.isSuccess()) {
+ NotLeaderException notLeaderException = reply.getNotLeaderException();
+ if (notLeaderException != null) {
+ RaftPeerId suggestedLeader =
+ notLeaderException.getSuggestedLeader() != null ?
+ notLeaderException.getSuggestedLeader().getId() : null;
+ org.apache.hadoop.ozone.om.exceptions.NotLeaderException
+ notLeaderException1;
+ if (suggestedLeader != null) {
+ notLeaderException1 = new org.apache.hadoop.ozone.om.exceptions
+ .NotLeaderException(getRaftPeerId(), suggestedLeader);
+ } else {
+ notLeaderException1 =
+ new org.apache.hadoop.ozone.om.exceptions
+ .NotLeaderException(getRaftPeerId());
+ }
+ throw new ServiceException(notLeaderException1);
+ }
+
Review comment:
Do you think it would be good idea to rename
org.apache.hadoop.ozone.om.exceptions.NotLeaderException to
OMNotLeaderException so as to distinguish with Ratis NotLeaderException.
Also, we can add a method in OMNotLeaderException to parse Ratis
NotLeaderException and call that method here.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]