hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [1/3] hadoop git commit: HDFS-8179. DFSClient#getServerDefaults returns null within 1 hour of system start. (Contributed by Xiaoyu Yao)
Date Mon, 20 Apr 2015 22:44:17 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 756c25429 -> 95a8d452c
  refs/heads/branch-2.7 b493ec28a -> cc42ad03d
  refs/heads/trunk d50e8f092 -> c92f6f360


HDFS-8179. DFSClient#getServerDefaults returns null within 1 hour of system start. (Contributed
by Xiaoyu Yao)


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

Branch: refs/heads/trunk
Commit: c92f6f360515cc21ecb9b9f49b3e59537ef0cb05
Parents: d50e8f0
Author: Arpit Agarwal <arp@apache.org>
Authored: Mon Apr 20 15:42:42 2015 -0700
Committer: Arpit Agarwal <arp@apache.org>
Committed: Mon Apr 20 15:42:42 2015 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/hadoop/fs/Trash.java    |  5 +++++
 .../org/apache/hadoop/fs/TrashPolicyDefault.java     |  4 ++--
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt          |  3 +++
 .../main/java/org/apache/hadoop/hdfs/DFSClient.java  |  4 +++-
 .../hadoop/hdfs/TestDistributedFileSystem.java       | 15 +++++++++++++++
 5 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/c92f6f36/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java
index 2d5f540..aae5cf7 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Trash.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.fs;
 
 import java.io.IOException;
 
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
@@ -33,6 +34,9 @@ import org.apache.hadoop.conf.Configured;
 @InterfaceAudience.Public
 @InterfaceStability.Stable
 public class Trash extends Configured {
+  private static final org.apache.commons.logging.Log LOG =
+      LogFactory.getLog(Trash.class);
+
   private TrashPolicy trashPolicy; // configured trash policy instance
 
   /** 
@@ -84,6 +88,7 @@ public class Trash extends Configured {
     } catch (Exception e) {
       // If we can not determine that trash is enabled server side then
       // bail rather than potentially deleting a file when trash is enabled.
+      LOG.warn("Failed to get server trash configuration", e);
       throw new IOException("Failed to get server trash configuration", e);
     }
     Trash trash = new Trash(fullyResolvedFs, conf);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c92f6f36/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java
index cfb51e2..d6a9b4b 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java
@@ -134,11 +134,11 @@ public class TrashPolicyDefault extends TrashPolicy {
     for (int i = 0; i < 2; i++) {
       try {
         if (!fs.mkdirs(baseTrashPath, PERMISSION)) {      // create current
-          LOG.warn("Can't create(mkdir) trash directory: "+baseTrashPath);
+          LOG.warn("Can't create(mkdir) trash directory: " + baseTrashPath);
           return false;
         }
       } catch (IOException e) {
-        LOG.warn("Can't create trash directory: "+baseTrashPath);
+        LOG.warn("Can't create trash directory: " + baseTrashPath, e);
         cause = e;
         break;
       }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c92f6f36/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 8dec32e..2d20812 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -561,6 +561,9 @@ Release 2.7.1 - UNRELEASED
     HDFS-8153. Error Message points to wrong parent directory in case of
     path component name length error (Anu Engineer via jitendra)
 
+    HDFS-8179. DFSClient#getServerDefaults returns null within 1
+    hour of system start. (Xiaoyu Yao via Arpit Agarwal)
+
 Release 2.7.0 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c92f6f36/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
index cc5727f..6a73a93 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
@@ -651,10 +651,12 @@ public class DFSClient implements java.io.Closeable, RemotePeerFactory,
    */
   public FsServerDefaults getServerDefaults() throws IOException {
     long now = Time.monotonicNow();
-    if (now - serverDefaultsLastUpdate > SERVER_DEFAULTS_VALIDITY_PERIOD) {
+    if ((serverDefaults == null) ||
+        (now - serverDefaultsLastUpdate > SERVER_DEFAULTS_VALIDITY_PERIOD)) {
       serverDefaults = namenode.getServerDefaults();
       serverDefaultsLastUpdate = now;
     }
+    assert serverDefaults != null;
     return serverDefaults;
   }
   

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c92f6f36/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
index 5be492f..9a10206 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
@@ -52,6 +52,7 @@ import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
 import org.apache.hadoop.fs.CreateFlag;
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FsServerDefaults;
 import org.apache.hadoop.fs.FileChecksum;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -997,4 +998,18 @@ public class TestDistributedFileSystem {
       cluster.shutdown();
     }
   }
+
+  @Test(timeout=60000)
+  public void testGetServerDefaults() throws IOException {
+    Configuration conf = new HdfsConfiguration();
+    MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
+    try {
+      cluster.waitActive();
+      DistributedFileSystem dfs = cluster.getFileSystem();
+      FsServerDefaults fsServerDefaults = dfs.getServerDefaults();
+      Assert.assertNotNull(fsServerDefaults);
+    } finally {
+      cluster.shutdown();
+    }
+  }
 }


Mime
View raw message