|
@@ -64,37 +64,43 @@ public class TestDFSNetworkTopology {
|
|
final String[] racks = {
|
|
final String[] racks = {
|
|
"/l1/d1/r1", "/l1/d1/r1", "/l1/d1/r2", "/l1/d1/r2", "/l1/d1/r2",
|
|
"/l1/d1/r1", "/l1/d1/r1", "/l1/d1/r2", "/l1/d1/r2", "/l1/d1/r2",
|
|
|
|
|
|
- "/l1/d2/r3", "/l1/d2/r3", "/l1/d2/r3",
|
|
|
|
|
|
+ "/l1/d2/r3", "/l1/d2/r3", "/l1/d2/r3", "/l1/d2/r3",
|
|
|
|
|
|
"/l2/d3/r1", "/l2/d3/r2", "/l2/d3/r3", "/l2/d3/r4", "/l2/d3/r5",
|
|
"/l2/d3/r1", "/l2/d3/r2", "/l2/d3/r3", "/l2/d3/r4", "/l2/d3/r5",
|
|
|
|
|
|
"/l2/d4/r1", "/l2/d4/r1", "/l2/d4/r1", "/l2/d4/r1", "/l2/d4/r1",
|
|
"/l2/d4/r1", "/l2/d4/r1", "/l2/d4/r1", "/l2/d4/r1", "/l2/d4/r1",
|
|
- "/l2/d4/r1", "/l2/d4/r1"};
|
|
|
|
|
|
+ "/l2/d4/r1", "/l2/d4/r1", "/l2/d4/r2",
|
|
|
|
+
|
|
|
|
+ "/l3/d5/r1", "/l3/d5/r1", "/l3/d5/r2"};
|
|
final String[] hosts = {
|
|
final String[] hosts = {
|
|
"host1", "host2", "host3", "host4", "host5",
|
|
"host1", "host2", "host3", "host4", "host5",
|
|
- "host6", "host7", "host8",
|
|
|
|
- "host9", "host10", "host11", "host12", "host13",
|
|
|
|
- "host14", "host15", "host16", "host17", "host18", "host19", "host20"};
|
|
|
|
|
|
+ "host6", "host7", "host8", "host9",
|
|
|
|
+ "host10", "host11", "host12", "host13", "host14",
|
|
|
|
+ "host15", "host16", "host17", "host18", "host19", "host20",
|
|
|
|
+ "host21", "host22", "host23", "host24", "host25"};
|
|
final StorageType[] types = {
|
|
final StorageType[] types = {
|
|
StorageType.ARCHIVE, StorageType.DISK, StorageType.ARCHIVE,
|
|
StorageType.ARCHIVE, StorageType.DISK, StorageType.ARCHIVE,
|
|
StorageType.DISK, StorageType.DISK,
|
|
StorageType.DISK, StorageType.DISK,
|
|
|
|
|
|
StorageType.DISK, StorageType.RAM_DISK, StorageType.SSD,
|
|
StorageType.DISK, StorageType.RAM_DISK, StorageType.SSD,
|
|
|
|
+ StorageType.NVDIMM,
|
|
|
|
|
|
StorageType.DISK, StorageType.RAM_DISK, StorageType.DISK,
|
|
StorageType.DISK, StorageType.RAM_DISK, StorageType.DISK,
|
|
StorageType.ARCHIVE, StorageType.ARCHIVE,
|
|
StorageType.ARCHIVE, StorageType.ARCHIVE,
|
|
|
|
|
|
StorageType.DISK, StorageType.DISK, StorageType.RAM_DISK,
|
|
StorageType.DISK, StorageType.DISK, StorageType.RAM_DISK,
|
|
StorageType.RAM_DISK, StorageType.ARCHIVE, StorageType.ARCHIVE,
|
|
StorageType.RAM_DISK, StorageType.ARCHIVE, StorageType.ARCHIVE,
|
|
- StorageType.SSD};
|
|
|
|
|
|
+ StorageType.SSD, StorageType.NVDIMM,
|
|
|
|
+
|
|
|
|
+ StorageType.NVDIMM, StorageType.ARCHIVE, StorageType.DISK};
|
|
final DatanodeStorageInfo[] storages =
|
|
final DatanodeStorageInfo[] storages =
|
|
- DFSTestUtil.createDatanodeStorageInfos(20, racks, hosts, types);
|
|
|
|
|
|
+ DFSTestUtil.createDatanodeStorageInfos(25, racks, hosts, types);
|
|
dataNodes = DFSTestUtil.toDatanodeDescriptor(storages);
|
|
dataNodes = DFSTestUtil.toDatanodeDescriptor(storages);
|
|
for (int i = 0; i < dataNodes.length; i++) {
|
|
for (int i = 0; i < dataNodes.length; i++) {
|
|
CLUSTER.add(dataNodes[i]);
|
|
CLUSTER.add(dataNodes[i]);
|
|
}
|
|
}
|
|
- dataNodes[9].setDecommissioned();
|
|
|
|
dataNodes[10].setDecommissioned();
|
|
dataNodes[10].setDecommissioned();
|
|
|
|
+ dataNodes[11].setDecommissioned();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -120,10 +126,11 @@ public class TestDFSNetworkTopology {
|
|
HashMap<String, EnumMap<StorageType, Integer>> d2info =
|
|
HashMap<String, EnumMap<StorageType, Integer>> d2info =
|
|
d2.getChildrenStorageInfo();
|
|
d2.getChildrenStorageInfo();
|
|
assertEquals(1, d2info.keySet().size());
|
|
assertEquals(1, d2info.keySet().size());
|
|
- assertTrue(d2info.get("r3").size() == 3);
|
|
|
|
|
|
+ assertEquals(4, d2info.get("r3").size());
|
|
assertEquals(1, (int)d2info.get("r3").get(StorageType.DISK));
|
|
assertEquals(1, (int)d2info.get("r3").get(StorageType.DISK));
|
|
assertEquals(1, (int)d2info.get("r3").get(StorageType.RAM_DISK));
|
|
assertEquals(1, (int)d2info.get("r3").get(StorageType.RAM_DISK));
|
|
assertEquals(1, (int)d2info.get("r3").get(StorageType.SSD));
|
|
assertEquals(1, (int)d2info.get("r3").get(StorageType.SSD));
|
|
|
|
+ assertEquals(1, (int)d2info.get("r3").get(StorageType.NVDIMM));
|
|
|
|
|
|
DFSTopologyNodeImpl d3 =
|
|
DFSTopologyNodeImpl d3 =
|
|
(DFSTopologyNodeImpl) CLUSTER.getNode("/l2/d3");
|
|
(DFSTopologyNodeImpl) CLUSTER.getNode("/l2/d3");
|
|
@@ -140,11 +147,23 @@ public class TestDFSNetworkTopology {
|
|
(DFSTopologyNodeImpl) CLUSTER.getNode("/l2/d4");
|
|
(DFSTopologyNodeImpl) CLUSTER.getNode("/l2/d4");
|
|
HashMap<String, EnumMap<StorageType, Integer>> d4info =
|
|
HashMap<String, EnumMap<StorageType, Integer>> d4info =
|
|
d4.getChildrenStorageInfo();
|
|
d4.getChildrenStorageInfo();
|
|
- assertEquals(1, d4info.keySet().size());
|
|
|
|
|
|
+ assertEquals(2, d4info.keySet().size());
|
|
assertEquals(2, (int)d4info.get("r1").get(StorageType.DISK));
|
|
assertEquals(2, (int)d4info.get("r1").get(StorageType.DISK));
|
|
assertEquals(2, (int)d4info.get("r1").get(StorageType.RAM_DISK));
|
|
assertEquals(2, (int)d4info.get("r1").get(StorageType.RAM_DISK));
|
|
assertEquals(2, (int)d4info.get("r1").get(StorageType.ARCHIVE));
|
|
assertEquals(2, (int)d4info.get("r1").get(StorageType.ARCHIVE));
|
|
assertEquals(1, (int)d4info.get("r1").get(StorageType.SSD));
|
|
assertEquals(1, (int)d4info.get("r1").get(StorageType.SSD));
|
|
|
|
+ assertEquals(1, (int)d4info.get("r2").get(StorageType.NVDIMM));
|
|
|
|
+
|
|
|
|
+ DFSTopologyNodeImpl d5 =
|
|
|
|
+ (DFSTopologyNodeImpl) CLUSTER.getNode("/l3/d5");
|
|
|
|
+ System.out.println(d5);
|
|
|
|
+ HashMap<String, EnumMap<StorageType, Integer>> d5info =
|
|
|
|
+ d5.getChildrenStorageInfo();
|
|
|
|
+ assertEquals(2, d5info.keySet().size());
|
|
|
|
+ assertEquals(1, (int)d5info.get("r1").get(StorageType.ARCHIVE));
|
|
|
|
+ assertEquals(1, (int)d5info.get("r1").get(StorageType.NVDIMM));
|
|
|
|
+ assertEquals(1, (int)d5info.get("r2").get(StorageType.DISK));
|
|
|
|
+
|
|
|
|
|
|
DFSTopologyNodeImpl l1 =
|
|
DFSTopologyNodeImpl l1 =
|
|
(DFSTopologyNodeImpl) CLUSTER.getNode("/l1");
|
|
(DFSTopologyNodeImpl) CLUSTER.getNode("/l1");
|
|
@@ -152,12 +171,13 @@ public class TestDFSNetworkTopology {
|
|
l1.getChildrenStorageInfo();
|
|
l1.getChildrenStorageInfo();
|
|
assertEquals(2, l1info.keySet().size());
|
|
assertEquals(2, l1info.keySet().size());
|
|
assertTrue(l1info.get("d1").size() == 2
|
|
assertTrue(l1info.get("d1").size() == 2
|
|
- && l1info.get("d2").size() == 3);
|
|
|
|
|
|
+ && l1info.get("d2").size() == 4);
|
|
assertEquals(2, (int)l1info.get("d1").get(StorageType.ARCHIVE));
|
|
assertEquals(2, (int)l1info.get("d1").get(StorageType.ARCHIVE));
|
|
assertEquals(3, (int)l1info.get("d1").get(StorageType.DISK));
|
|
assertEquals(3, (int)l1info.get("d1").get(StorageType.DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.RAM_DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.RAM_DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.SSD));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.SSD));
|
|
|
|
+ assertEquals(1, (int)l1info.get("d2").get(StorageType.NVDIMM));
|
|
|
|
|
|
// checking level = 1 nodes
|
|
// checking level = 1 nodes
|
|
DFSTopologyNodeImpl l2 =
|
|
DFSTopologyNodeImpl l2 =
|
|
@@ -165,7 +185,7 @@ public class TestDFSNetworkTopology {
|
|
HashMap<String, EnumMap<StorageType, Integer>> l2info =
|
|
HashMap<String, EnumMap<StorageType, Integer>> l2info =
|
|
l2.getChildrenStorageInfo();
|
|
l2.getChildrenStorageInfo();
|
|
assertTrue(l2info.get("d3").size() == 3
|
|
assertTrue(l2info.get("d3").size() == 3
|
|
- && l2info.get("d4").size() == 4);
|
|
|
|
|
|
+ && l2info.get("d4").size() == 5);
|
|
assertEquals(2, l2info.keySet().size());
|
|
assertEquals(2, l2info.keySet().size());
|
|
assertEquals(2, (int)l2info.get("d3").get(StorageType.DISK));
|
|
assertEquals(2, (int)l2info.get("d3").get(StorageType.DISK));
|
|
assertEquals(2, (int)l2info.get("d3").get(StorageType.ARCHIVE));
|
|
assertEquals(2, (int)l2info.get("d3").get(StorageType.ARCHIVE));
|
|
@@ -174,6 +194,17 @@ public class TestDFSNetworkTopology {
|
|
assertEquals(2, (int)l2info.get("d4").get(StorageType.ARCHIVE));
|
|
assertEquals(2, (int)l2info.get("d4").get(StorageType.ARCHIVE));
|
|
assertEquals(2, (int)l2info.get("d4").get(StorageType.RAM_DISK));
|
|
assertEquals(2, (int)l2info.get("d4").get(StorageType.RAM_DISK));
|
|
assertEquals(1, (int)l2info.get("d4").get(StorageType.SSD));
|
|
assertEquals(1, (int)l2info.get("d4").get(StorageType.SSD));
|
|
|
|
+ assertEquals(1, (int)l2info.get("d4").get(StorageType.NVDIMM));
|
|
|
|
+
|
|
|
|
+ DFSTopologyNodeImpl l3 =
|
|
|
|
+ (DFSTopologyNodeImpl) CLUSTER.getNode("/l3");
|
|
|
|
+ HashMap<String, EnumMap<StorageType, Integer>> l3info =
|
|
|
|
+ l3.getChildrenStorageInfo();
|
|
|
|
+ assertTrue(l3info.get("d5").size() == 3);
|
|
|
|
+ assertEquals(1, l3info.keySet().size());
|
|
|
|
+ assertEquals(1, (int)l3info.get("d5").get(StorageType.NVDIMM));
|
|
|
|
+ assertEquals(1, (int)l3info.get("d5").get(StorageType.ARCHIVE));
|
|
|
|
+ assertEquals(1, (int)l3info.get("d5").get(StorageType.DISK));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -182,15 +213,16 @@ public class TestDFSNetworkTopology {
|
|
*/
|
|
*/
|
|
@Test
|
|
@Test
|
|
public void testAddAndRemoveTopology() throws Exception {
|
|
public void testAddAndRemoveTopology() throws Exception {
|
|
- String[] newRack = {"/l1/d1/r1", "/l1/d1/r3", "/l1/d3/r3", "/l1/d3/r3"};
|
|
|
|
- String[] newHost = {"nhost1", "nhost2", "nhost3", "nhost4"};
|
|
|
|
|
|
+ String[] newRack = {"/l1/d1/r1", "/l1/d1/r3", "/l1/d3/r3", "/l1/d3/r3",
|
|
|
|
+ "/l1/d3/r4"};
|
|
|
|
+ String[] newHost = {"nhost1", "nhost2", "nhost3", "nhost4", "nhost5"};
|
|
String[] newips = {"30.30.30.30", "31.31.31.31", "32.32.32.32",
|
|
String[] newips = {"30.30.30.30", "31.31.31.31", "32.32.32.32",
|
|
- "33.33.33.33"};
|
|
|
|
|
|
+ "33.33.33.33", "34.34.34.34"};
|
|
StorageType[] newTypes = {StorageType.DISK, StorageType.SSD,
|
|
StorageType[] newTypes = {StorageType.DISK, StorageType.SSD,
|
|
- StorageType.SSD, StorageType.SSD};
|
|
|
|
- DatanodeDescriptor[] newDD = new DatanodeDescriptor[4];
|
|
|
|
|
|
+ StorageType.SSD, StorageType.SSD, StorageType.NVDIMM};
|
|
|
|
+ DatanodeDescriptor[] newDD = new DatanodeDescriptor[5];
|
|
|
|
|
|
- for (int i = 0; i<4; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
DatanodeStorageInfo dsi = DFSTestUtil.createDatanodeStorageInfo(
|
|
DatanodeStorageInfo dsi = DFSTestUtil.createDatanodeStorageInfo(
|
|
"s" + newHost[i], newips[i], newRack[i], newHost[i],
|
|
"s" + newHost[i], newips[i], newRack[i], newHost[i],
|
|
newTypes[i], null);
|
|
newTypes[i], null);
|
|
@@ -215,9 +247,10 @@ public class TestDFSNetworkTopology {
|
|
(DFSTopologyNodeImpl) CLUSTER.getNode("/l1/d3");
|
|
(DFSTopologyNodeImpl) CLUSTER.getNode("/l1/d3");
|
|
HashMap<String, EnumMap<StorageType, Integer>> d3info =
|
|
HashMap<String, EnumMap<StorageType, Integer>> d3info =
|
|
d3.getChildrenStorageInfo();
|
|
d3.getChildrenStorageInfo();
|
|
- assertEquals(1, d3info.keySet().size());
|
|
|
|
- assertTrue(d3info.get("r3").size() == 1);
|
|
|
|
|
|
+ assertEquals(2, d3info.keySet().size());
|
|
|
|
+ assertTrue(d3info.get("r3").size() == 1 && d3info.get("r4").size() == 1);
|
|
assertEquals(2, (int)d3info.get("r3").get(StorageType.SSD));
|
|
assertEquals(2, (int)d3info.get("r3").get(StorageType.SSD));
|
|
|
|
+ assertEquals(1, (int)d3info.get("r4").get(StorageType.NVDIMM));
|
|
|
|
|
|
DFSTopologyNodeImpl l1 =
|
|
DFSTopologyNodeImpl l1 =
|
|
(DFSTopologyNodeImpl) CLUSTER.getNode("/l1");
|
|
(DFSTopologyNodeImpl) CLUSTER.getNode("/l1");
|
|
@@ -225,7 +258,7 @@ public class TestDFSNetworkTopology {
|
|
l1.getChildrenStorageInfo();
|
|
l1.getChildrenStorageInfo();
|
|
assertEquals(3, l1info.keySet().size());
|
|
assertEquals(3, l1info.keySet().size());
|
|
assertTrue(l1info.get("d1").size() == 3 &&
|
|
assertTrue(l1info.get("d1").size() == 3 &&
|
|
- l1info.get("d2").size() == 3 && l1info.get("d3").size() == 1);
|
|
|
|
|
|
+ l1info.get("d2").size() == 4 && l1info.get("d3").size() == 2);
|
|
assertEquals(4, (int)l1info.get("d1").get(StorageType.DISK));
|
|
assertEquals(4, (int)l1info.get("d1").get(StorageType.DISK));
|
|
assertEquals(2, (int)l1info.get("d1").get(StorageType.ARCHIVE));
|
|
assertEquals(2, (int)l1info.get("d1").get(StorageType.ARCHIVE));
|
|
assertEquals(1, (int)l1info.get("d1").get(StorageType.SSD));
|
|
assertEquals(1, (int)l1info.get("d1").get(StorageType.SSD));
|
|
@@ -233,8 +266,9 @@ public class TestDFSNetworkTopology {
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.RAM_DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.RAM_DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.DISK));
|
|
assertEquals(2, (int)l1info.get("d3").get(StorageType.SSD));
|
|
assertEquals(2, (int)l1info.get("d3").get(StorageType.SSD));
|
|
|
|
+ assertEquals(1, (int)l1info.get("d3").get(StorageType.NVDIMM));
|
|
|
|
|
|
- for (int i = 0; i<4; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
CLUSTER.remove(newDD[i]);
|
|
CLUSTER.remove(newDD[i]);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -257,12 +291,13 @@ public class TestDFSNetworkTopology {
|
|
nl1.getChildrenStorageInfo();
|
|
nl1.getChildrenStorageInfo();
|
|
assertEquals(2, nl1info.keySet().size());
|
|
assertEquals(2, nl1info.keySet().size());
|
|
assertTrue(l1info.get("d1").size() == 2
|
|
assertTrue(l1info.get("d1").size() == 2
|
|
- && l1info.get("d2").size() == 3);
|
|
|
|
|
|
+ && l1info.get("d2").size() == 4);
|
|
assertEquals(2, (int)nl1info.get("d1").get(StorageType.ARCHIVE));
|
|
assertEquals(2, (int)nl1info.get("d1").get(StorageType.ARCHIVE));
|
|
assertEquals(3, (int)nl1info.get("d1").get(StorageType.DISK));
|
|
assertEquals(3, (int)nl1info.get("d1").get(StorageType.DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.RAM_DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.RAM_DISK));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.SSD));
|
|
assertEquals(1, (int)l1info.get("d2").get(StorageType.SSD));
|
|
|
|
+ assertEquals(1, (int)l1info.get("d2").get(StorageType.NVDIMM));
|
|
|
|
|
|
assertNull(CLUSTER.getNode("/l1/d3"));
|
|
assertNull(CLUSTER.getNode("/l1/d3"));
|
|
}
|
|
}
|
|
@@ -278,6 +313,7 @@ public class TestDFSNetworkTopology {
|
|
Set<String> archiveUnderL1 = Sets.newHashSet("host1", "host3");
|
|
Set<String> archiveUnderL1 = Sets.newHashSet("host1", "host3");
|
|
Set<String> ramdiskUnderL1 = Sets.newHashSet("host7");
|
|
Set<String> ramdiskUnderL1 = Sets.newHashSet("host7");
|
|
Set<String> ssdUnderL1 = Sets.newHashSet("host8");
|
|
Set<String> ssdUnderL1 = Sets.newHashSet("host8");
|
|
|
|
+ Set<String> nvdimmUnderL1 = Sets.newHashSet("host9");
|
|
for (int i = 0; i < 10; i++) {
|
|
for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageType("/l1", null, null,
|
|
n = CLUSTER.chooseRandomWithStorageType("/l1", null, null,
|
|
StorageType.DISK);
|
|
StorageType.DISK);
|
|
@@ -319,35 +355,35 @@ public class TestDFSNetworkTopology {
|
|
// exclude the host on r4 (since there is only one host, no randomness here)
|
|
// exclude the host on r4 (since there is only one host, no randomness here)
|
|
excluded.add(n);
|
|
excluded.add(n);
|
|
|
|
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageType("/l2/d3", null, null,
|
|
n = CLUSTER.chooseRandomWithStorageType("/l2/d3", null, null,
|
|
StorageType.ARCHIVE);
|
|
StorageType.ARCHIVE);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
dd = (DatanodeDescriptor) n;
|
|
dd = (DatanodeDescriptor) n;
|
|
- assertTrue(dd.getHostName().equals("host12") ||
|
|
|
|
- dd.getHostName().equals("host13"));
|
|
|
|
|
|
+ assertTrue(dd.getHostName().equals("host13") ||
|
|
|
|
+ dd.getHostName().equals("host14"));
|
|
}
|
|
}
|
|
|
|
|
|
// test exclude nodes
|
|
// test exclude nodes
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageType("/l2/d3", null, excluded,
|
|
n = CLUSTER.chooseRandomWithStorageType("/l2/d3", null, excluded,
|
|
StorageType.ARCHIVE);
|
|
StorageType.ARCHIVE);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
dd = (DatanodeDescriptor) n;
|
|
dd = (DatanodeDescriptor) n;
|
|
- assertTrue(dd.getHostName().equals("host13"));
|
|
|
|
|
|
+ assertTrue(dd.getHostName().equals("host14"));
|
|
}
|
|
}
|
|
|
|
|
|
// test exclude scope
|
|
// test exclude scope
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageType("/l2/d3", "/l2/d3/r4", null,
|
|
n = CLUSTER.chooseRandomWithStorageType("/l2/d3", "/l2/d3/r4", null,
|
|
StorageType.ARCHIVE);
|
|
StorageType.ARCHIVE);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
dd = (DatanodeDescriptor) n;
|
|
dd = (DatanodeDescriptor) n;
|
|
- assertTrue(dd.getHostName().equals("host13"));
|
|
|
|
|
|
+ assertTrue(dd.getHostName().equals("host14"));
|
|
}
|
|
}
|
|
|
|
|
|
// test exclude scope + excluded node with expected null return node
|
|
// test exclude scope + excluded node with expected null return node
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageType("/l2/d3", "/l2/d3/r5", excluded,
|
|
n = CLUSTER.chooseRandomWithStorageType("/l2/d3", "/l2/d3/r5", excluded,
|
|
StorageType.ARCHIVE);
|
|
StorageType.ARCHIVE);
|
|
assertNull(n);
|
|
assertNull(n);
|
|
@@ -361,7 +397,7 @@ public class TestDFSNetworkTopology {
|
|
// exclude the host on r4 (since there is only one host, no randomness here)
|
|
// exclude the host on r4 (since there is only one host, no randomness here)
|
|
excluded.add(n);
|
|
excluded.add(n);
|
|
Set<String> expectedSet = Sets.newHashSet("host4", "host5");
|
|
Set<String> expectedSet = Sets.newHashSet("host4", "host5");
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
// under l1, there are four hosts with DISK:
|
|
// under l1, there are four hosts with DISK:
|
|
// /l1/d1/r1/host2, /l1/d1/r2/host4, /l1/d1/r2/host5 and /l1/d2/r3/host6
|
|
// /l1/d1/r1/host2, /l1/d1/r2/host4, /l1/d1/r2/host5 and /l1/d2/r3/host6
|
|
// host6 is excludedNode, host2 is under excluded range scope /l1/d1/r1
|
|
// host6 is excludedNode, host2 is under excluded range scope /l1/d1/r1
|
|
@@ -403,21 +439,21 @@ public class TestDFSNetworkTopology {
|
|
excluded.add(n);
|
|
excluded.add(n);
|
|
|
|
|
|
// search with given scope being desired scope
|
|
// search with given scope being desired scope
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageType(
|
|
n = CLUSTER.chooseRandomWithStorageType(
|
|
"/l2/d3", null, StorageType.ARCHIVE);
|
|
"/l2/d3", null, StorageType.ARCHIVE);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
dd = (DatanodeDescriptor) n;
|
|
dd = (DatanodeDescriptor) n;
|
|
- assertTrue(dd.getHostName().equals("host12") ||
|
|
|
|
- dd.getHostName().equals("host13"));
|
|
|
|
|
|
+ assertTrue(dd.getHostName().equals("host13") ||
|
|
|
|
+ dd.getHostName().equals("host14"));
|
|
}
|
|
}
|
|
|
|
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageType(
|
|
n = CLUSTER.chooseRandomWithStorageType(
|
|
"/l2/d3", excluded, StorageType.ARCHIVE);
|
|
"/l2/d3", excluded, StorageType.ARCHIVE);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
dd = (DatanodeDescriptor) n;
|
|
dd = (DatanodeDescriptor) n;
|
|
- assertTrue(dd.getHostName().equals("host13"));
|
|
|
|
|
|
+ assertTrue(dd.getHostName().equals("host14"));
|
|
}
|
|
}
|
|
|
|
|
|
// search with given scope being exclude scope
|
|
// search with given scope being exclude scope
|
|
@@ -425,13 +461,13 @@ public class TestDFSNetworkTopology {
|
|
// a total of 4 ramdisk nodes:
|
|
// a total of 4 ramdisk nodes:
|
|
// /l1/d2/r3/host7, /l2/d3/r2/host10, /l2/d4/r1/host7 and /l2/d4/r1/host10
|
|
// /l1/d2/r3/host7, /l2/d3/r2/host10, /l2/d4/r1/host7 and /l2/d4/r1/host10
|
|
// so if we exclude /l2/d4/r1, if should be always either host7 or host10
|
|
// so if we exclude /l2/d4/r1, if should be always either host7 or host10
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageType(
|
|
n = CLUSTER.chooseRandomWithStorageType(
|
|
"~/l2/d4", null, StorageType.RAM_DISK);
|
|
"~/l2/d4", null, StorageType.RAM_DISK);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
dd = (DatanodeDescriptor) n;
|
|
dd = (DatanodeDescriptor) n;
|
|
assertTrue(dd.getHostName().equals("host7") ||
|
|
assertTrue(dd.getHostName().equals("host7") ||
|
|
- dd.getHostName().equals("host10"));
|
|
|
|
|
|
+ dd.getHostName().equals("host11"));
|
|
}
|
|
}
|
|
|
|
|
|
// similar to above, except that we also exclude host10 here. so it should
|
|
// similar to above, except that we also exclude host10 here. so it should
|
|
@@ -440,7 +476,7 @@ public class TestDFSNetworkTopology {
|
|
StorageType.RAM_DISK);
|
|
StorageType.RAM_DISK);
|
|
// add host10 to exclude
|
|
// add host10 to exclude
|
|
excluded.add(n);
|
|
excluded.add(n);
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageType(
|
|
n = CLUSTER.chooseRandomWithStorageType(
|
|
"~/l2/d4", excluded, StorageType.RAM_DISK);
|
|
"~/l2/d4", excluded, StorageType.RAM_DISK);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
@@ -537,21 +573,21 @@ public class TestDFSNetworkTopology {
|
|
excluded.add(n);
|
|
excluded.add(n);
|
|
|
|
|
|
// search with given scope being desired scope
|
|
// search with given scope being desired scope
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageTypeTwoTrial(
|
|
n = CLUSTER.chooseRandomWithStorageTypeTwoTrial(
|
|
"/l2/d3", null, StorageType.ARCHIVE);
|
|
"/l2/d3", null, StorageType.ARCHIVE);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
dd = (DatanodeDescriptor) n;
|
|
dd = (DatanodeDescriptor) n;
|
|
- assertTrue(dd.getHostName().equals("host12") ||
|
|
|
|
- dd.getHostName().equals("host13"));
|
|
|
|
|
|
+ assertTrue(dd.getHostName().equals("host13") ||
|
|
|
|
+ dd.getHostName().equals("host14"));
|
|
}
|
|
}
|
|
|
|
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageTypeTwoTrial(
|
|
n = CLUSTER.chooseRandomWithStorageTypeTwoTrial(
|
|
"/l2/d3", excluded, StorageType.ARCHIVE);
|
|
"/l2/d3", excluded, StorageType.ARCHIVE);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
dd = (DatanodeDescriptor) n;
|
|
dd = (DatanodeDescriptor) n;
|
|
- assertTrue(dd.getHostName().equals("host13"));
|
|
|
|
|
|
+ assertTrue(dd.getHostName().equals("host14"));
|
|
}
|
|
}
|
|
|
|
|
|
// search with given scope being exclude scope
|
|
// search with given scope being exclude scope
|
|
@@ -559,13 +595,13 @@ public class TestDFSNetworkTopology {
|
|
// a total of 4 ramdisk nodes:
|
|
// a total of 4 ramdisk nodes:
|
|
// /l1/d2/r3/host7, /l2/d3/r2/host10, /l2/d4/r1/host7 and /l2/d4/r1/host10
|
|
// /l1/d2/r3/host7, /l2/d3/r2/host10, /l2/d4/r1/host7 and /l2/d4/r1/host10
|
|
// so if we exclude /l2/d4/r1, if should be always either host7 or host10
|
|
// so if we exclude /l2/d4/r1, if should be always either host7 or host10
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageTypeTwoTrial(
|
|
n = CLUSTER.chooseRandomWithStorageTypeTwoTrial(
|
|
"~/l2/d4", null, StorageType.RAM_DISK);
|
|
"~/l2/d4", null, StorageType.RAM_DISK);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
dd = (DatanodeDescriptor) n;
|
|
dd = (DatanodeDescriptor) n;
|
|
assertTrue(dd.getHostName().equals("host7") ||
|
|
assertTrue(dd.getHostName().equals("host7") ||
|
|
- dd.getHostName().equals("host10"));
|
|
|
|
|
|
+ dd.getHostName().equals("host11"));
|
|
}
|
|
}
|
|
|
|
|
|
// similar to above, except that we also exclude host10 here. so it should
|
|
// similar to above, except that we also exclude host10 here. so it should
|
|
@@ -574,7 +610,7 @@ public class TestDFSNetworkTopology {
|
|
StorageType.RAM_DISK);
|
|
StorageType.RAM_DISK);
|
|
// add host10 to exclude
|
|
// add host10 to exclude
|
|
excluded.add(n);
|
|
excluded.add(n);
|
|
- for (int i = 0; i<10; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
n = CLUSTER.chooseRandomWithStorageTypeTwoTrial(
|
|
n = CLUSTER.chooseRandomWithStorageTypeTwoTrial(
|
|
"~/l2/d4", excluded, StorageType.RAM_DISK);
|
|
"~/l2/d4", excluded, StorageType.RAM_DISK);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|
|
assertTrue(n instanceof DatanodeDescriptor);
|