BlockManagerSafeMode { synchronized void incrementSafeBlockCount(int storageNum, BlockInfo storedBlock) { assert namesystem.hasWriteLock(); if (status == BMSafeModeStatus.OFF) { return; } final int safe = storedBlock.isStriped() ? ((BlockInfoStriped)storedBlock).getRealDataBlockNum() : safeReplication; if (storageNum == safe) { this.blockSafe++; StartupProgress prog = NameNode.getStartupProgress(); if (prog.getStatus(Phase.SAFEMODE) != Status.COMPLETE) { if (this.awaitingReportedBlocksCounter == null) { this.awaitingReportedBlocksCounter = prog.getCounter(Phase.SAFEMODE, STEP_AWAITING_REPORTED_BLOCKS); } this.awaitingReportedBlocksCounter.increment(); } checkSafeMode(); } } BlockManagerSafeMode(BlockManager blockManager, Namesystem namesystem,
      Configuration conf);   }
@Test(timeout = 30000) public void testIncrementSafeBlockCount() { bmSafeMode.activate(BLOCK_TOTAL); Whitebox.setInternalState(bmSafeMode, "extension", 0); for (long i = 1; i <= BLOCK_TOTAL; i++) { BlockInfo blockInfo = mock(BlockInfo.class); doReturn(false).when(blockInfo).isStriped(); bmSafeMode.incrementSafeBlockCount(1, blockInfo); if (i < BLOCK_THRESHOLD) { assertEquals(i, getblockSafe()); assertTrue(bmSafeMode.isInSafeMode()); } else { assertFalse(bmSafeMode.isInSafeMode()); assertEquals(BLOCK_THRESHOLD, getblockSafe()); } } }