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

Haohui Mai commented on HDFS-9012:
----------------------------------

The patch looks good to me.

{code}
+
+  /**
+   * Get the timeout to be used for transmitting the OOB type
+   * @return the timeout in milliseconds
+   */
+  public static long getOOBTimeout(Configuration conf, Status status)
+      throws IOException {
+    final int OOB_START = Status.OOB_RESTART_VALUE; // the first OOB type
+    final int OOB_END = Status.OOB_RESERVED3_VALUE; // the last OOB type
+    final int NUM_OOB_TYPES = OOB_END - OOB_START + 1;
+
+    final int index = status.getNumber() - OOB_START;
+    if (index < 0 || index >= NUM_OOB_TYPES) {
+      // Not an OOB.
+      throw new IOException("Not an OOB status: " + status);
+    }
+
+    // get timeout value of each OOB type from configuration
+    final String[] OOB_TIMEOUT = conf.get(DFS_DATANODE_OOB_TIMEOUT_KEY,
+        DFS_DATANODE_OOB_TIMEOUT_DEFAULT).split(",");
+    return index < OOB_TIMEOUT.length ? Long.parseLong(OOB_TIMEOUT[index]) : 0;
+  }
{code}

It might make more sense to promote the array of {{OOB_TIMEOUT}} to the 
{{DataNode}} class to avoid repetitive queries of the configuration object. 

> Move o.a.h.hdfs.protocol.datatransfer.PipelineAck class to hadoop-hdfs-client 
> module
> ------------------------------------------------------------------------------------
>
>                 Key: HDFS-9012
>                 URL: https://issues.apache.org/jira/browse/HDFS-9012
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: build
>            Reporter: Mingliang Liu
>            Assignee: Mingliang Liu
>         Attachments: HDFS-9012.000.patch, HDFS-9012.001.patch
>
>
> The {{package org.apache.hadoop.hdfs.protocol.datatransfer.PipelineAck}} 
> class is used in client module classes (e.g. 
> {{DataStreamer$ResponseProcessor}} in {{DFSInputStream}} and 
> {{DFSOutputStream}}). This jira tracks the effort of moving this class to 
> {{hadoop-hdfs-client}} module.
> We should keep the static attribute {{OOB_TIMEOUT}} and helper method 
> {{getOOBTimeout}} in the {{hadoop-hdfs}} module as they're not used (by now) 
> in {{hadoop-hdfs-client}} module. Meanwhile, we don't create the 
> {{HdfsConfiguration}} statically if we can pass the correct {{conf}} object.
> The checkstyle warnings can be addressed in 
> [HDFS-8979|https://issues.apache.org/jira/browse/HDFS-8979].



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to