use of org.apache.hadoop.hdfs.MiniDFSNNTopology.NSConf in project hadoop by apache.
the class TestRefreshNamenodes method testRefreshNamenodes.
@Test
public void testRefreshNamenodes() throws IOException {
// Start cluster with a single NN and DN
Configuration conf = new Configuration();
MiniDFSCluster cluster = null;
try {
MiniDFSNNTopology topology = new MiniDFSNNTopology().addNameservice(new NSConf("ns1").addNN(new NNConf(null).setIpcPort(nnPort1))).setFederation(true);
cluster = new MiniDFSCluster.Builder(conf).nnTopology(topology).build();
DataNode dn = cluster.getDataNodes().get(0);
assertEquals(1, dn.getAllBpOs().size());
cluster.addNameNode(conf, nnPort2);
assertEquals(2, dn.getAllBpOs().size());
cluster.addNameNode(conf, nnPort3);
assertEquals(3, dn.getAllBpOs().size());
cluster.addNameNode(conf, nnPort4);
// Ensure a BPOfferService in the datanodes corresponds to
// a namenode in the cluster
Set<InetSocketAddress> nnAddrsFromCluster = Sets.newHashSet();
for (int i = 0; i < 4; i++) {
assertTrue(nnAddrsFromCluster.add(cluster.getNameNode(i).getNameNodeAddress()));
}
Set<InetSocketAddress> nnAddrsFromDN = Sets.newHashSet();
for (BPOfferService bpos : dn.getAllBpOs()) {
for (BPServiceActor bpsa : bpos.getBPServiceActors()) {
assertTrue(nnAddrsFromDN.add(bpsa.getNNSocketAddress()));
}
}
assertEquals("", Joiner.on(",").join(Sets.symmetricDifference(nnAddrsFromCluster, nnAddrsFromDN)));
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
Aggregations