[ 
https://issues.apache.org/jira/browse/HDFS-11426?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15879852#comment-15879852
 ] 

Surendra Singh Lilhore edited comment on HDFS-11426 at 2/23/17 12:12 PM:
-------------------------------------------------------------------------

Sorry but one more comment form my side..
In {{SetECPolicyCommand}} we can avoid one RPC for 
{{getErasureCodingPolicies()}}.

{code}
+        ErasureCodingPolicy[] ecPolicies =
+            dfs.getClient().getErasureCodingPolicies();
+        for (ErasureCodingPolicy policy : ecPolicies) {
+          if (ecPolicyName.equals(policy.getName())) {
+            ecPolicy = policy;
+            break;
+          }
+        }
+        if (ecPolicy == null) {
+          StringBuilder sb = new StringBuilder();
+          sb.append("Policy '");
+          sb.append(ecPolicyName);
+          sb.append("' does not match any of the supported policies.");
+          sb.append(" Please select any one of ");
+          List<String> ecPolicyNames = new ArrayList<String>();
+          for (ErasureCodingPolicy policy : ecPolicies) {
+            ecPolicyNames.add(policy.getName());
+          }
+          sb.append(ecPolicyNames);
+          System.err.println(sb.toString());
+          return 3;
+        }
{code}

This check already there in Namenode 
{{FSDirErasureCodingOp#setErasureCodingPolicyXAttr}}
{code}
      if (!validPolicy) {
        List<String> ecPolicyNames = new ArrayList<String>();
        for (ErasureCodingPolicy activePolicy : activePolicies) {
          ecPolicyNames.add(activePolicy.getName());
        }
        throw new HadoopIllegalArgumentException("Policy [ " +
            ecPolicy.getName() + " ] does not match any of the " +
            "supported policies. Please select any one of " + ecPolicyNames);
      }
{code}
If we change this only one RPC call is required in both the case (Invalid and 
valid policy)


was (Author: surendrasingh):
Sorry but one more comment form my side..
In {{SetECPolicyCommand}} we can avoid one RPC for 
{{getErasureCodingPolicies()}}.

{code}
+        ErasureCodingPolicy[] ecPolicies =
+            dfs.getClient().getErasureCodingPolicies();
+        for (ErasureCodingPolicy policy : ecPolicies) {
+          if (ecPolicyName.equals(policy.getName())) {
+            ecPolicy = policy;
+            break;
+          }
+        }
+        if (ecPolicy == null) {
+          StringBuilder sb = new StringBuilder();
+          sb.append("Policy '");
+          sb.append(ecPolicyName);
+          sb.append("' does not match any of the supported policies.");
+          sb.append(" Please select any one of ");
+          List<String> ecPolicyNames = new ArrayList<String>();
+          for (ErasureCodingPolicy policy : ecPolicies) {
+            ecPolicyNames.add(policy.getName());
+          }
+          sb.append(ecPolicyNames);
+          System.err.println(sb.toString());
+          return 3;
+        }
{code}

This check already there in Namenode 
{{FSDirErasureCodingOp#setErasureCodingPolicyXAttr}}
{code}
      if (!validPolicy) {
        List<String> ecPolicyNames = new ArrayList<String>();
        for (ErasureCodingPolicy activePolicy : activePolicies) {
          ecPolicyNames.add(activePolicy.getName());
        }
        throw new HadoopIllegalArgumentException("Policy [ " +
            ecPolicy.getName() + " ] does not match any of the " +
            "supported policies. Please select any one of " + ecPolicyNames);
      }
{code}

> Refactor EC CLI to be similar to storage policies CLI
> -----------------------------------------------------
>
>                 Key: HDFS-11426
>                 URL: https://issues.apache.org/jira/browse/HDFS-11426
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: erasure-coding, shell
>    Affects Versions: 3.0.0-alpha1
>            Reporter: Andrew Wang
>            Assignee: Andrew Wang
>              Labels: hdfs-ec-3.0-must-do
>         Attachments: HDFS-11426.001.patch, HDFS-11426.002.patch, 
> HDFS-11426.003.patch
>
>
> The {{hdfs erasurecode}} CLI is similar to {{hdfs storagepolicies}} in terms 
> of functionality, but different in terms of behavior. Let's refactor 
> {{ECCli}} to be more similar to the various Admin classes we already have, 
> and also make its calling syntax mimic {{hdfs storagepolicies}} as closely as 
> possible.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

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

Reply via email to