@Override public Boolean get() { return !nn1.isInSafeMode(); } }, 100, 10000);
/** * Returns true if the NameNode is running and is out of Safe Mode. */ public boolean isClusterUp() { if (nameNode == null) { return false; } long[] sizes = nameNode.getStats(); boolean isUp = false; synchronized (this) { isUp = (!nameNode.isInSafeMode() && sizes[0] != 0); } return isUp; }
NameNode startNameNode( Configuration conf, String imageDirs, String editsDirs, StartupOption start) throws IOException { conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:0"); conf.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "0.0.0.0:0"); conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, imageDirs); conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY, editsDirs); String[] args = new String[]{start.getName()}; NameNode nn = NameNode.createNameNode(args, conf); Assert.assertTrue(nn.isInSafeMode()); return nn; }
NameNode startNameNode( Configuration conf, String imageDirs, String editsDirs, StartupOption start) throws IOException { conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:0"); conf.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "0.0.0.0:0"); conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, imageDirs); conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY, editsDirs); String[] args = new String[]{start.getName()}; NameNode nn = NameNode.createNameNode(args, conf); assertTrue(nn.isInSafeMode()); return nn; }
/** * Returns true if the NameNode is running and is out of Safe Mode * or if waiting for safe mode is disabled. */ public boolean isNameNodeUp(int nnIndex) { NameNode nameNode = nameNodes[nnIndex].nameNode; if (nameNode == null) { return false; } long[] sizes; sizes = NameNodeAdapter.getStats(nameNode.getNamesystem()); boolean isUp = false; synchronized (this) { isUp = ((!nameNode.isInSafeMode() || !waitSafeMode) && sizes[ClientProtocol.GET_STATS_CAPACITY_IDX] != 0); } return isUp; }
isNameNodeMonitorRunning); assertFalse("NN should not presently be in safe mode", cluster.getNameNode().isInSafeMode()); while (!cluster.getNameNode().isInSafeMode() && Time.now() < startMillis + (60 * 1000)) { Thread.sleep(1000); cluster.getNameNode().isInSafeMode()); } finally { if (cluster != null)
assertTrue("should still be in SafeMode", namenode.isInSafeMode()); assertFalse("should not be in SafeMode", namenode.isInSafeMode()); namenode.isInSafeMode()); FileStatus stat = fs.getFileStatus(file1); try { assertFalse("Should not be in safemode", namenode.isInSafeMode()); checkGetBlockLocationsWorks(fs, file1);
@Test public void testSingleFailedEditsDirOnFlush() throws IOException { assertTrue(doAnEdit()); // Invalidate one edits journal. invalidateEditsDirAtIndex(0, true, false); // The NN has not terminated (no ExitException thrown) assertTrue(doAnEdit()); // A single journal failure should not result in a call to terminate assertFalse(cluster.getNameNode().isInSafeMode()); }
@Test public void testSingleFailedEditsDirOnSetReadyToFlush() throws IOException { assertTrue(doAnEdit()); // Invalidate one edits journal. invalidateEditsDirAtIndex(0, false, false); // The NN has not terminated (no ExitException thrown) assertTrue(doAnEdit()); // A single journal failure should not result in a call to terminate assertFalse(cluster.getNameNode().isInSafeMode()); }
cluster.getNameNode().isInSafeMode());
assertFalse( "StandBy NameNode should not go to SafeMode on resource unavailability", nn1.isInSafeMode());
/** * Make sure that when we transition to active in safe mode that we don't * prematurely consider blocks missing just because not all DNs have reported * yet. * * This is a regression test for HDFS-3921. */ @Test public void testNoPopulatingReplQueuesWhenStartingActiveInSafeMode() throws IOException { DFSTestUtil.createFile(fs, new Path("/test"), 15*BLOCK_SIZE, (short)3, 1L); // Stop the DN so that when the NN restarts not all blocks wil be reported // and the NN won't leave safe mode. cluster.stopDataNode(1); // Restart the namenode but don't wait for it to hear from all DNs (since // one DN is deliberately shut down.) cluster.restartNameNode(0, false); cluster.transitionToActive(0); assertTrue(cluster.getNameNode(0).isInSafeMode()); // We shouldn't yet consider any blocks "missing" since we're in startup // safemode, i.e. not all DNs may have reported. assertEquals(0, cluster.getNamesystem(0).getMissingBlocksCount()); }
cluster.restartNameNode(); NameNode nn = cluster.getNameNode(); assertTrue(nn.isInSafeMode()); DelegationTokenSecretManager sm = NameNodeAdapter.getDtSecretManager(nn.getNamesystem()); sm = NameNodeAdapter.getDtSecretManager(nn.getNamesystem()); assertFalse(nn.isInSafeMode()); assertTrue(sm.isRunning());
assertTrue(nn.isInSafeMode()); assertFalse(isDTRunning(nn)); NameNodeAdapter.leaveSafeMode(nn); assertTrue(nn.isStandbyState()); assertFalse(nn.isInSafeMode()); assertFalse(isDTRunning(nn)); NameNodeAdapter.enterSafeMode(nn, false); assertTrue(nn.isStandbyState()); assertTrue(nn.isInSafeMode()); assertFalse(isDTRunning(nn)); nn.getRpcServer().transitionToActive(REQ_INFO); assertFalse(nn.isStandbyState()); assertTrue(nn.isInSafeMode()); assertFalse(isDTRunning(nn)); nn.getRpcServer().transitionToStandby(REQ_INFO); assertTrue(nn.isStandbyState()); assertTrue(nn.isInSafeMode()); assertFalse(isDTRunning(nn)); NameNodeAdapter.leaveSafeMode(nn); assertFalse(nn.isStandbyState()); assertFalse(nn.isInSafeMode()); assertTrue(isDTRunning(nn)); NameNodeAdapter.enterSafeMode(nn, false);