svn merge -c 1305632 from trunk for HDFS-2413. Add an API DistributedFileSystem.isInSafeMode() and change DistributedFileSystem to @InterfaceAudience.LimitedPrivate.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1305633 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2012-03-26 22:19:30 +00:00
parent 1cbb18d3e0
commit 28c307519a
4 changed files with 34 additions and 4 deletions

View File

@ -58,6 +58,10 @@ Release 0.23.3 - UNRELEASED
HDFS-2941. Add an administrative command to download a copy of the fsimage
from the NN. (atm)
HDFS-2413. Add an API DistributedFileSystem.isInSafeMode() and change
DistributedFileSystem to @InterfaceAudience.LimitedPrivate.
(harsh via szetszwo)
IMPROVEMENTS
HDFS-2018. Move all journal stream management code into one place.

View File

@ -51,6 +51,7 @@
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
import org.apache.hadoop.hdfs.protocol.HdfsConstants.UpgradeAction;
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
import org.apache.hadoop.hdfs.protocol.HdfsLocatedFileStatus;
@ -71,8 +72,8 @@
* DistributedFileSystem.
*
*****************************************************************/
@InterfaceAudience.Private
@InterfaceStability.Evolving
@InterfaceAudience.LimitedPrivate({ "MapReduce", "HBase" })
@InterfaceStability.Unstable
public class DistributedFileSystem extends FileSystem {
private Path workingDir;
private URI uri;
@ -854,4 +855,14 @@ public String getCanonicalServiceName() {
return super.getCanonicalServiceName();
}
}
/**
* Utility function that returns if the NameNode is in safemode or not.
*
* @return true if NameNode is in safemode, false otherwise.
* @throws IOException when there is an issue communicating with the NameNode
*/
public boolean isInSafeMode() throws IOException {
return setSafeMode(SafeModeAction.SAFEMODE_GET);
}
}

View File

@ -59,7 +59,7 @@
import org.apache.hadoop.util.ToolRunner;
/**
* This class provides some DFS administrative access.
* This class provides some DFS administrative access shell commands.
*/
@InterfaceAudience.Private
public class DFSAdmin extends FsShell {
@ -396,7 +396,7 @@ public void setSafeMode(String[] argv, int idx) throws IOException {
} catch (java.lang.InterruptedException e) {
throw new IOException("Wait Interrupted");
}
inSafeMode = dfs.setSafeMode(action);
inSafeMode = dfs.isInSafeMode();
}
}

View File

@ -357,4 +357,19 @@ public void testDatanodeThreshold() throws IOException {
assertEquals("", cluster.getNamesystem().getSafemode());
}
/*
* Tests some utility methods that surround the SafeMode's state.
* @throws IOException when there's an issue connecting to the test DFS.
*/
public void testSafeModeUtils() throws IOException {
dfs = (DistributedFileSystem)cluster.getFileSystem();
// Enter safemode.
dfs.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
assertTrue("State was expected to be in safemode.", dfs.isInSafeMode());
// Exit safemode.
dfs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
assertFalse("State was expected to be out of safemode.", dfs.isInSafeMode());
}
}