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:
parent
1cbb18d3e0
commit
28c307519a
|
@ -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.
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.apache.hadoop.hdfs.protocol.DirectoryListing;
|
|||
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 @@ import org.apache.hadoop.util.Progressable;
|
|||
* 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 class DistributedFileSystem extends FileSystem {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ import org.apache.hadoop.util.StringUtils;
|
|||
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 class DFSAdmin extends FsShell {
|
|||
} catch (java.lang.InterruptedException e) {
|
||||
throw new IOException("Wait Interrupted");
|
||||
}
|
||||
inSafeMode = dfs.setSafeMode(action);
|
||||
inSafeMode = dfs.isInSafeMode();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -357,4 +357,19 @@ public class TestSafeMode {
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue