hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yq...@apache.org
Subject hadoop git commit: HDFS-12085. Reconfigure namenode heartbeat interval fails if the interval was set with time unit. Contributed by Weiwei Yang.
Date Tue, 11 Jul 2017 12:40:56 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 34f113df5 -> 3a7f02b81


HDFS-12085. Reconfigure namenode heartbeat interval fails if the interval was set with time
unit. Contributed by Weiwei Yang.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3a7f02b8
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3a7f02b8
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3a7f02b8

Branch: refs/heads/trunk
Commit: 3a7f02b81520ad4d3eebf92e9dbca662beec0302
Parents: 34f113d
Author: Yiqun Lin <yqlin@apache.org>
Authored: Tue Jul 11 20:40:11 2017 +0800
Committer: Yiqun Lin <yqlin@apache.org>
Committed: Tue Jul 11 20:40:11 2017 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/hadoop/conf/Configuration.java  | 10 +++++++++-
 .../org/apache/hadoop/hdfs/server/namenode/NameNode.java |  5 ++++-
 .../hdfs/server/namenode/TestNameNodeReconfigure.java    | 11 +++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/3a7f02b8/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
index d3dd822..550aee7 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
@@ -1667,7 +1667,15 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
     }
   }
 
-  private long getTimeDurationHelper(String name, String vStr, TimeUnit unit) {
+  /**
+   * Return time duration in the given time unit. Valid units are encoded in
+   * properties as suffixes: nanoseconds (ns), microseconds (us), milliseconds
+   * (ms), seconds (s), minutes (m), hours (h), and days (d).
+   * @param name Property name
+   * @param vStr The string value with time unit suffix to be converted.
+   * @param unit Unit to convert the stored property, if it exists.
+   */
+  public long getTimeDurationHelper(String name, String vStr, TimeUnit unit) {
     vStr = vStr.trim();
     vStr = StringUtils.toLowerCase(vStr);
     ParsedTimeDuration vUnit = ParsedTimeDuration.unitFor(vStr);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3a7f02b8/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
index 5d0e8cb..79bbbc5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java
@@ -2050,7 +2050,10 @@ public class NameNode extends ReconfigurableBase implements
         datanodeManager.setHeartbeatInterval(DFS_HEARTBEAT_INTERVAL_DEFAULT);
         return String.valueOf(DFS_HEARTBEAT_INTERVAL_DEFAULT);
       } else {
-        datanodeManager.setHeartbeatInterval(Long.parseLong(newVal));
+        long newInterval = getConf()
+            .getTimeDurationHelper(DFS_HEARTBEAT_INTERVAL_KEY,
+                newVal, TimeUnit.SECONDS);
+        datanodeManager.setHeartbeatInterval(newInterval);
         return String.valueOf(datanodeManager.getHeartbeatInterval());
       }
     } catch (NumberFormatException nfe) {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3a7f02b8/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeReconfigure.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeReconfigure.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeReconfigure.java
index 7b4061a..6b553df 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeReconfigure.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeReconfigure.java
@@ -182,6 +182,17 @@ public class TestNameNodeReconfigure {
         + " has wrong value", 10 * 60 * 1000,
         datanodeManager.getHeartbeatRecheckInterval());
 
+    // change to a value with time unit
+    nameNode.reconfigureProperty(DFS_HEARTBEAT_INTERVAL_KEY, "1m");
+
+    assertEquals(
+        DFS_HEARTBEAT_INTERVAL_KEY + " has wrong value",
+        60,
+        nameNode.getConf().getLong(DFS_HEARTBEAT_INTERVAL_KEY,
+            DFS_HEARTBEAT_INTERVAL_DEFAULT));
+    assertEquals(DFS_HEARTBEAT_INTERVAL_KEY + " has wrong value", 60,
+        datanodeManager.getHeartbeatInterval());
+
     // revert to defaults
     nameNode.reconfigureProperty(DFS_HEARTBEAT_INTERVAL_KEY, null);
     nameNode.reconfigureProperty(DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY,


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


Mime
View raw message