HDFS-16345. Fix test case fail in TestBlockStoragePolicy (#3696). Contributed by guophilipse.
Reviewed-by: Akira Ajisaka <aajisaka@apache.org> Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
parent
6ed01585eb
commit
25849ff7b7
@ -1274,23 +1274,29 @@ public void testChooseTargetWithTopology() throws Exception {
|
|||||||
DFSTestUtil.formatNameNode(conf);
|
DFSTestUtil.formatNameNode(conf);
|
||||||
NameNode namenode = new NameNode(conf);
|
NameNode namenode = new NameNode(conf);
|
||||||
|
|
||||||
final BlockManager bm = namenode.getNamesystem().getBlockManager();
|
try {
|
||||||
BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy();
|
final BlockManager bm = namenode.getNamesystem().getBlockManager();
|
||||||
NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology();
|
BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy();
|
||||||
for (DatanodeDescriptor datanode : dataNodes) {
|
NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology();
|
||||||
cluster.add(datanode);
|
for (DatanodeDescriptor datanode : dataNodes) {
|
||||||
}
|
cluster.add(datanode);
|
||||||
|
}
|
||||||
|
|
||||||
DatanodeStorageInfo[] targets = replicator.chooseTarget("/foo", 3,
|
DatanodeStorageInfo[] targets = replicator.chooseTarget("/foo", 3,
|
||||||
dataNodes[0], Collections.<DatanodeStorageInfo>emptyList(), false,
|
dataNodes[0], Collections.<DatanodeStorageInfo>emptyList(), false,
|
||||||
new HashSet<Node>(), 0, policy1, null);
|
new HashSet<Node>(), 0, policy1, null);
|
||||||
System.out.println(Arrays.asList(targets));
|
System.out.println(Arrays.asList(targets));
|
||||||
Assert.assertEquals(3, targets.length);
|
Assert.assertEquals(3, targets.length);
|
||||||
targets = replicator.chooseTarget("/foo", 3,
|
targets = replicator.chooseTarget("/foo", 3,
|
||||||
dataNodes[0], Collections.<DatanodeStorageInfo>emptyList(), false,
|
dataNodes[0], Collections.<DatanodeStorageInfo>emptyList(), false,
|
||||||
new HashSet<Node>(), 0, policy2, null);
|
new HashSet<Node>(), 0, policy2, null);
|
||||||
System.out.println(Arrays.asList(targets));
|
System.out.println(Arrays.asList(targets));
|
||||||
Assert.assertEquals(3, targets.length);
|
Assert.assertEquals(3, targets.length);
|
||||||
|
} finally {
|
||||||
|
if (namenode != null) {
|
||||||
|
namenode.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -1321,20 +1327,26 @@ public void testChooseSsdOverDisk() throws Exception {
|
|||||||
DFSTestUtil.formatNameNode(conf);
|
DFSTestUtil.formatNameNode(conf);
|
||||||
NameNode namenode = new NameNode(conf);
|
NameNode namenode = new NameNode(conf);
|
||||||
|
|
||||||
final BlockManager bm = namenode.getNamesystem().getBlockManager();
|
try {
|
||||||
BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy();
|
final BlockManager bm = namenode.getNamesystem().getBlockManager();
|
||||||
NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology();
|
BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy();
|
||||||
for (DatanodeDescriptor datanode : dataNodes) {
|
NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology();
|
||||||
cluster.add(datanode);
|
for (DatanodeDescriptor datanode : dataNodes) {
|
||||||
}
|
cluster.add(datanode);
|
||||||
|
}
|
||||||
|
|
||||||
DatanodeStorageInfo[] targets = replicator.chooseTarget("/foo", 3,
|
DatanodeStorageInfo[] targets = replicator.chooseTarget("/foo", 3,
|
||||||
dataNodes[0], Collections.<DatanodeStorageInfo>emptyList(), false,
|
dataNodes[0], Collections.<DatanodeStorageInfo>emptyList(), false,
|
||||||
new HashSet<Node>(), 0, policy, null);
|
new HashSet<Node>(), 0, policy, null);
|
||||||
System.out.println(policy.getName() + ": " + Arrays.asList(targets));
|
System.out.println(policy.getName() + ": " + Arrays.asList(targets));
|
||||||
Assert.assertEquals(2, targets.length);
|
Assert.assertEquals(2, targets.length);
|
||||||
Assert.assertEquals(StorageType.SSD, targets[0].getStorageType());
|
Assert.assertEquals(StorageType.SSD, targets[0].getStorageType());
|
||||||
Assert.assertEquals(StorageType.DISK, targets[1].getStorageType());
|
Assert.assertEquals(StorageType.DISK, targets[1].getStorageType());
|
||||||
|
} finally {
|
||||||
|
if (namenode != null) {
|
||||||
|
namenode.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1374,20 +1386,26 @@ public void testAddDatanode2ExistingPipelineInSsd() throws Exception {
|
|||||||
DFSTestUtil.formatNameNode(conf);
|
DFSTestUtil.formatNameNode(conf);
|
||||||
NameNode namenode = new NameNode(conf);
|
NameNode namenode = new NameNode(conf);
|
||||||
|
|
||||||
final BlockManager bm = namenode.getNamesystem().getBlockManager();
|
try {
|
||||||
BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy();
|
final BlockManager bm = namenode.getNamesystem().getBlockManager();
|
||||||
NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology();
|
BlockPlacementPolicy replicator = bm.getBlockPlacementPolicy();
|
||||||
for (DatanodeDescriptor datanode : dataNodes) {
|
NetworkTopology cluster = bm.getDatanodeManager().getNetworkTopology();
|
||||||
cluster.add(datanode);
|
for (DatanodeDescriptor datanode : dataNodes) {
|
||||||
|
cluster.add(datanode);
|
||||||
|
}
|
||||||
|
// chsenDs are DISK StorageType to simulate not enough SDD Storage
|
||||||
|
List<DatanodeStorageInfo> chsenDs = new ArrayList<>();
|
||||||
|
chsenDs.add(diskStorages[0]);
|
||||||
|
chsenDs.add(diskStorages[1]);
|
||||||
|
DatanodeStorageInfo[] targets = replicator.chooseTarget("/foo", 1,
|
||||||
|
null, chsenDs, true,
|
||||||
|
new HashSet<Node>(), 0, policy, null);
|
||||||
|
Assert.assertEquals(3, targets.length);
|
||||||
|
} finally {
|
||||||
|
if (namenode != null) {
|
||||||
|
namenode.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// chsenDs are DISK StorageType to simulate not enough SDD Storage
|
|
||||||
List<DatanodeStorageInfo> chsenDs = new ArrayList<>();
|
|
||||||
chsenDs.add(diskStorages[0]);
|
|
||||||
chsenDs.add(diskStorages[1]);
|
|
||||||
DatanodeStorageInfo[] targets = replicator.chooseTarget("/foo", 1,
|
|
||||||
null, chsenDs, true,
|
|
||||||
new HashSet<Node>(), 0, policy, null);
|
|
||||||
Assert.assertEquals(3, targets.length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user