You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2019/11/28 00:39:47 UTC

[GitHub] [hadoop-ozone] hanishakoneru commented on a change in pull request #276: HDDS-2637. Handle LeaderNot ready exception in OzoneManager StateMachine and upgrade ratis to latest version.

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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org