[ 
https://issues.apache.org/jira/browse/HDDS-1258?focusedWorklogId=264748&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-264748
 ]

ASF GitHub Bot logged work on HDDS-1258:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Jun/19 16:28
            Start Date: 21/Jun/19 16:28
    Worklog Time Spent: 10m 
      Work Description: jiwq commented on pull request #1001: HDDS-1258 - Fix 
error propagation for SCM protocol
URL: https://github.com/apache/hadoop/pull/1001#discussion_r296306101
 
 

 ##########
 File path: 
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/scm/exceptions/TestSCMExceptionResultCodes.java
 ##########
 @@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdds.scm.exceptions;
+
+import org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes;
+import org.apache.hadoop.hdds.protocol.proto.
+    ScmBlockLocationProtocolProtos.Status;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test Result code mappping between SCMException and the protobuf definitions.
+ */
+public class TestSCMExceptionResultCodes {
+
+  @Test
+  public void codeMapping() {
+    // ResultCode = SCMException definition
+    // Status = protobuf definition
+    Assert.assertEquals(ResultCodes.values().length, Status.values().length);
+    for (int i = 0; i < ResultCodes.values().length; i++) {
+      ResultCodes codeValue = ResultCodes.values()[i];
+      Status protoBufValue = Status.values()[i];
+      Assert.assertTrue(String
+          .format("Protobuf/Enum constant name mismatch %s %s", codeValue,
+              protoBufValue), sameName(codeValue.name(), 
protoBufValue.name()));
+      ResultCodes converted = ResultCodes.values()[protoBufValue.ordinal()];
+      Assert.assertEquals(codeValue, converted);
+    }
+  }
+
+  private boolean sameName(String codeValue, String protoBufValue) {
+    return codeValue.equals(protoBufValue);
+  }
+
+}
 
 Review comment:
   ```suggestion
   }
   
   ```
 
----------------------------------------------------------------
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 264748)
    Time Spent: 1h  (was: 50m)

> Fix error propagation for SCM protocol
> --------------------------------------
>
>                 Key: HDDS-1258
>                 URL: https://issues.apache.org/jira/browse/HDDS-1258
>             Project: Hadoop Distributed Data Store
>          Issue Type: Improvement
>            Reporter: Elek, Marton
>            Assignee: Stephen O'Donnell
>            Priority: Critical
>              Labels: pull-request-available
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> HDDS-1068 fixed the error propagation between the OM client and OM server.
> By default the Server.java transforms all the IOExceptions to one string 
> (message + stack trace) and this is returned to the client.
> But for business exception (eg. volume not found, chill mode is active, etc.) 
> this is not what we need.
> In the OM side we fixed this behaviour. In the ServerSideTranslator classes 
> we catch (server) the business (OMException) exceptions and serialize them to 
> the response object.
> The exception (and the status code) is stored in message/status field of the 
> OMResponse (hadoop-ozone/common/src/main/proto/OzoneManagerProtocol.proto)
> Here I propose to do the same for the ScmBlockLocationProtocol.proto.
> Unfortunately there is no common parent object (like OMRequest) in this 
> protocol, but we can easily add one as only the Serverside/Clientside 
> translator should be changed for that. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to