BlockManagerSafeMode { synchronized void decrementSafeBlockCount(BlockInfo b) { assert namesystem.hasWriteLock(); if (status == BMSafeModeStatus.OFF) { return; } BlockInfo storedBlock = blockManager.getStoredBlock(b); if (storedBlock.isComplete() && blockManager.countNodes(b).liveReplicas() == safeReplication - 1) { this.blockSafe--; assert blockSafe >= 0; checkSafeMode(); } } BlockManagerSafeMode(BlockManager blockManager, Namesystem namesystem,
      Configuration conf);   }
@Test(timeout = 30000) public void testDecrementSafeBlockCount() { bmSafeMode.activate(BLOCK_TOTAL); Whitebox.setInternalState(bmSafeMode, "extension", 0); mockBlockManagerForBlockSafeDecrement(); setBlockSafe(BLOCK_THRESHOLD); for (long i = BLOCK_THRESHOLD; i > 0; i--) { BlockInfo blockInfo = mock(BlockInfo.class); bmSafeMode.decrementSafeBlockCount(blockInfo); assertEquals(i - 1, getblockSafe()); assertTrue(bmSafeMode.isInSafeMode()); } }