类org.apache.hadoop.fs.shell.CommandFactory源码实例Demo

下面列出了怎么用org.apache.hadoop.fs.shell.CommandFactory的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hadoop-ozone   文件: OzoneFsShell.java

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(OzoneFsShell.class)) {
    factory.registerCommands(FsCommand.class);
  }
}
 
源代码2 项目: hdfs-shell   文件: ContextCommandsTest.java

@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();

    });

}
 
源代码3 项目: hadoop   文件: FsShell.java

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);
  }
}
 
源代码4 项目: big-c   文件: FsShell.java

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);
  }
}
 
源代码5 项目: hdfs-shell   文件: HadoopDfsCommands.java

private static Command getCommandInstance(String cmdName, Configuration conf) {
    final CommandFactory commandFactory = new CommandFactory(conf);
    FsCommand.registerCommands(commandFactory);
    return commandFactory.getInstance(cmdName, conf);
}
 
源代码6 项目: hadoop   文件: FsShellPermissions.java

/**
 * Register the permission related commands with the factory
 * @param factory the command factory
 */
public static void registerCommands(CommandFactory factory) {
  factory.addClass(Chmod.class, "-chmod");
  factory.addClass(Chown.class, "-chown");
  factory.addClass(Chgrp.class, "-chgrp");
}
 
源代码7 项目: big-c   文件: FsShellPermissions.java

/**
 * Register the permission related commands with the factory
 * @param factory the command factory
 */
public static void registerCommands(CommandFactory factory) {
  factory.addClass(Chmod.class, "-chmod");
  factory.addClass(Chown.class, "-chown");
  factory.addClass(Chgrp.class, "-chgrp");
}
 
源代码8 项目: examples   文件: Find.java

/** sets the command factory for later use */
public void setCommandFactory(CommandFactory factory) { // FIXME FsShell should call this
  this.commandFactory = factory;
}
 
源代码9 项目: examples   文件: Find.java

/** retrieves the command factory */
protected CommandFactory getCommandFactory() {
  return this.commandFactory;
}
 
源代码10 项目: examples   文件: HdfsFindTool.java

@Override
protected void registerCommands(CommandFactory factory) {
  super.registerCommands(factory);
  factory.registerCommands(Find.class);
}
 
源代码11 项目: hadoop   文件: FindOptions.java

/**
 * Set the command factory.
 *
 * @param factory {@link CommandFactory}
 */
public void setCommandFactory(CommandFactory factory) {
  this.commandFactory = factory;
}
 
源代码12 项目: hadoop   文件: FindOptions.java

/**
 * Return the command factory.
 *
 * @return {@link CommandFactory}
 */
public CommandFactory getCommandFactory() {
  return this.commandFactory;
}
 
源代码13 项目: hadoop   文件: Find.java

/**
 * Register the names for the count command
 * 
 * @param factory the command factory that will instantiate this class
 */
public static void registerCommands(CommandFactory factory) {
  factory.addClass(Find.class, "-find");
}
 
源代码14 项目: big-c   文件: FindOptions.java

/**
 * Set the command factory.
 *
 * @param factory {@link CommandFactory}
 */
public void setCommandFactory(CommandFactory factory) {
  this.commandFactory = factory;
}
 
源代码15 项目: big-c   文件: FindOptions.java

/**
 * Return the command factory.
 *
 * @return {@link CommandFactory}
 */
public CommandFactory getCommandFactory() {
  return this.commandFactory;
}
 
源代码16 项目: big-c   文件: Find.java

/**
 * Register the names for the count command
 * 
 * @param factory the command factory that will instantiate this class
 */
public static void registerCommands(CommandFactory factory) {
  factory.addClass(Find.class, "-find");
}
 
源代码17 项目: examples   文件: Find.java

/**
 * Register the names for the count command
 * @param factory the command factory that will instantiate this class
 */
public static void registerCommands(CommandFactory factory) {
  factory.addClass(Find.class, "-find");
}
 
源代码18 项目: examples   文件: FindOptions.java

/**
 * Set the command factory.
 * @param factory {@link CommandFactory}
 */
public void setCommandFactory(CommandFactory factory) {
  this.commandFactory = factory;
}
 
源代码19 项目: examples   文件: FindOptions.java

/**
 * Return the command factory.
 * @return {@link CommandFactory}
 */
public CommandFactory getCommandFactory() {
  return this.commandFactory;
}
 
 类所在包
 同包方法