use of org.apache.hadoop.hdfs.server.blockmanagement.BlockStoragePolicySuite in project hadoop by apache.
the class TestStoragePolicyCommands method testSetAndGetStoragePolicy.
@Test
public void testSetAndGetStoragePolicy() throws Exception {
final Path foo = new Path("/foo");
final Path bar = new Path(foo, "bar");
DFSTestUtil.createFile(fs, bar, SIZE, REPL, 0);
final StoragePolicyAdmin admin = new StoragePolicyAdmin(conf);
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /foo", 0, "The storage policy of " + foo.toString() + " is unspecified");
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /foo/bar", 0, "The storage policy of " + bar.toString() + " is unspecified");
DFSTestUtil.toolRun(admin, "-setStoragePolicy -path /foo -policy WARM", 0, "Set storage policy WARM on " + foo.toString());
DFSTestUtil.toolRun(admin, "-setStoragePolicy -path /foo/bar -policy COLD", 0, "Set storage policy COLD on " + bar.toString());
DFSTestUtil.toolRun(admin, "-setStoragePolicy -path /fooz -policy WARM", 2, "File/Directory does not exist: /fooz");
final BlockStoragePolicySuite suite = BlockStoragePolicySuite.createDefaultSuite();
final BlockStoragePolicy warm = suite.getPolicy("WARM");
final BlockStoragePolicy cold = suite.getPolicy("COLD");
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /foo", 0, "The storage policy of " + foo.toString() + ":\n" + warm);
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /foo/bar", 0, "The storage policy of " + bar.toString() + ":\n" + cold);
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /fooz", 2, "File/Directory does not exist: /fooz");
}
use of org.apache.hadoop.hdfs.server.blockmanagement.BlockStoragePolicySuite in project hadoop by apache.
the class TestStoragePolicyCommands method testSetAndUnsetStoragePolicy.
@Test
public void testSetAndUnsetStoragePolicy() throws Exception {
final Path foo = new Path("/foo");
final Path bar = new Path(foo, "bar");
final Path wow = new Path(bar, "wow");
DFSTestUtil.createFile(fs, wow, SIZE, REPL, 0);
/*
* test: set storage policy
*/
final StoragePolicyAdmin admin = new StoragePolicyAdmin(conf);
DFSTestUtil.toolRun(admin, "-setStoragePolicy -path " + fs.getUri() + "/foo -policy WARM", 0, "Set storage policy WARM on " + fs.getUri() + "/foo");
DFSTestUtil.toolRun(admin, "-setStoragePolicy -path /foo/bar -policy COLD", 0, "Set storage policy COLD on " + bar.toString());
DFSTestUtil.toolRun(admin, "-setStoragePolicy -path /foo/bar/wow -policy HOT", 0, "Set storage policy HOT on " + wow.toString());
DFSTestUtil.toolRun(admin, "-setStoragePolicy -path /fooz -policy WARM", 2, "File/Directory does not exist: /fooz");
/*
* test: get storage policy after set
*/
final BlockStoragePolicySuite suite = BlockStoragePolicySuite.createDefaultSuite();
final BlockStoragePolicy warm = suite.getPolicy("WARM");
final BlockStoragePolicy cold = suite.getPolicy("COLD");
final BlockStoragePolicy hot = suite.getPolicy("HOT");
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path " + fs.getUri() + "/foo", 0, "The storage policy of " + fs.getUri() + "/foo:\n" + warm);
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /foo/bar", 0, "The storage policy of " + bar.toString() + ":\n" + cold);
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /foo/bar/wow", 0, "The storage policy of " + wow.toString() + ":\n" + hot);
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /fooz", 2, "File/Directory does not exist: /fooz");
/*
* test: unset storage policy
*/
DFSTestUtil.toolRun(admin, "-unsetStoragePolicy -path " + fs.getUri() + "/foo", 0, "Unset storage policy from " + fs.getUri() + "/foo");
DFSTestUtil.toolRun(admin, "-unsetStoragePolicy -path /foo/bar", 0, "Unset storage policy from " + bar.toString());
DFSTestUtil.toolRun(admin, "-unsetStoragePolicy -path /foo/bar/wow", 0, "Unset storage policy from " + wow.toString());
DFSTestUtil.toolRun(admin, "-unsetStoragePolicy -path /fooz", 2, "File/Directory does not exist: /fooz");
/*
* test: get storage policy after unset
*/
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /foo", 0, "The storage policy of " + foo.toString() + " is unspecified");
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /foo/bar", 0, "The storage policy of " + bar.toString() + " is unspecified");
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /foo/bar/wow", 0, "The storage policy of " + wow.toString() + " is unspecified");
DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /fooz", 2, "File/Directory does not exist: /fooz");
}
use of org.apache.hadoop.hdfs.server.blockmanagement.BlockStoragePolicySuite in project hadoop by apache.
the class TestStoragePolicySummary method testMultipleWarmsInDifferentOrder.
@Test
public void testMultipleWarmsInDifferentOrder() {
BlockStoragePolicySuite bsps = BlockStoragePolicySuite.createDefaultSuite();
StoragePolicySummary sts = new StoragePolicySummary(bsps.getAllPolicies());
BlockStoragePolicy warm = bsps.getPolicy("WARM");
//DISK:1,ARCHIVE:1
sts.add(new StorageType[] { StorageType.DISK, StorageType.ARCHIVE }, warm);
sts.add(new StorageType[] { StorageType.ARCHIVE, StorageType.DISK }, warm);
//DISK:2,ARCHIVE:1
sts.add(new StorageType[] { StorageType.ARCHIVE, StorageType.DISK, StorageType.DISK }, warm);
sts.add(new StorageType[] { StorageType.DISK, StorageType.ARCHIVE, StorageType.DISK }, warm);
sts.add(new StorageType[] { StorageType.DISK, StorageType.DISK, StorageType.ARCHIVE }, warm);
//DISK:1,ARCHIVE:2
sts.add(new StorageType[] { StorageType.DISK, StorageType.ARCHIVE, StorageType.ARCHIVE }, warm);
sts.add(new StorageType[] { StorageType.ARCHIVE, StorageType.DISK, StorageType.ARCHIVE }, warm);
sts.add(new StorageType[] { StorageType.ARCHIVE, StorageType.ARCHIVE, StorageType.DISK }, warm);
//DISK:2,ARCHIVE:2
sts.add(new StorageType[] { StorageType.ARCHIVE, StorageType.ARCHIVE, StorageType.DISK, StorageType.DISK }, warm);
Map<String, Long> actualOutput = convertToStringMap(sts);
Assert.assertEquals(4, actualOutput.size());
Map<String, Long> expectedOutput = new HashMap<>();
expectedOutput.put("WARM|DISK:1,ARCHIVE:1(WARM)", 2l);
expectedOutput.put("WARM|DISK:2,ARCHIVE:1", 3l);
expectedOutput.put("WARM|DISK:1,ARCHIVE:2(WARM)", 3l);
expectedOutput.put("WARM|DISK:2,ARCHIVE:2", 1l);
Assert.assertEquals(expectedOutput, actualOutput);
}
use of org.apache.hadoop.hdfs.server.blockmanagement.BlockStoragePolicySuite in project hadoop by apache.
the class TestStoragePolicySummary method testMultipleHots.
@Test
public void testMultipleHots() {
BlockStoragePolicySuite bsps = BlockStoragePolicySuite.createDefaultSuite();
StoragePolicySummary sts = new StoragePolicySummary(bsps.getAllPolicies());
BlockStoragePolicy hot = bsps.getPolicy("HOT");
sts.add(new StorageType[] { StorageType.DISK }, hot);
sts.add(new StorageType[] { StorageType.DISK, StorageType.DISK }, hot);
sts.add(new StorageType[] { StorageType.DISK, StorageType.DISK, StorageType.DISK }, hot);
sts.add(new StorageType[] { StorageType.DISK, StorageType.DISK, StorageType.DISK, StorageType.DISK }, hot);
Map<String, Long> actualOutput = convertToStringMap(sts);
Assert.assertEquals(4, actualOutput.size());
Map<String, Long> expectedOutput = new HashMap<>();
expectedOutput.put("HOT|DISK:1(HOT)", 1l);
expectedOutput.put("HOT|DISK:2(HOT)", 1l);
expectedOutput.put("HOT|DISK:3(HOT)", 1l);
expectedOutput.put("HOT|DISK:4(HOT)", 1l);
Assert.assertEquals(expectedOutput, actualOutput);
}
use of org.apache.hadoop.hdfs.server.blockmanagement.BlockStoragePolicySuite in project hadoop by apache.
the class TestStoragePolicySummary method testMultipleHotsWithDifferentCounts.
@Test
public void testMultipleHotsWithDifferentCounts() {
BlockStoragePolicySuite bsps = BlockStoragePolicySuite.createDefaultSuite();
StoragePolicySummary sts = new StoragePolicySummary(bsps.getAllPolicies());
BlockStoragePolicy hot = bsps.getPolicy("HOT");
sts.add(new StorageType[] { StorageType.DISK }, hot);
sts.add(new StorageType[] { StorageType.DISK, StorageType.DISK }, hot);
sts.add(new StorageType[] { StorageType.DISK, StorageType.DISK }, hot);
sts.add(new StorageType[] { StorageType.DISK, StorageType.DISK, StorageType.DISK }, hot);
sts.add(new StorageType[] { StorageType.DISK, StorageType.DISK, StorageType.DISK }, hot);
sts.add(new StorageType[] { StorageType.DISK, StorageType.DISK, StorageType.DISK, StorageType.DISK }, hot);
Map<String, Long> actualOutput = convertToStringMap(sts);
Assert.assertEquals(4, actualOutput.size());
Map<String, Long> expectedOutput = new HashMap<>();
expectedOutput.put("HOT|DISK:1(HOT)", 1l);
expectedOutput.put("HOT|DISK:2(HOT)", 2l);
expectedOutput.put("HOT|DISK:3(HOT)", 2l);
expectedOutput.put("HOT|DISK:4(HOT)", 1l);
Assert.assertEquals(expectedOutput, actualOutput);
}
Aggregations