Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 93A3B1016F for ; Tue, 5 May 2015 20:47:23 +0000 (UTC) Received: (qmail 6205 invoked by uid 500); 5 May 2015 20:47:23 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 6139 invoked by uid 500); 5 May 2015 20:47:23 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 6130 invoked by uid 99); 5 May 2015 20:47:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 May 2015 20:47:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2F33CE116F; Tue, 5 May 2015 20:47:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: xyao@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HDFS-8219. setStoragePolicy with folder behavior is different after cluster restart. (surendra singh lilhore via Xiaoyu Yao) Date: Tue, 5 May 2015 20:47:23 +0000 (UTC) Repository: hadoop Updated Branches: refs/heads/branch-2 eb0c6d2ee -> e68e8b3b5 HDFS-8219. setStoragePolicy with folder behavior is different after cluster restart. (surendra singh lilhore via Xiaoyu Yao) (cherry picked from commit 0100b155019496d077f958904de7d385697d65d9) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/e68e8b3b Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/e68e8b3b Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/e68e8b3b Branch: refs/heads/branch-2 Commit: e68e8b3b5cff85bfd8bb5b00b9033f63577856d6 Parents: eb0c6d2 Author: Xiaoyu Yao Authored: Tue May 5 13:41:14 2015 -0700 Committer: Xiaoyu Yao Committed: Tue May 5 13:42:22 2015 -0700 ---------------------------------------------------------------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../hadoop/hdfs/server/namenode/FSEditLog.java | 2 +- .../hadoop/hdfs/TestBlockStoragePolicy.java | 45 ++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/e68e8b3b/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 75d0871..0aaba2f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -299,6 +299,9 @@ Release 2.8.0 - UNRELEASED HDFS-8290. WebHDFS calls before namesystem initialization can cause NullPointerException. (cnauroth) + HDFS-8219. setStoragePolicy with folder behavior is different after cluster restart. + (surendra singh lilhore via Xiaoyu Yao) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/e68e8b3b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java index 9ec4902..0e097c7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLog.java @@ -740,7 +740,7 @@ public class FSEditLog implements LogsPurgeable { .setClientMachine( newNode.getFileUnderConstructionFeature().getClientMachine()) .setOverwrite(overwrite) - .setStoragePolicyId(newNode.getStoragePolicyID()); + .setStoragePolicyId(newNode.getLocalStoragePolicyID()); AclFeature f = newNode.getAclFeature(); if (f != null) { http://git-wip-us.apache.org/repos/asf/hadoop/blob/e68e8b3b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlockStoragePolicy.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlockStoragePolicy.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlockStoragePolicy.java index 821d2db..4c3e7f0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlockStoragePolicy.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestBlockStoragePolicy.java @@ -26,6 +26,7 @@ import java.util.*; import com.google.common.collect.Lists; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.StorageType; @@ -1177,4 +1178,48 @@ public class TestBlockStoragePolicy { cluster.shutdown(); } } + + @Test + public void testGetFileStoragePolicyAfterRestartNN() throws Exception { + //HDFS8219 + final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) + .numDataNodes(REPLICATION) + .storageTypes( + new StorageType[] {StorageType.DISK, StorageType.ARCHIVE}) + .build(); + cluster.waitActive(); + final DistributedFileSystem fs = cluster.getFileSystem(); + try { + final String file = "/testScheduleWithinSameNode/file"; + Path dir = new Path("/testScheduleWithinSameNode"); + fs.mkdirs(dir); + // 2. Set Dir policy + fs.setStoragePolicy(dir, "COLD"); + // 3. Create file + final FSDataOutputStream out = fs.create(new Path(file)); + out.writeChars("testScheduleWithinSameNode"); + out.close(); + // 4. Set Dir policy + fs.setStoragePolicy(dir, "HOT"); + HdfsFileStatus status = fs.getClient().getFileInfo(file); + // 5. get file policy, it should be parent policy. + Assert + .assertTrue( + "File storage policy should be HOT", + status.getStoragePolicy() + == HdfsServerConstants.HOT_STORAGE_POLICY_ID); + // 6. restart NameNode for reloading edits logs. + cluster.restartNameNode(true); + // 7. get file policy, it should be parent policy. + status = fs.getClient().getFileInfo(file); + Assert + .assertTrue( + "File storage policy should be HOT", + status.getStoragePolicy() + == HdfsServerConstants.HOT_STORAGE_POLICY_ID); + + } finally { + cluster.shutdown(); + } + } }