|
@@ -25,6 +25,7 @@ import org.apache.hadoop.hdfs.server.datanode.BlockScanner;
|
|
|
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference;
|
|
|
import org.apache.hadoop.hdfs.server.datanode.fsdataset.RoundRobinVolumeChoosingPolicy;
|
|
|
import org.apache.hadoop.hdfs.server.datanode.fsdataset.VolumeChoosingPolicy;
|
|
|
+import org.apache.hadoop.util.StringUtils;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.Test;
|
|
|
import org.mockito.Mockito;
|
|
@@ -159,4 +160,37 @@ public class TestFsVolumeList {
|
|
|
assertEquals(expectedNonDfsUsage, spyVolume.getNonDfsUsed());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testDfsReservedForDifferentStorageTypes() throws IOException {
|
|
|
+ Configuration conf = new Configuration();
|
|
|
+ conf.setLong(DFSConfigKeys.DFS_DATANODE_DU_RESERVED_KEY, 100L);
|
|
|
+
|
|
|
+ File volDir = new File(baseDir, "volume-0");
|
|
|
+ volDir.mkdirs();
|
|
|
+ // when storage type reserved is not configured,should consider
|
|
|
+ // dfs.datanode.du.reserved.
|
|
|
+ FsVolumeImpl volume = new FsVolumeImpl(dataset, "storage-id", volDir, conf,
|
|
|
+ StorageType.RAM_DISK);
|
|
|
+ assertEquals("", 100L, volume.getReserved());
|
|
|
+ // when storage type reserved is configured.
|
|
|
+ conf.setLong(
|
|
|
+ DFSConfigKeys.DFS_DATANODE_DU_RESERVED_KEY + "."
|
|
|
+ + StringUtils.toLowerCase(StorageType.RAM_DISK.toString()), 1L);
|
|
|
+ conf.setLong(
|
|
|
+ DFSConfigKeys.DFS_DATANODE_DU_RESERVED_KEY + "."
|
|
|
+ + StringUtils.toLowerCase(StorageType.SSD.toString()), 2L);
|
|
|
+ FsVolumeImpl volume1 = new FsVolumeImpl(dataset, "storage-id", volDir,
|
|
|
+ conf, StorageType.RAM_DISK);
|
|
|
+ assertEquals("", 1L, volume1.getReserved());
|
|
|
+ FsVolumeImpl volume2 = new FsVolumeImpl(dataset, "storage-id", volDir,
|
|
|
+ conf, StorageType.SSD);
|
|
|
+ assertEquals("", 2L, volume2.getReserved());
|
|
|
+ FsVolumeImpl volume3 = new FsVolumeImpl(dataset, "storage-id", volDir,
|
|
|
+ conf, StorageType.DISK);
|
|
|
+ assertEquals("", 100L, volume3.getReserved());
|
|
|
+ FsVolumeImpl volume4 = new FsVolumeImpl(dataset, "storage-id", volDir,
|
|
|
+ conf, StorageType.DEFAULT);
|
|
|
+ assertEquals("", 100L, volume4.getReserved());
|
|
|
+ }
|
|
|
+
|
|
|
}
|