HDFS-14936. Add getNumOfChildren() for interface InnerNode. Contributed by Lisheng Sun.
This commit is contained in:
parent
8c9173c87c
commit
d9fbedc4ae
|
@ -47,6 +47,9 @@ public interface InnerNode extends Node {
|
|||
/** @return its children */
|
||||
List<Node> getChildren();
|
||||
|
||||
/** @return the number of children this node has. */
|
||||
int getNumOfChildren();
|
||||
|
||||
/** @return the number of leave nodes. */
|
||||
int getNumOfLeaves();
|
||||
|
||||
|
|
|
@ -59,7 +59,8 @@ public class InnerNodeImpl extends NodeBase implements InnerNode {
|
|||
}
|
||||
|
||||
/** @return the number of children this node has. */
|
||||
int getNumOfChildren() {
|
||||
@Override
|
||||
public int getNumOfChildren() {
|
||||
return children.size();
|
||||
}
|
||||
|
||||
|
|
|
@ -109,10 +109,6 @@ public class DFSTopologyNodeImpl extends InnerNodeImpl {
|
|||
}
|
||||
}
|
||||
|
||||
int getNumOfChildren() {
|
||||
return children.size();
|
||||
}
|
||||
|
||||
private void incStorageTypeCount(StorageType type) {
|
||||
// no locking because the caller is synchronized already
|
||||
if (storageTypeCounts.containsKey(type)) {
|
||||
|
|
|
@ -351,6 +351,10 @@ public class TestNetworkTopology {
|
|||
|
||||
@Test
|
||||
public void testRemove() throws Exception {
|
||||
// this cluster topology is:
|
||||
// /d1/r1, /d1/r2, /d2/r3, /d3/r1, /d3/r2, /d4/r1
|
||||
// so root "" has four children
|
||||
assertEquals(4, cluster.clusterMap.getNumOfChildren());
|
||||
for(int i=0; i<dataNodes.length; i++) {
|
||||
cluster.remove(dataNodes[i]);
|
||||
}
|
||||
|
@ -359,6 +363,7 @@ public class TestNetworkTopology {
|
|||
}
|
||||
assertEquals(0, cluster.getNumOfLeaves());
|
||||
assertEquals(0, cluster.clusterMap.getChildren().size());
|
||||
assertEquals(0, cluster.clusterMap.getNumOfChildren());
|
||||
for(int i=0; i<dataNodes.length; i++) {
|
||||
cluster.add(dataNodes[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue