Java Code Examples for org.apache.hadoop.hdfs.MiniDFSCluster#addNameNode()
The following examples show how to use
org.apache.hadoop.hdfs.MiniDFSCluster#addNameNode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestDataNodeMultipleRegistrations.java From RDFS with Apache License 2.0 | 6 votes |
@Test public void testAddingNewNameNodeToNonFederatedCluster() throws IOException { // 3. start non-federate Configuration conf = new Configuration(); MiniDFSCluster cluster = new MiniDFSCluster(0, conf, 1, true, true, null, null); Assert.assertNotNull(cluster); Assert.assertEquals("(2)Should be 1 namenodes", 1, cluster.getNumNameNodes()); // add a node try { cluster.addNameNode(conf, MiniDFSCluster.getFreePort()); Assert.fail("shouldn't be able to add another NN to non federated cluster"); } catch (IOException e) { // correct Assert.assertTrue(e.getMessage().startsWith("cannot add namenode")); Assert.assertEquals("(3)Should be 1 namenodes", 1, cluster.getNumNameNodes()); } finally { cluster.shutdown(); } }
Example 2
Source File: TestDataNodeMultipleRegistrations.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testClusterIdMismatch() throws Exception { MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) .nnTopology(MiniDFSNNTopology.simpleFederatedTopology(2)) .build(); try { cluster.waitActive(); DataNode dn = cluster.getDataNodes().get(0); BPOfferService [] bposs = dn.getAllBpOs(); LOG.info("dn bpos len (should be 2):" + bposs.length); Assert.assertEquals("should've registered with two namenodes", bposs.length,2); // add another namenode cluster.addNameNode(conf, 9938); Thread.sleep(500);// lets wait for the registration to happen bposs = dn.getAllBpOs(); LOG.info("dn bpos len (should be 3):" + bposs.length); Assert.assertEquals("should've registered with three namenodes", bposs.length,3); // change cluster id and another Namenode StartupOption.FORMAT.setClusterId("DifferentCID"); cluster.addNameNode(conf, 9948); NameNode nn4 = cluster.getNameNode(3); assertNotNull("cannot create nn4", nn4); Thread.sleep(500);// lets wait for the registration to happen bposs = dn.getAllBpOs(); LOG.info("dn bpos len (still should be 3):" + bposs.length); Assert.assertEquals("should've registered with three namenodes", 3, bposs.length); } finally { cluster.shutdown(); } }
Example 3
Source File: TestDataNodeMultipleRegistrations.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testClusterIdMismatch() throws Exception { MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) .nnTopology(MiniDFSNNTopology.simpleFederatedTopology(2)) .build(); try { cluster.waitActive(); DataNode dn = cluster.getDataNodes().get(0); BPOfferService [] bposs = dn.getAllBpOs(); LOG.info("dn bpos len (should be 2):" + bposs.length); Assert.assertEquals("should've registered with two namenodes", bposs.length,2); // add another namenode cluster.addNameNode(conf, 9938); Thread.sleep(500);// lets wait for the registration to happen bposs = dn.getAllBpOs(); LOG.info("dn bpos len (should be 3):" + bposs.length); Assert.assertEquals("should've registered with three namenodes", bposs.length,3); // change cluster id and another Namenode StartupOption.FORMAT.setClusterId("DifferentCID"); cluster.addNameNode(conf, 9948); NameNode nn4 = cluster.getNameNode(3); assertNotNull("cannot create nn4", nn4); Thread.sleep(500);// lets wait for the registration to happen bposs = dn.getAllBpOs(); LOG.info("dn bpos len (still should be 3):" + bposs.length); Assert.assertEquals("should've registered with three namenodes", 3, bposs.length); } finally { cluster.shutdown(); } }
Example 4
Source File: TestRefreshNamenodes.java From hadoop with Apache License 2.0 | 4 votes |
@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().length); cluster.addNameNode(conf, nnPort2); assertEquals(2, dn.getAllBpOs().length); cluster.addNameNode(conf, nnPort3); assertEquals(3, dn.getAllBpOs().length); 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(); } } }
Example 5
Source File: TestRefreshNamenodes.java From big-c with Apache License 2.0 | 4 votes |
@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().length); cluster.addNameNode(conf, nnPort2); assertEquals(2, dn.getAllBpOs().length); cluster.addNameNode(conf, nnPort3); assertEquals(3, dn.getAllBpOs().length); 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(); } } }