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

项目:hops    文件:TestFsShell.java   
@Test
public void testExceptionNullMessage() throws Exception {
  final String cmdName = "-cmdExNullMsg";
  final Command cmd = Mockito.mock(Command.class);
  Mockito.when(cmd.run(Mockito.<String>anyVararg())).thenThrow(
      new IllegalArgumentException());
  Mockito.when(cmd.getUsage()).thenReturn(cmdName);

  final CommandFactory cmdFactory = Mockito.mock(CommandFactory.class);
  final String[] names = {cmdName};
  Mockito.when(cmdFactory.getNames()).thenReturn(names);
  Mockito.when(cmdFactory.getInstance(cmdName)).thenReturn(cmd);

  FsShell shell = new FsShell(new Configuration());
  shell.commandFactory = cmdFactory;
  try (GenericTestUtils.SystemErrCapturer capture =
           new GenericTestUtils.SystemErrCapturer()) {
    ToolRunner.run(shell, new String[]{cmdName});
    Assert.assertThat(capture.getOutput(),
        StringContains.containsString(cmdName
            + ": Null exception message"));
  }
}
项目:hadoop-oss    文件: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);
  }
}
项目: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();

    });

}
项目: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);
  }
}
项目:aliyun-oss-hadoop-fs    文件:ECCommand.java   
public static void registerCommands(CommandFactory factory) {
  // Register all commands of Erasure CLI, with a '-' at the beginning in name
  // of the command.
  factory.addClass(SetECPolicyCommand.class, "-" + SetECPolicyCommand.NAME);
  factory.addClass(GetECPolicyCommand.class, "-"
      + GetECPolicyCommand.NAME);
  factory.addClass(ListPolicies.class, "-" + ListPolicies.NAME);
}
项目:aliyun-oss-hadoop-fs    文件: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);
  }
}
项目: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);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件: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);
  }
}
项目:hadoop-plus    文件: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);
  }
}
项目:hops    文件: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);
  }
}
项目:hadoop-TCP    文件: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);
  }
}
项目:hardfs    文件: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);
  }
}
项目:hadoop-on-lustre2    文件: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);
  }
}
项目:hadoop-oss    文件: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");
}
项目:hadoop-oss    文件:TestFsShellReturnCode.java   
@Override
protected void registerCommands(CommandFactory factory) {
  factory.addClass(InterruptCommand.class, "-testInterrupt");
}
项目: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);
}
项目: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");
}
项目:aliyun-oss-hadoop-fs    文件:ECCli.java   
@Override
protected void registerCommands(CommandFactory factory) {
  factory.registerCommands(ECCommand.class);
}
项目:aliyun-oss-hadoop-fs    文件: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");
}
项目:aliyun-oss-hadoop-fs    文件:TestFsShellReturnCode.java   
@Override
protected void registerCommands(CommandFactory factory) {
  factory.addClass(InterruptCommand.class, "-testInterrupt");
}
项目: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");
}
项目:hadoop-2.6.0-cdh5.4.3    文件: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");
}
项目:hadoop-plus    文件: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");
}
项目:prairie    文件:FsShellWithIO.java   
@Override
protected void registerCommands(CommandFactory factory) {
    factory.registerCommands(FsCommand.class);
}
项目:prairie    文件:CommandFactoryWithIO.java   
public CommandFactoryWithIO(CommandFactory commandFactory, PrintStream out, PrintStream err) {
    this.commandFactory = commandFactory;
    this.out = out;
    this.err = err;
}
项目:PDHC    文件:TrueDelete.java   
public static void registerCommands(CommandFactory factory) {
  factory.addClass(TRmr.class, "-rmr");
  factory.addClass(Expunge.class, "-expunge");
}
项目:hops    文件: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");
}
项目:hadoop-TCP    文件: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");
}
项目:hardfs    文件: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");
}
项目:hadoop-on-lustre2    文件: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");
}
项目:hadoop-oss    文件:FindOptions.java   
/**
 * Set the command factory.
 *
 * @param factory {@link CommandFactory}
 */
public void setCommandFactory(CommandFactory factory) {
  this.commandFactory = factory;
}
项目:hadoop-oss    文件:FindOptions.java   
/**
 * Return the command factory.
 *
 * @return {@link CommandFactory}
 */
public CommandFactory getCommandFactory() {
  return this.commandFactory;
}
项目:hadoop-oss    文件: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");
}
项目:hadoop    文件:FindOptions.java   
/**
 * Set the command factory.
 *
 * @param factory {@link CommandFactory}
 */
public void setCommandFactory(CommandFactory factory) {
  this.commandFactory = factory;
}
项目:hadoop    文件:FindOptions.java   
/**
 * Return the command factory.
 *
 * @return {@link CommandFactory}
 */
public CommandFactory getCommandFactory() {
  return this.commandFactory;
}
项目: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");
}
项目:aliyun-oss-hadoop-fs    文件:FindOptions.java   
/**
 * Set the command factory.
 *
 * @param factory {@link CommandFactory}
 */
public void setCommandFactory(CommandFactory factory) {
  this.commandFactory = factory;
}
项目:aliyun-oss-hadoop-fs    文件:FindOptions.java   
/**
 * Return the command factory.
 *
 * @return {@link CommandFactory}
 */
public CommandFactory getCommandFactory() {
  return this.commandFactory;
}
项目:aliyun-oss-hadoop-fs    文件: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");
}
项目:big-c    文件:FindOptions.java   
/**
 * Set the command factory.
 *
 * @param factory {@link CommandFactory}
 */
public void setCommandFactory(CommandFactory factory) {
  this.commandFactory = factory;
}