Java Code Examples for org.apache.hadoop.hdfs.DistributedFileSystem#isInSafeMode()
The following examples show how to use
org.apache.hadoop.hdfs.DistributedFileSystem#isInSafeMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestHASafeMode.java From hadoop with Apache License 2.0 | 5 votes |
/** * DFS#isInSafeMode should check the ActiveNNs safemode in HA enabled cluster. HDFS-3507 * * @throws Exception */ @Test public void testIsInSafemode() throws Exception { // Check for the standby nn without client failover. NameNode nn2 = cluster.getNameNode(1); assertTrue("nn2 should be in standby state", nn2.isStandbyState()); InetSocketAddress nameNodeAddress = nn2.getNameNodeAddress(); Configuration conf = new Configuration(); DistributedFileSystem dfs = new DistributedFileSystem(); try { dfs.initialize( URI.create("hdfs://" + nameNodeAddress.getHostName() + ":" + nameNodeAddress.getPort()), conf); dfs.isInSafeMode(); fail("StandBy should throw exception for isInSafeMode"); } catch (IOException e) { if (e instanceof RemoteException) { IOException sbExcpetion = ((RemoteException) e).unwrapRemoteException(); assertTrue("StandBy nn should not support isInSafeMode", sbExcpetion instanceof StandbyException); } else { throw e; } } finally { if (null != dfs) { dfs.close(); } } // Check with Client FailOver cluster.transitionToStandby(0); cluster.transitionToActive(1); cluster.getNameNodeRpc(1).setSafeMode(SafeModeAction.SAFEMODE_ENTER, false); DistributedFileSystem dfsWithFailOver = (DistributedFileSystem) fs; assertTrue("ANN should be in SafeMode", dfsWithFailOver.isInSafeMode()); cluster.getNameNodeRpc(1).setSafeMode(SafeModeAction.SAFEMODE_LEAVE, false); assertFalse("ANN should be out of SafeMode", dfsWithFailOver.isInSafeMode()); }
Example 2
Source File: TestHASafeMode.java From big-c with Apache License 2.0 | 5 votes |
/** * DFS#isInSafeMode should check the ActiveNNs safemode in HA enabled cluster. HDFS-3507 * * @throws Exception */ @Test public void testIsInSafemode() throws Exception { // Check for the standby nn without client failover. NameNode nn2 = cluster.getNameNode(1); assertTrue("nn2 should be in standby state", nn2.isStandbyState()); InetSocketAddress nameNodeAddress = nn2.getNameNodeAddress(); Configuration conf = new Configuration(); DistributedFileSystem dfs = new DistributedFileSystem(); try { dfs.initialize( URI.create("hdfs://" + nameNodeAddress.getHostName() + ":" + nameNodeAddress.getPort()), conf); dfs.isInSafeMode(); fail("StandBy should throw exception for isInSafeMode"); } catch (IOException e) { if (e instanceof RemoteException) { IOException sbExcpetion = ((RemoteException) e).unwrapRemoteException(); assertTrue("StandBy nn should not support isInSafeMode", sbExcpetion instanceof StandbyException); } else { throw e; } } finally { if (null != dfs) { dfs.close(); } } // Check with Client FailOver cluster.transitionToStandby(0); cluster.transitionToActive(1); cluster.getNameNodeRpc(1).setSafeMode(SafeModeAction.SAFEMODE_ENTER, false); DistributedFileSystem dfsWithFailOver = (DistributedFileSystem) fs; assertTrue("ANN should be in SafeMode", dfsWithFailOver.isInSafeMode()); cluster.getNameNodeRpc(1).setSafeMode(SafeModeAction.SAFEMODE_LEAVE, false); assertFalse("ANN should be out of SafeMode", dfsWithFailOver.isInSafeMode()); }