/** * Get the NameNode corresponding to the given block pool. * * @param bpid Block pool Id * @return Namenode corresponding to the bpid * @throws IOException if unable to get the corresponding NameNode */ DatanodeProtocolClientSideTranslatorPB getActiveNamenodeForBP( String bpid) throws IOException { BPOfferService bpos = datanode.getBPOfferService(bpid); if (bpos == null) { throw new IOException("No block pool offer service for bpid=" + bpid); } DatanodeProtocolClientSideTranslatorPB activeNN = bpos.getActiveNN(); if (activeNN == null) { throw new IOException( "Block pool " + bpid + " has not recognized an active NN"); } return activeNN; }
/** * Get the NameNode corresponding to the given block pool. * * @param bpid Block pool Id * @return Namenode corresponding to the bpid * @throws IOException if unable to get the corresponding NameNode */ public DatanodeProtocolClientSideTranslatorPB getActiveNamenodeForBP(String bpid) throws IOException { BPOfferService bpos = blockPoolManager.get(bpid); if (bpos == null) { throw new IOException("No block pool offer service for bpid=" + bpid); } DatanodeProtocolClientSideTranslatorPB activeNN = bpos.getActiveNN(); if (activeNN == null) { throw new IOException( "Block pool " + bpid + " has not recognized an active NN"); } return activeNN; }
/** * Get the NameNode corresponding to the given block pool. * * @param bpid Block pool Id * @return Namenode corresponding to the bpid * @throws IOException if unable to get the corresponding NameNode */ public DatanodeProtocolClientSideTranslatorPB getActiveNamenodeForBP(String bpid) throws IOException { BPOfferService bpos = blockPoolManager.get(bpid); if (bpos == null) { throw new IOException("No block pool offer service for bpid=" + bpid); } DatanodeProtocolClientSideTranslatorPB activeNN = bpos.getActiveNN(); if (activeNN == null) { throw new IOException( "Block pool " + bpid + " has not recognized an active NN"); } return activeNN; }
waitForInitialization(bpos); assertNull(bpos.getActiveNN()); assertSame(mockNN1, bpos.getActiveNN()); Mockito.doAnswer(new Answer<Void>() {
waitForInitialization(bpos); assertNull(bpos.getActiveNN()); assertSame(mockNN1, bpos.getActiveNN()); Mockito.doAnswer(new BPOfferServiceSynchronousCallAnswer(0)) .when(mockNN1).errorReport(Mockito.any(DatanodeRegistration.class),
assertNull(bpos.getActiveNN()); assertSame(mockNN1, bpos.getActiveNN()); assertSame(mockNN2, bpos.getActiveNN()); assertSame(mockNN2, bpos.getActiveNN()); assertNull(bpos.getActiveNN()); assertSame(mockNN1, bpos.getActiveNN());
waitForInitialization(bpos); assertNull(bpos.getActiveNN()); assertSame(mockNN1, bpos.getActiveNN());
waitForInitialization(bpos); assertNull(bpos.getActiveNN()); assertSame(mockNN1, bpos.getActiveNN());
waitForInitialization(bpos); assertNull(bpos.getActiveNN()); assertSame(mockNN1, bpos.getActiveNN()); Mockito.doAnswer(new BPOfferServiceSynchronousCallAnswer(0)) .when(mockNN1).reportBadBlocks(Mockito.any(LocatedBlock[].class));