本文整理汇总了Java中org.apache.hadoop.fs.shell.FsCommand类的典型用法代码示例。如果您正苦于以下问题:Java FsCommand类的具体用法?Java FsCommand怎么用?Java FsCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FsCommand类属于org.apache.hadoop.fs.shell包,在下文中一共展示了FsCommand类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testChgrpGroupValidity
import org.apache.hadoop.fs.shell.FsCommand; //导入依赖的package包/类
/**
* Tests valid and invalid group arguments to chgrp.
*/
@Test
public void testChgrpGroupValidity() {
// This test only covers argument parsing, so override to skip processing.
FsCommand chgrp = new FsShellPermissions.Chgrp() {
@Override
protected void processArgument(PathData item) {
}
};
chgrp.setConf(new Configuration());
// The following are valid (no exception expected).
chgrp.run("group", "/path");
// The following are valid only on Windows.
assertValidArgumentsOnWindows(chgrp, "Group With Spaces", "/path");
// The following are invalid (exception expected).
assertIllegalArguments(chgrp, ":gr#oup", "/path");
assertIllegalArguments(chgrp, ":gr%oup", "/path");
}
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestFsShellReturnCode.java
示例2: registerCommands
import org.apache.hadoop.fs.shell.FsCommand; //导入依赖的package包/类
protected void registerCommands(CommandFactory factory) {
// TODO: DFSAdmin subclasses FsShell so need to protect the command
// registration. This class should morph into a base class for
// commands, and then this method can be abstract
if (this.getClass().equals(FsShell.class)) {
factory.registerCommands(FsCommand.class);
}
}
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:FsShell.java
示例3: testChownUserAndGroupValidity
import org.apache.hadoop.fs.shell.FsCommand; //导入依赖的package包/类
private void testChownUserAndGroupValidity(boolean enableWarning) {
Configuration conf = new Configuration();
conf.setBoolean(
HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY, enableWarning);
FsCommand chown = new FakeChown();
chown.setConf(conf);
// The following are valid (no exception expected).
chown.run("user", "/path");
chown.run("user:group", "/path");
chown.run(":group", "/path");
// The following are valid only on Windows.
assertValidArgumentsOnWindows(chown, "User With Spaces", "/path");
assertValidArgumentsOnWindows(chown, "User With Spaces:group", "/path");
assertValidArgumentsOnWindows(chown, "User With Spaces:Group With Spaces",
"/path");
assertValidArgumentsOnWindows(chown, "user:Group With Spaces", "/path");
assertValidArgumentsOnWindows(chown, ":Group With Spaces", "/path");
// The following are invalid (exception expected).
assertIllegalArguments(chown, "us!er", "/path");
assertIllegalArguments(chown, "us^er", "/path");
assertIllegalArguments(chown, "user:gr#oup", "/path");
assertIllegalArguments(chown, "user:gr%oup", "/path");
assertIllegalArguments(chown, ":gr#oup", "/path");
assertIllegalArguments(chown, ":gr%oup", "/path");
}
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:29,代码来源:TestFsShellReturnCode.java
示例4: assertIllegalArguments
import org.apache.hadoop.fs.shell.FsCommand; //导入依赖的package包/类
/**
* Asserts that for the given command, the given arguments are considered
* invalid. The expectation is that the command will throw
* IllegalArgumentException.
*
* @param cmd FsCommand to check
* @param args String... arguments to check
*/
private static void assertIllegalArguments(FsCommand cmd, String... args) {
try {
cmd.run(args);
fail("Expected IllegalArgumentException from args: " +
Arrays.toString(args));
} catch (IllegalArgumentException e) {
}
}
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:TestFsShellReturnCode.java
示例5: assertValidArgumentsOnWindows
import org.apache.hadoop.fs.shell.FsCommand; //导入依赖的package包/类
/**
* Asserts that for the given command, the given arguments are considered valid
* on Windows, but invalid elsewhere.
*
* @param cmd FsCommand to check
* @param args String... arguments to check
*/
private static void assertValidArgumentsOnWindows(FsCommand cmd,
String... args) {
if (Shell.WINDOWS) {
cmd.run(args);
} else {
assertIllegalArguments(cmd, args);
}
}
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:16,代码来源:TestFsShellReturnCode.java
示例6: generateMethods
import org.apache.hadoop.fs.shell.FsCommand; //导入依赖的package包/类
@Test
@Ignore
public void generateMethods() {
final CommandFactory commandFactory = new CommandFactory(new Configuration());
FsCommand.registerCommands(commandFactory);
final String[] names = commandFactory.getNames();
final String collect = Arrays.stream(names).map(item -> "\"" + item.replace("-", "") + "\"").collect(Collectors.joining(","));
System.out.println(collect);
Arrays.stream(names).map(commandFactory::getInstance).forEach(item -> {
String description = "";
final String[] sentences = item.getDescription().split("\\.");
if (sentences.length == 0) {
description = item.getDescription();
} else {
description = sentences[0] + ".";
}
String cliCommand = String.format("@CliCommand(value = {\"%s\", \"hdfs dfs -%s\"}, help = \"%s\")", item.getCommandName(), item.getCommandName(), description);
String content = String.format(" public String %s(\n" +
" @CliOption(key = {\"\"}, help = \"%s\") String path\n" +
" ) {\n" +
" return runCommand(\"%s\", path);\n" +
" }\n", item.getCommandName(), description, item.getCommandName());
System.out.println(cliCommand);
System.out.println(content);
System.out.println();
});
}
开发者ID:avast,项目名称:hdfs-shell,代码行数:34,代码来源:ContextCommandsTest.java
示例7: testChownUserAndGroupValidity
import org.apache.hadoop.fs.shell.FsCommand; //导入依赖的package包/类
/**
* Tests combinations of valid and invalid user and group arguments to chown.
*/
@Test
public void testChownUserAndGroupValidity() {
// This test only covers argument parsing, so override to skip processing.
FsCommand chown = new FsShellPermissions.Chown() {
@Override
protected void processArgument(PathData item) {
}
};
chown.setConf(new Configuration());
// The following are valid (no exception expected).
chown.run("user", "/path");
chown.run("user:group", "/path");
chown.run(":group", "/path");
// The following are valid only on Windows.
assertValidArgumentsOnWindows(chown, "User With Spaces", "/path");
assertValidArgumentsOnWindows(chown, "User With Spaces:group", "/path");
assertValidArgumentsOnWindows(chown, "User With Spaces:Group With Spaces",
"/path");
assertValidArgumentsOnWindows(chown, "user:Group With Spaces", "/path");
assertValidArgumentsOnWindows(chown, ":Group With Spaces", "/path");
// The following are invalid (exception expected).
assertIllegalArguments(chown, "us!er", "/path");
assertIllegalArguments(chown, "us^er", "/path");
assertIllegalArguments(chown, "user:gr#oup", "/path");
assertIllegalArguments(chown, "user:gr%oup", "/path");
assertIllegalArguments(chown, ":gr#oup", "/path");
assertIllegalArguments(chown, ":gr%oup", "/path");
}
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:TestFsShellReturnCode.java
注:本文中的org.apache.hadoop.fs.shell.FsCommand类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论