org.apache.hadoop.fs.shell.Command Java Examples
The following examples show how to use
org.apache.hadoop.fs.shell.Command.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FsShell.java From hadoop with Apache License 2.0 | 5 votes |
private void displayError(String cmd, String message) { for (String line : message.split("\n")) { System.err.println(cmd + ": " + line); if (cmd.charAt(0) != '-') { Command instance = null; instance = commandFactory.getInstance("-" + cmd); if (instance != null) { System.err.println("Did you mean -" + cmd + "? This command " + "begins with a dash."); } } } }
Example #2
Source File: FsShell.java From big-c with Apache License 2.0 | 5 votes |
private void displayError(String cmd, String message) { for (String line : message.split("\n")) { System.err.println(cmd + ": " + line); if (cmd.charAt(0) != '-') { Command instance = null; instance = commandFactory.getInstance("-" + cmd); if (instance != null) { System.err.println("Did you mean -" + cmd + "? This command " + "begins with a dash."); } } } }
Example #3
Source File: HadoopDfsCommands.java From hdfs-shell with Apache License 2.0 | 4 votes |
String runCommand(String cmdName, String[] arguments) { final Configuration conf = contextCommands.getConfiguration(); cmdName = "-" + cmdName; final Command command = getCommandInstance(cmdName, conf); if (command == null) { return "Unknown command " + cmdName; } if (arguments.length == 0 && !NO_PARAMS_COMMANDS.contains(cmdName)) { return command.getDescription(); } contextCommands.updateCurrentWorkingDirectory(); arguments = replaceHdfsPath(arguments); final PrintStream printStream = ClientConnection.context.get(); if (printStream != null) { command.err = printStream; command.out = printStream; } // final ByteArrayOutputStream out = new ByteArrayOutputStream(); // final PrintStream printStream = new PrintStream(out); // command.err = printStream; // command.out = printStream; final int result = command.run(arguments); if (contextCommands.isShowResultCode()) { if (result == 0) { command.out.println("Exit code = " + result); } else { command.err.println("Exit code = " + result); } } //printStream.close(); if (result != 0 && contextCommands.isFailOnError()) { throw new RuntimeException("HDFS Command finished with result code " + result); } return ""; }
Example #4
Source File: HadoopDfsCommands.java From hdfs-shell with Apache License 2.0 | 4 votes |
private static Command getCommandInstance(String cmdName, Configuration conf) { final CommandFactory commandFactory = new CommandFactory(conf); FsCommand.registerCommands(commandFactory); return commandFactory.getInstance(cmdName, conf); }
Example #5
Source File: FsShell.java From hadoop with Apache License 2.0 | 4 votes |
private void printInstanceUsage(PrintStream out, Command instance) { out.println(usagePrefix + " " + instance.getUsage()); }
Example #6
Source File: FsShell.java From big-c with Apache License 2.0 | 4 votes |
private void printInstanceUsage(PrintStream out, Command instance) { out.println(usagePrefix + " " + instance.getUsage()); }
Example #7
Source File: Exec.java From examples with Apache License 2.0 | 4 votes |
Command getCommand() { return this.command; }