HDFS-7029. Archival Storage: fix TestDFSInotifyEventInputStream and TestDistributedFileSystem. Contributed by Tsz Wo Nicholas Sze.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/867f0f14 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/867f0f14 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/867f0f14 Branch: refs/heads/HDFS-6581 Commit: 867f0f141cc935c1f67680533cc22f25b804f720 Parents: 74a7e22 Author: Jing Zhao <ji...@apache.org> Authored: Mon Sep 8 14:57:27 2014 -0700 Committer: Jing Zhao <ji...@apache.org> Committed: Mon Sep 8 14:57:27 2014 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/hdfs/BlockStoragePolicy.java | 15 +++++++++++++++ .../hadoop/hdfs/TestDFSInotifyEventInputStream.java | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/867f0f14/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/BlockStoragePolicy.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/BlockStoragePolicy.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/BlockStoragePolicy.java index a72d4f1..efbf8a0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/BlockStoragePolicy.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/BlockStoragePolicy.java @@ -55,6 +55,17 @@ public class BlockStoragePolicy { public static final int ID_MAX = (1 << ID_BIT_LENGTH) - 1; public static final byte ID_UNSPECIFIED = 0; + private static final Suite DEFAULT_SUITE = createDefaultSuite(); + + private static Suite createDefaultSuite() { + final BlockStoragePolicy[] policies = new BlockStoragePolicy[1 << ID_BIT_LENGTH]; + final StorageType[] storageTypes = {StorageType.DISK}; + final byte defaultPolicyId = 12; + policies[defaultPolicyId] = new BlockStoragePolicy(defaultPolicyId, "HOT", + storageTypes, StorageType.EMPTY_ARRAY, StorageType.EMPTY_ARRAY); + return new Suite(defaultPolicyId, policies); + } + /** A block storage policy suite. */ public static class Suite { private final byte defaultPolicyID; @@ -342,6 +353,10 @@ public class BlockStoragePolicy { public static Suite readBlockStorageSuite(Configuration conf) { final BlockStoragePolicy[] policies = new BlockStoragePolicy[1 << ID_BIT_LENGTH]; final String[] values = conf.getStrings(DFS_BLOCK_STORAGE_POLICIES_KEY); + if (values == null) { + // conf property is missing, use default suite. + return DEFAULT_SUITE; + } byte firstID = -1; for(String v : values) { v = v.trim(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/867f0f14/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSInotifyEventInputStream.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSInotifyEventInputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSInotifyEventInputStream.java index 45b588b..a608ba8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSInotifyEventInputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSInotifyEventInputStream.java @@ -64,7 +64,7 @@ public class TestDFSInotifyEventInputStream { */ @Test public void testOpcodeCount() { - Assert.assertTrue(FSEditLogOpCodes.values().length == 46); + Assert.assertTrue(FSEditLogOpCodes.values().length == 47); }