本文整理汇总了Java中org.apache.hadoop.hdfs.protocol.FSConstants.SafeModeAction方法的典型用法代码示例。如果您正苦于以下问题:Java FSConstants.SafeModeAction方法的具体用法?Java FSConstants.SafeModeAction怎么用?Java FSConstants.SafeModeAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hdfs.protocol.FSConstants
的用法示例。
在下文中一共展示了FSConstants.SafeModeAction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSafeMode
import org.apache.hadoop.hdfs.protocol.FSConstants; //导入方法依赖的package包/类
/**
* Safe mode maintenance command.
* Usage: java DFSAdmin -safemode [enter | leave | get | wait | initqueues]
* @param argv List of of command line parameters.
* @param idx The index of the command that is being processed.
* @exception IOException if the filesystem does not exist.
*/
public void setSafeMode(String[] argv, int idx) throws IOException {
DistributedFileSystem dfs = getDFS();
if (dfs == null) {
System.err.println("FileSystem is " + getFS().getUri());
return;
}
if (idx != argv.length - 1) {
printUsage("-safemode");
return;
}
FSConstants.SafeModeAction action;
Boolean waitExitSafe = false;
if ("leave".equalsIgnoreCase(argv[idx])) {
action = FSConstants.SafeModeAction.SAFEMODE_LEAVE;
} else if ("enter".equalsIgnoreCase(argv[idx])) {
action = FSConstants.SafeModeAction.SAFEMODE_ENTER;
} else if ("get".equalsIgnoreCase(argv[idx])) {
action = FSConstants.SafeModeAction.SAFEMODE_GET;
} else if ("initqueues".equalsIgnoreCase(argv[idx])) {
action = FSConstants.SafeModeAction.SAFEMODE_INITQUEUES;
} else if ("wait".equalsIgnoreCase(argv[idx])) {
action = FSConstants.SafeModeAction.SAFEMODE_GET;
waitExitSafe = true;
} else {
printUsage("-safemode");
return;
}
boolean inSafeMode = dfs.setSafeMode(action);
//
// If we are waiting for safemode to exit, then poll and
// sleep till we are out of safemode.
//
if (waitExitSafe) {
while (inSafeMode) {
try {
Thread.sleep(5000);
} catch (java.lang.InterruptedException e) {
throw new IOException("Wait Interrupted");
}
inSafeMode = dfs.setSafeMode(action);
}
}
System.out.println("Safe mode is " + (inSafeMode ? "ON" : "OFF"));
}
示例2: setSafeMode
import org.apache.hadoop.hdfs.protocol.FSConstants; //导入方法依赖的package包/类
/**
* Enter, leave or get safe mode.
*
* @see org.apache.hadoop.hdfs.protocol.ClientProtocol#setSafeMode(
* FSConstants.SafeModeAction)
*/
public boolean setSafeMode(FSConstants.SafeModeAction action)
throws IOException {
return dfs.setSafeMode(action);
}
示例3: setSafeMode
import org.apache.hadoop.hdfs.protocol.FSConstants; //导入方法依赖的package包/类
/**
* Enter, leave or get safe mode.
*
* @see org.apache.hadoop.hdfs.protocol.ClientProtocol#setSafeMode(FSConstants.SafeModeAction)
*/
public boolean setSafeMode(FSConstants.SafeModeAction action)
throws IOException {
return getDFS().setSafeMode(action);
}