Search in sources :

Example 1 with NSConf

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();
        }
    }
}
Also used : NNConf(org.apache.hadoop.hdfs.MiniDFSNNTopology.NNConf) NSConf(org.apache.hadoop.hdfs.MiniDFSNNTopology.NSConf) MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) Configuration(org.apache.hadoop.conf.Configuration) InetSocketAddress(java.net.InetSocketAddress) MiniDFSNNTopology(org.apache.hadoop.hdfs.MiniDFSNNTopology) Test(org.junit.Test)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 Configuration (org.apache.hadoop.conf.Configuration)1 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)1 MiniDFSNNTopology (org.apache.hadoop.hdfs.MiniDFSNNTopology)1 NNConf (org.apache.hadoop.hdfs.MiniDFSNNTopology.NNConf)1 NSConf (org.apache.hadoop.hdfs.MiniDFSNNTopology.NSConf)1 Test (org.junit.Test)1