hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vinayakum...@apache.org
Subject [4/4] hadoop git commit: HDFS-9625. set replication for empty file failed when set storage policy (Contributed by DENG FEI)
Date Thu, 21 Jan 2016 13:52:11 GMT
HDFS-9625. set replication for empty file failed when set storage policy (Contributed by DENG
FEI)

(cherry picked from commit b7372b7166a13111b98794602ca4c166dfd78d29)
(cherry picked from commit 845acfd96c8461ebb412cd1daec51e89ce9f1c18)


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

Branch: refs/heads/branch-2.7
Commit: ca299334052cec38e9b63c9711e53a9422c4d9f4
Parents: eb3dcc0
Author: Vinayakumar B <vinayakumarb@apache.org>
Authored: Thu Jan 21 19:17:05 2016 +0530
Committer: Vinayakumar B <vinayakumarb@apache.org>
Committed: Thu Jan 21 19:21:00 2016 +0530

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt      |  3 +++
 .../hadoop/hdfs/server/namenode/FSDirectory.java |  4 ++++
 .../apache/hadoop/hdfs/TestSetrepIncreasing.java | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca299334/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 012080e..67e13a5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -62,6 +62,9 @@ Release 2.7.3 - UNRELEASED
     HDFS-9661. Deadlock in DN.FsDatasetImpl between moveBlockAcrossStorage and
     createRbw (ade via vinayakumarb)
 
+    HDFS-9625. set replication for empty file failed when set storage policy
+    (DENG FEI via vinayakumarb)
+
 Release 2.7.2 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca299334/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
index 0c4859f..58dc967 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
@@ -741,6 +741,10 @@ public class FSDirectory implements Closeable {
       long dsDelta, short oldRep, short newRep) {
     EnumCounters<StorageType> typeSpaceDeltas =
         new EnumCounters<StorageType>(StorageType.class);
+    // empty file
+    if(dsDelta == 0){
+      return typeSpaceDeltas;
+    }
     // Storage type and its quota are only available when storage policy is set
     if (storagePolicyID != BlockStoragePolicySuite.ID_UNSPECIFIED) {
       BlockStoragePolicy storagePolicy = getBlockManager().getStoragePolicy(storagePolicyID);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ca299334/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSetrepIncreasing.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSetrepIncreasing.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSetrepIncreasing.java
index 0af1988..a055adc 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSetrepIncreasing.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestSetrepIncreasing.java
@@ -83,4 +83,23 @@ public class TestSetrepIncreasing {
   public void testSetrepIncreasingSimulatedStorage() throws IOException {
     setrep(3, 7, true);
   }
+
+  @Test
+  public void testSetRepWithStoragePolicyOnEmptyFile() throws Exception {
+    Configuration conf = new HdfsConfiguration();
+    MiniDFSCluster cluster =
+        new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
+    DistributedFileSystem dfs = cluster.getFileSystem();
+    try {
+      Path d = new Path("/tmp");
+      dfs.mkdirs(d);
+      dfs.setStoragePolicy(d, "HOT");
+      Path f = new Path(d, "foo");
+      dfs.createNewFile(f);
+      dfs.setReplication(f, (short) 4);
+    } finally {
+      dfs.close();
+      cluster.shutdown();
+    }
+ }
 }


Mime
View raw message