From b32757c616cc89c6df2312edd1aa05b7dab6ee6c Mon Sep 17 00:00:00 2001 From: Ayush Saxena Date: Fri, 10 Jan 2020 08:14:56 +0530 Subject: [PATCH] HDFS-15107. dfs.client.server-defaults.validity.period.ms to support time units. Contributed by Ayush Saxena. --- .../src/main/java/org/apache/hadoop/hdfs/DFSClient.java | 7 ++++--- .../server/federation/router/RouterClientProtocol.java | 5 +++-- .../hadoop-hdfs/src/main/resources/hdfs-default.xml | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java index c19aa96d36..f8d85d0b21 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java @@ -375,9 +375,10 @@ public DFSClient(URI nameNodeUri, ClientProtocol rpcNamenode, null : conf.getBoolean(DFS_CLIENT_CACHE_DROP_BEHIND_READS, false); Long readahead = (conf.get(DFS_CLIENT_CACHE_READAHEAD) == null) ? null : conf.getLongBytes(DFS_CLIENT_CACHE_READAHEAD, 0); - this.serverDefaultsValidityPeriod = - conf.getLong(DFS_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_KEY, - DFS_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_DEFAULT); + this.serverDefaultsValidityPeriod = conf.getTimeDuration( + DFS_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_KEY, + DFS_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_DEFAULT, + TimeUnit.MILLISECONDS); Boolean writeDropBehind = (conf.get(DFS_CLIENT_CACHE_DROP_BEHIND_WRITES) == null) ? null : conf.getBoolean(DFS_CLIENT_CACHE_DROP_BEHIND_WRITES, false); diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java index 5edcf8def1..82871aed15 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java @@ -167,9 +167,10 @@ public class RouterClientProtocol implements ClientProtocol { RBFConfigKeys.DFS_ROUTER_CLIENT_MOUNT_TIME_OUT, RBFConfigKeys.DFS_ROUTER_CLIENT_MOUNT_TIME_OUT_DEFAULT, TimeUnit.MILLISECONDS); - this.serverDefaultsValidityPeriod = conf.getLong( + this.serverDefaultsValidityPeriod = conf.getTimeDuration( DFS_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_KEY, - DFS_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_DEFAULT); + DFS_CLIENT_SERVER_DEFAULTS_VALIDITY_PERIOD_MS_DEFAULT, + TimeUnit.MILLISECONDS); // User and group for reporting try { this.superUser = UserGroupInformation.getCurrentUser().getShortUserName(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml index 775d7e5a9c..c0f14f578c 100755 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml @@ -2548,6 +2548,8 @@ The amount of milliseconds after which cached server defaults are updated. By default this parameter is set to 1 hour. + Support multiple time unit suffix(case insensitive), as described + in dfs.heartbeat.interval.