/** * Initialize replication queues. */ protected synchronized void initializeReplQueues() { LOG.info("initializing replication queues"); if (namesystem.isPopulatingReplQueues()) { LOG.warn("Replication queues already initialized."); } namesystem.processMisReplicatedBlocks(); namesystem.initializedReplQueues = true; }
/** * @return Replication queue initialization status */ public static boolean safeModeInitializedReplQueues(NameNode nn) { return nn.getNamesystem().isPopulatingReplQueues(); }
protected void startPostSafeModeProcessing() { // if not done yet, initialize replication queues if (!namesystem.isPopulatingReplQueues()) { initializeReplQueues(); } long timeInSafemode = FSNamesystem.now() - namesystem.systemStart; NameNode.stateChangeLog.info("STATE* Leaving safe mode after " + timeInSafemode / 1000 + " secs."); NameNode.getNameNodeMetrics().safeModeTime.set((int) timeInSafemode); if (reached >= 0) { NameNode.stateChangeLog.info("STATE* Safe mode is OFF."); } reached = -1; try { nameNode.startServerForClientRequests(); } catch (IOException ex) { nameNode.stop(); } NameNode.stateChangeLog.info("STATE* Network topology has " + namesystem.clusterMap.getNumOfRacks() + " racks and " + namesystem.clusterMap.getNumOfLeaves() + " datanodes"); NameNode.stateChangeLog.info("STATE* UnderReplicatedBlocks has " + namesystem.getUnderReplicatedBlocks() + " blocks"); }
try { checkOperation(OperationCategory.READ); if (!isPopulatingReplQueues()) { throw new IOException("Cannot run listCorruptFileBlocks because " + "replication queues have not been initialized.");
try { checkOperation(OperationCategory.READ); if (!isPopulatingReplQueues()) { throw new IOException("Cannot run listCorruptFileBlocks because " + "replication queues have not been initialized.");
if (!isPopulatingReplQueues() && shouldPopulateReplQueues()) { initializeReplQueues();
synchronized (neededReplications) { try { if (!isPopulatingReplQueues()) { throw new IOException("Cannot run listCorruptFileBlocks because " + "replication queues have not been initialized.");
@Test public void testReplQueuesActiveAfterStartupSafemode() throws IOException, InterruptedException{ Configuration conf = new Configuration(); FSEditLog fsEditLog = Mockito.mock(FSEditLog.class); FSImage fsImage = Mockito.mock(FSImage.class); Mockito.when(fsImage.getEditLog()).thenReturn(fsEditLog); FSNamesystem fsNamesystem = new FSNamesystem(conf, fsImage); FSNamesystem fsn = Mockito.spy(fsNamesystem); //Make shouldPopulaeReplQueues return true HAContext haContext = Mockito.mock(HAContext.class); HAState haState = Mockito.mock(HAState.class); Mockito.when(haContext.getState()).thenReturn(haState); Mockito.when(haState.shouldPopulateReplQueues()).thenReturn(true); Whitebox.setInternalState(fsn, "haContext", haContext); //Make NameNode.getNameNodeMetrics() not return null NameNode.initMetrics(conf, NamenodeRole.NAMENODE); fsn.enterSafeMode(false); assertTrue("FSNamesystem didn't enter safemode", fsn.isInSafeMode()); assertTrue("Replication queues were being populated during very first " + "safemode", !fsn.isPopulatingReplQueues()); fsn.leaveSafeMode(); assertTrue("FSNamesystem didn't leave safemode", !fsn.isInSafeMode()); assertTrue("Replication queues weren't being populated even after leaving " + "safemode", fsn.isPopulatingReplQueues()); fsn.enterSafeMode(false); assertTrue("FSNamesystem didn't enter safemode", fsn.isInSafeMode()); assertTrue("Replication queues weren't being populated after entering " + "safemode 2nd time", fsn.isPopulatingReplQueues()); }
&& !namesystem.isPopulatingReplQueues()) { initializeReplQueues(); if (canInitializeReplQueues() && !namesystem.isPopulatingReplQueues()) { initializeReplQueues();
} else if (isPopulatingReplQueues()) {
enter(); if (canInitializeReplQueues() && !isPopulatingReplQueues() && !haEnabled) { initializeReplQueues(); if (canInitializeReplQueues() && !isPopulatingReplQueues() && !haEnabled) { initializeReplQueues();
enter(); if (canInitializeReplQueues() && !isPopulatingReplQueues() && !haEnabled) { initializeReplQueues(); if (canInitializeReplQueues() && !isPopulatingReplQueues() && !haEnabled) { initializeReplQueues();
while (!cluster.getNameNode().namesystem.isPopulatingReplQueues()) { try { LOG.info("waiting for replication queues");
int numLiveReplicas = 0; boolean popReplQueuesBefore = isPopulatingReplQueues(); if (!popReplQueuesBefore && isPopulatingReplQueues()) { if (!isPopulatingReplQueues()) { return true;
/** * Start services common to both active and standby states */ void startCommonServices(Configuration conf, HAContext haContext) throws IOException { this.registerMBean(); // register the MBean for the FSNamesystemState writeLock(); this.haContext = haContext; try { nnResourceChecker = new NameNodeResourceChecker(conf); checkAvailableResources(); assert safeMode != null && !isPopulatingReplQueues(); StartupProgress prog = NameNode.getStartupProgress(); prog.beginPhase(Phase.SAFEMODE); prog.setTotal(Phase.SAFEMODE, STEP_AWAITING_REPORTED_BLOCKS, getCompleteBlocksTotal()); setBlockTotal(); blockManager.activate(conf); } finally { writeUnlock("startCommonServices"); } registerMXBean(); DefaultMetricsSystem.instance().register(this); if (inodeAttributeProvider != null) { inodeAttributeProvider.start(); dir.setINodeAttributeProvider(inodeAttributeProvider); } snapshotManager.registerMXBean(); }
/** * Start services common to both active and standby states */ void startCommonServices(Configuration conf, HAContext haContext) throws IOException { this.registerMBean(); // register the MBean for the FSNamesystemState writeLock(); this.haContext = haContext; try { nnResourceChecker = new NameNodeResourceChecker(conf); checkAvailableResources(); assert safeMode != null && !isPopulatingReplQueues(); StartupProgress prog = NameNode.getStartupProgress(); prog.beginPhase(Phase.SAFEMODE); prog.setTotal(Phase.SAFEMODE, STEP_AWAITING_REPORTED_BLOCKS, getCompleteBlocksTotal()); setBlockTotal(); blockManager.activate(conf); } finally { writeUnlock("startCommonServices"); } registerMXBean(); DefaultMetricsSystem.instance().register(this); if (inodeAttributeProvider != null) { inodeAttributeProvider.start(); dir.setINodeAttributeProvider(inodeAttributeProvider); } snapshotManager.registerMXBean(); }
if (!isPopulatingReplQueues() && shouldPopulateReplQueues()) { initializeReplQueues();