From 5699dbc35f5b81f598e0d9e709f67ba7d8095fa1 Mon Sep 17 00:00:00 2001 From: Harsh J Date: Sun, 14 Jul 2013 11:01:02 +0000 Subject: [PATCH] HADOOP-9241. DU refresh interval is not configurable. (harsh) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1502955 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 2 ++ .../apache/hadoop/fs/CommonConfigurationKeysPublic.java | 4 ++++ .../src/main/java/org/apache/hadoop/fs/DU.java | 5 +++-- .../hadoop-common/src/main/resources/core-default.xml | 6 ++++++ .../src/test/java/org/apache/hadoop/fs/TestDU.java | 7 ++++++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 9c44d76718c..d6c28d54887 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -14,6 +14,8 @@ Release 2.3.0 - UNRELEASED HADOOP-9432 Add support for markdown .md files in site documentation (stevel) + HADOOP-9241. DU refresh interval is not configurable (harsh) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeysPublic.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeysPublic.java index d6774b8d284..211a36f80d4 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeysPublic.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/CommonConfigurationKeysPublic.java @@ -54,6 +54,10 @@ public class CommonConfigurationKeysPublic { public static final String FS_DF_INTERVAL_KEY = "fs.df.interval"; /** Default value for FS_DF_INTERVAL_KEY */ public static final long FS_DF_INTERVAL_DEFAULT = 60000; + /** See core-default.xml */ + public static final String FS_DU_INTERVAL_KEY = "fs.du.interval"; + /** Default value for FS_DU_INTERVAL_KEY */ + public static final long FS_DU_INTERVAL_DEFAULT = 600000; //Defaults are not specified for following keys diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java index db90cfa7aac..3fa55100368 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java @@ -20,6 +20,7 @@ package org.apache.hadoop.fs; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.util.Shell; import java.io.BufferedReader; @@ -64,8 +65,8 @@ public class DU extends Shell { * @throws IOException if we fail to refresh the disk usage */ public DU(File path, Configuration conf) throws IOException { - this(path, 600000L); - //10 minutes default refresh interval + this(path, conf.getLong(CommonConfigurationKeys.FS_DU_INTERVAL_KEY, + CommonConfigurationKeys.FS_DU_INTERVAL_DEFAULT)); } /** diff --git a/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml b/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml index f56e161d44b..236b4b22613 100644 --- a/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml +++ b/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml @@ -456,6 +456,12 @@ Disk usage statistics refresh interval in msec. + + fs.du.interval + 600000 + File space usage statistics refresh interval in msec. + + fs.s3.block.size 67108864 diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java index 71024acd9e6..ef59b85bd34 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java @@ -24,6 +24,9 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.util.Random; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.CommonConfigurationKeys; + /** This test makes sure that "DU" does not get to run on each call to getUsed */ public class TestDU extends TestCase { final static private File DU_DIR = new File( @@ -106,7 +109,9 @@ public class TestDU extends TestCase { public void testDUGetUsedWillNotReturnNegative() throws IOException { File file = new File(DU_DIR, "data"); assertTrue(file.createNewFile()); - DU du = new DU(file, 10000); + Configuration conf = new Configuration(); + conf.setLong(CommonConfigurationKeys.FS_DU_INTERVAL_KEY, 10000L); + DU du = new DU(file, conf); du.decDfsUsed(Long.MAX_VALUE); long duSize = du.getUsed(); assertTrue(String.valueOf(duSize), duSize >= 0L);