diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsConstants.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsConstants.java index f12a6fbb5bc..d4fb8608ad2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsConstants.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsConstants.java @@ -37,6 +37,9 @@ public class HdfsConstants { public static final String MEMORY_STORAGE_POLICY_NAME = "LAZY_PERSIST"; public static final String ALLSSD_STORAGE_POLICY_NAME = "ALL_SSD"; public static final String ONESSD_STORAGE_POLICY_NAME = "ONE_SSD"; + public static final String HOT_STORAGE_POLICY_NAME = "HOT"; + public static final String WARM_STORAGE_POLICY_NAME = "WARM"; + public static final String COLD_STORAGE_POLICY_NAME = "COLD"; // TODO should be conf injected? public static final int DEFAULT_DATA_SOCKET_SIZE = 128 * 1024; /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 1efea0fcdd2..ce521a3b5ef 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -414,6 +414,9 @@ Release 2.8.0 - UNRELEASED HDFS-8180. AbstractFileSystem Implementation for WebHdfs. (snayak via jghoman) + HDFS-8811. Move BlockStoragePolicy name's constants from + HdfsServerConstants.java to HdfsConstants.java (vinayakumarb) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockStoragePolicySuite.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockStoragePolicySuite.java index 2a71c2973f0..7e6c2b2d15f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockStoragePolicySuite.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockStoragePolicySuite.java @@ -69,18 +69,18 @@ public class BlockStoragePolicySuite { new StorageType[]{StorageType.SSD, StorageType.DISK}); final byte hotId = HdfsServerConstants.HOT_STORAGE_POLICY_ID; policies[hotId] = new BlockStoragePolicy(hotId, - HdfsServerConstants.HOT_STORAGE_POLICY_NAME, + HdfsConstants.HOT_STORAGE_POLICY_NAME, new StorageType[]{StorageType.DISK}, StorageType.EMPTY_ARRAY, new StorageType[]{StorageType.ARCHIVE}); final byte warmId = HdfsServerConstants.WARM_STORAGE_POLICY_ID; policies[warmId] = new BlockStoragePolicy(warmId, - HdfsServerConstants.WARM_STORAGE_POLICY_NAME, + HdfsConstants.WARM_STORAGE_POLICY_NAME, new StorageType[]{StorageType.DISK, StorageType.ARCHIVE}, new StorageType[]{StorageType.DISK, StorageType.ARCHIVE}, new StorageType[]{StorageType.DISK, StorageType.ARCHIVE}); final byte coldId = HdfsServerConstants.COLD_STORAGE_POLICY_ID; policies[coldId] = new BlockStoragePolicy(coldId, - HdfsServerConstants.COLD_STORAGE_POLICY_NAME, + HdfsConstants.COLD_STORAGE_POLICY_NAME, new StorageType[]{StorageType.ARCHIVE}, StorageType.EMPTY_ARRAY, StorageType.EMPTY_ARRAY); return new BlockStoragePolicySuite(hotId, policies); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/HdfsServerConstants.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/HdfsServerConstants.java index eeacd711af7..1259f4198d0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/HdfsServerConstants.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/HdfsServerConstants.java @@ -99,9 +99,6 @@ public interface HdfsServerConstants { }; byte[] DOT_SNAPSHOT_DIR_BYTES = DFSUtil.string2Bytes(HdfsConstants.DOT_SNAPSHOT_DIR); - String HOT_STORAGE_POLICY_NAME = "HOT"; - String WARM_STORAGE_POLICY_NAME = "WARM"; - String COLD_STORAGE_POLICY_NAME = "COLD"; byte MEMORY_STORAGE_POLICY_ID = 15; byte ALLSSD_STORAGE_POLICY_ID = 12; byte ONESSD_STORAGE_POLICY_ID = 10; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java index c07969163b6..0218b32874f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java @@ -1261,7 +1261,7 @@ public class DFSTestUtil { s2.close(); // OP_SET_STORAGE_POLICY 45 filesystem.setStoragePolicy(pathFileCreate, - HdfsServerConstants.HOT_STORAGE_POLICY_NAME); + HdfsConstants.HOT_STORAGE_POLICY_NAME); // OP_RENAME_OLD 1 final Path pathFileMoved = new Path("/file_moved"); filesystem.rename(pathFileCreate, pathFileMoved); 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 d11b06dd1ec..5875b131257 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 @@ -89,7 +89,7 @@ public class TestBlockStoragePolicy { try { cluster.waitActive(); cluster.getFileSystem().setStoragePolicy(new Path("/"), - HdfsServerConstants.COLD_STORAGE_POLICY_NAME); + HdfsConstants.COLD_STORAGE_POLICY_NAME); } finally { cluster.shutdown(); } @@ -109,7 +109,7 @@ public class TestBlockStoragePolicy { try { cluster.waitActive(); cluster.getFileSystem().setStoragePolicy(new Path("/"), - HdfsServerConstants.COLD_STORAGE_POLICY_NAME); + HdfsConstants.COLD_STORAGE_POLICY_NAME); } finally { cluster.shutdown(); } @@ -865,7 +865,7 @@ public class TestBlockStoragePolicy { final Path invalidPath = new Path("/invalidPath"); try { - fs.setStoragePolicy(invalidPath, HdfsServerConstants.WARM_STORAGE_POLICY_NAME); + fs.setStoragePolicy(invalidPath, HdfsConstants.WARM_STORAGE_POLICY_NAME); Assert.fail("Should throw a FileNotFoundException"); } catch (FileNotFoundException e) { GenericTestUtils.assertExceptionContains(invalidPath.toString(), e); @@ -878,17 +878,17 @@ public class TestBlockStoragePolicy { GenericTestUtils.assertExceptionContains(invalidPath.toString(), e); } - fs.setStoragePolicy(fooFile, HdfsServerConstants.COLD_STORAGE_POLICY_NAME); - fs.setStoragePolicy(barDir, HdfsServerConstants.WARM_STORAGE_POLICY_NAME); - fs.setStoragePolicy(barFile2, HdfsServerConstants.HOT_STORAGE_POLICY_NAME); + fs.setStoragePolicy(fooFile, HdfsConstants.COLD_STORAGE_POLICY_NAME); + fs.setStoragePolicy(barDir, HdfsConstants.WARM_STORAGE_POLICY_NAME); + fs.setStoragePolicy(barFile2, HdfsConstants.HOT_STORAGE_POLICY_NAME); Assert.assertEquals("File storage policy should be COLD", - HdfsServerConstants.COLD_STORAGE_POLICY_NAME, + HdfsConstants.COLD_STORAGE_POLICY_NAME, fs.getStoragePolicy(fooFile).getName()); Assert.assertEquals("File storage policy should be WARM", - HdfsServerConstants.WARM_STORAGE_POLICY_NAME, + HdfsConstants.WARM_STORAGE_POLICY_NAME, fs.getStoragePolicy(barDir).getName()); Assert.assertEquals("File storage policy should be HOT", - HdfsServerConstants.HOT_STORAGE_POLICY_NAME, + HdfsConstants.HOT_STORAGE_POLICY_NAME, fs.getStoragePolicy(barFile2).getName()); dirList = fs.getClient().listPaths(dir.toString(), @@ -937,7 +937,7 @@ public class TestBlockStoragePolicy { DFSTestUtil.createFile(fs, fooFile1, FILE_LEN, REPLICATION, 0L); DFSTestUtil.createFile(fs, fooFile2, FILE_LEN, REPLICATION, 0L); - fs.setStoragePolicy(fooDir, HdfsServerConstants.WARM_STORAGE_POLICY_NAME); + fs.setStoragePolicy(fooDir, HdfsConstants.WARM_STORAGE_POLICY_NAME); HdfsFileStatus[] dirList = fs.getClient().listPaths(dir.toString(), HdfsFileStatus.EMPTY_NAME, true).getPartialListing(); @@ -949,7 +949,7 @@ public class TestBlockStoragePolicy { // take snapshot SnapshotTestHelper.createSnapshot(fs, dir, "s1"); // change the storage policy of fooFile1 - fs.setStoragePolicy(fooFile1, HdfsServerConstants.COLD_STORAGE_POLICY_NAME); + fs.setStoragePolicy(fooFile1, HdfsConstants.COLD_STORAGE_POLICY_NAME); fooList = fs.getClient().listPaths(fooDir.toString(), HdfsFileStatus.EMPTY_NAME).getPartialListing(); @@ -972,7 +972,7 @@ public class TestBlockStoragePolicy { HdfsFileStatus.EMPTY_NAME).getPartialListing(), COLD); // change the storage policy of foo dir - fs.setStoragePolicy(fooDir, HdfsServerConstants.HOT_STORAGE_POLICY_NAME); + fs.setStoragePolicy(fooDir, HdfsConstants.HOT_STORAGE_POLICY_NAME); // /dir/foo is now hot dirList = fs.getClient().listPaths(dir.toString(), HdfsFileStatus.EMPTY_NAME, true).getPartialListing(); @@ -1089,7 +1089,7 @@ public class TestBlockStoragePolicy { */ @Test public void testChangeHotFileRep() throws Exception { - testChangeFileRep(HdfsServerConstants.HOT_STORAGE_POLICY_NAME, HOT, + testChangeFileRep(HdfsConstants.HOT_STORAGE_POLICY_NAME, HOT, new StorageType[]{StorageType.DISK, StorageType.DISK, StorageType.DISK}, new StorageType[]{StorageType.DISK, StorageType.DISK, StorageType.DISK, @@ -1103,7 +1103,7 @@ public class TestBlockStoragePolicy { */ @Test public void testChangeWarmRep() throws Exception { - testChangeFileRep(HdfsServerConstants.WARM_STORAGE_POLICY_NAME, WARM, + testChangeFileRep(HdfsConstants.WARM_STORAGE_POLICY_NAME, WARM, new StorageType[]{StorageType.DISK, StorageType.ARCHIVE, StorageType.ARCHIVE}, new StorageType[]{StorageType.DISK, StorageType.ARCHIVE, @@ -1116,7 +1116,7 @@ public class TestBlockStoragePolicy { */ @Test public void testChangeColdRep() throws Exception { - testChangeFileRep(HdfsServerConstants.COLD_STORAGE_POLICY_NAME, COLD, + testChangeFileRep(HdfsConstants.COLD_STORAGE_POLICY_NAME, COLD, new StorageType[]{StorageType.ARCHIVE, StorageType.ARCHIVE, StorageType.ARCHIVE}, new StorageType[]{StorageType.ARCHIVE, StorageType.ARCHIVE, diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/mover/TestStorageMover.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/mover/TestStorageMover.java index da7e4b94c0d..a4e4a9648bf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/mover/TestStorageMover.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/mover/TestStorageMover.java @@ -44,6 +44,7 @@ import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.HdfsConfiguration; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.protocol.DirectoryListing; +import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; import org.apache.hadoop.hdfs.protocol.HdfsLocatedFileStatus; import org.apache.hadoop.hdfs.protocol.LocatedBlock; @@ -54,7 +55,6 @@ import org.apache.hadoop.hdfs.server.balancer.ExitStatus; import org.apache.hadoop.hdfs.server.balancer.TestBalancer; import org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicy; import org.apache.hadoop.hdfs.server.blockmanagement.BlockStoragePolicySuite; -import org.apache.hadoop.hdfs.server.common.HdfsServerConstants; import org.apache.hadoop.hdfs.server.datanode.DataNode; import org.apache.hadoop.hdfs.server.datanode.DataNodeTestUtils; import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi; @@ -102,9 +102,9 @@ public class TestStorageMover { DEFAULT_CONF.setLong(DFSConfigKeys.DFS_MOVER_MOVEDWINWIDTH_KEY, 2000L); DEFAULT_POLICIES = BlockStoragePolicySuite.createDefaultSuite(); - HOT = DEFAULT_POLICIES.getPolicy(HdfsServerConstants.HOT_STORAGE_POLICY_NAME); - WARM = DEFAULT_POLICIES.getPolicy(HdfsServerConstants.WARM_STORAGE_POLICY_NAME); - COLD = DEFAULT_POLICIES.getPolicy(HdfsServerConstants.COLD_STORAGE_POLICY_NAME); + HOT = DEFAULT_POLICIES.getPolicy(HdfsConstants.HOT_STORAGE_POLICY_NAME); + WARM = DEFAULT_POLICIES.getPolicy(HdfsConstants.WARM_STORAGE_POLICY_NAME); + COLD = DEFAULT_POLICIES.getPolicy(HdfsConstants.COLD_STORAGE_POLICY_NAME); TestBalancer.initTestSetup(); Dispatcher.setDelayAfterErrors(1000L); }