ToolRunner (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: ToolRunner

Package org.apache.hadoop.util

# Class ToolRunner

java.lang.Object
org.apache.hadoop.util.ToolRunner

@Public @Stable public class ToolRunner extends Object
A utility to help run `Tool`s.

`ToolRunner` can be used to run classes implementing `Tool` interface. It works in conjunction with `GenericOptionsParser` to parse the generic hadoop command line arguments and modifies the `Configuration` of the `Tool`. The application-specific options are passed along without being modified.

See Also:
  - `Tool`
  - `GenericOptionsParser`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ToolRunner()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static boolean`
  `confirmPrompt(String prompt)`
  Print out a prompt to the user, and return true if the user responds with "y" or "yes".
  `static void`
  `printGenericCommandUsage(PrintStream out)`
  Prints generic command-line argurments and usage information.
  `static int`
  `run(Configuration conf, Tool tool, String[] args)`
  Runs the given `Tool` by `Tool.run(String[])`, after parsing with the given generic arguments.
  `static int`
  `run(Tool tool, String[] args)`
  Runs the `Tool` with its `Configuration`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ToolRunner

    public ToolRunner()

- ## Method Details

  - ### run

    public static int run(Configuration conf, Tool tool, String[] args) throws Exception
    Runs the given `Tool` by `Tool.run(String[])`, after parsing with the given generic arguments. Uses the given `Configuration`, or builds one if null. Sets the `Tool`'s configuration with the possibly modified version of the `conf`.
    Parameters:
      `conf` - `Configuration` for the `Tool`.
      `tool` - `Tool` to run.
      `args` - command-line arguments to the tool.
    Returns:
      exit code of the `Tool.run(String[])` method.
    Throws:
      `Exception` - Exception.

  - ### run

    public static int run(Tool tool, String[] args) throws Exception
    Runs the `Tool` with its `Configuration`. Equivalent to `run(tool.getConf(), tool, args)`.
    Parameters:
      `tool` - `Tool` to run.
      `args` - command-line arguments to the tool.
    Returns:
      exit code of the `Tool.run(String[])` method.
    Throws:
      `Exception` - exception.

  - ### printGenericCommandUsage

    public static void printGenericCommandUsage(PrintStream out)
    Prints generic command-line argurments and usage information.
    Parameters:
      `out` - stream to write usage information to.

  - ### confirmPrompt

    public static boolean confirmPrompt(String prompt) throws IOException
    Print out a prompt to the user, and return true if the user responds with "y" or "yes". (case insensitive).
    Parameters:
      `prompt` - prompt.
    Returns:
      if the user responds with "y" or "yes". (case insensitive) true, not false.
    Throws:
      `IOException` - raised on errors performing I/O.