/** * @param addr rpc address of the namenode * @return true if the datanode is connected to a NameNode at the * given address */ public boolean isConnectedToNN(InetSocketAddress addr) { for (BPOfferService bpos : getAllBpOs()) { for (BPServiceActor bpsa : bpos.getBPServiceActors()) { if (addr.equals(bpsa.getNNSocketAddress())) { return bpsa.isAlive(); } } } return false; }
/** * @param addr rpc address of the namenode * @return true if the datanode is connected to a NameNode at the * given address */ public boolean isConnectedToNN(InetSocketAddress addr) { for (BPOfferService bpos : getAllBpOs()) { for (BPServiceActor bpsa : bpos.getBPServiceActors()) { if (addr.equals(bpsa.getNNSocketAddress())) { return bpsa.isAlive(); } } } return false; }
/** * @param addr rpc address of the namenode * @return true if the datanode is connected to a NameNode at the * given address */ public boolean isConnectedToNN(InetSocketAddress addr) { for (BPOfferService bpos : getAllBpOs()) { for (BPServiceActor bpsa : bpos.getBPServiceActors()) { if (addr.equals(bpsa.getNNSocketAddress())) { return bpsa.isAlive(); } } } return false; }
public static void triggerDeletionReport(DataNode dn) throws IOException { for (BPOfferService bpos : dn.getAllBpOs()) { bpos.triggerDeletionReportForTests(); } }
public static void triggerHeartbeat(DataNode dn) throws IOException { for (BPOfferService bpos : dn.getAllBpOs()) { bpos.triggerHeartbeatForTests(); } }
public static void triggerBlockReport(DataNode dn) throws IOException { for (BPOfferService bpos : dn.getAllBpOs()) { bpos.triggerBlockReportForTests(); } }
private void stopBPServiceThreads(int numStopThreads, DataNode dn) throws Exception { BPOfferService[] bpoList = dn.getAllBpOs(); int expected = dn.getBpOsCount() - numStopThreads; int index = numStopThreads - 1; while (index >= 0) { bpoList[index--].stop(); } int iterations = 3000; // Total 30 seconds MAX wait time while(dn.getBpOsCount() != expected && iterations > 0) { Thread.sleep(WAIT_TIME_IN_MILLIS); iterations--; } assertEquals("Mismatch in number of BPServices running", expected, dn.getBpOsCount()); }
dn.getAllBpOs()[0].triggerHeartbeatForTests();
@Before public void startCluster() throws IOException { conf = new HdfsConfiguration(); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(DN_COUNT).build(); singletonNn = cluster.getNameNode(); singletonDn = cluster.getDataNodes().get(0); bpos = singletonDn.getAllBpOs()[0]; actor = bpos.getBPServiceActors().get(0); storageUuid = singletonDn.getFSDataset().getVolumes().get(0).getStorageID(); }
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); bposs = dn.getAllBpOs(); LOG.info("dn bpos len (should be 3):" + bposs.length); Assert.assertEquals("should've registered with three namenodes", bposs.length,3); 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);
for (BPOfferService thisBpos : dn.getAllBpOs()) { if (thisBpos.getBlockPoolId().equals(bpid)) { bpos = thisBpos;
DataNode datanode = cluster.getDataNodes().get(0); BPServiceActor actor = datanode.getAllBpOs()[0].getBPServiceActors().get(0); String storageUuid = datanode.getFSDataset().getVolumes().get(0).getStorageID();
assertEquals(1, dn.getAllBpOs().length); assertEquals(2, dn.getAllBpOs().length); assertEquals(3, dn.getAllBpOs().length); for (BPOfferService bpos : dn.getAllBpOs()) { for (BPServiceActor bpsa : bpos.getBPServiceActors()) { assertTrue(nnAddrsFromDN.add(bpsa.getNNSocketAddress()));
int blocksProcessed = 0, savedBlocksProcessed = 0; try { BPOfferService bpos[] = ctx.datanode.getAllBpOs(); assertEquals(1, bpos.length); BlockIterator iter = volume.newBlockIterator(ctx.bpids[0], "test");
for (BPOfferService bpos : dn.getAllBpOs()) { LOG.info("reg: bpid=" + "; name=" + bpos.bpRegistration + "; sid=" + bpos.bpRegistration.getDatanodeUuid() + "; nna=" + BPOfferService bpos1 = dn.getAllBpOs()[0]; bpos1.triggerBlockReportForTests(); assertEquals(0, dn.getAllBpOs().length); cluster = null; } finally {
for (BPOfferService bpos : dn.getAllBpOs()) { LOG.info("BP: " + bpos); BPOfferService bpos1 = dn.getAllBpOs()[0]; BPOfferService bpos2 = dn.getAllBpOs()[1];
nn1Conf.set(DFSConfigKeys.DFS_NAMESERVICES, "namesServerId1"); dn1.refreshNamenodes(nn1Conf); assertEquals(1, dn1.getAllBpOs().length);
nn1Conf.set(DFSConfigKeys.DFS_NAMESERVICES, "namesServerId2"); dn1.refreshNamenodes(nn1Conf); assertEquals(1, dn1.getAllBpOs().length); assertEquals(1, dn2.getAllBpOs().length);
@Test(timeout = 20000) public void testClusterIdMismatchAtStartupWithHA() throws Exception { MiniDFSNNTopology top = new MiniDFSNNTopology() .addNameservice(new MiniDFSNNTopology.NSConf("ns1") .addNN(new MiniDFSNNTopology.NNConf("nn0")) .addNN(new MiniDFSNNTopology.NNConf("nn1"))) .addNameservice(new MiniDFSNNTopology.NSConf("ns2") .addNN(new MiniDFSNNTopology.NNConf("nn2").setClusterId("bad-cid")) .addNN(new MiniDFSNNTopology.NNConf("nn3").setClusterId("bad-cid"))); top.setFederation(true); MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).nnTopology(top) .numDataNodes(0).build(); try { cluster.startDataNodes(conf, 1, true, null, null); // let the initialization be complete Thread.sleep(10000); DataNode dn = cluster.getDataNodes().get(0); assertTrue("Datanode should be running", dn.isDatanodeUp()); assertEquals("Only one BPOfferService should be running", 1, dn.getAllBpOs().length); } finally { cluster.shutdown(); } }
assertTrue("Datanode should be running", dn.isDatanodeUp()); assertEquals("BPOfferService should be running", 1, dn.getAllBpOs().length); DataNodeProperties dnProp = cluster.stopDataNode(0);