Package org.apache.hadoop.util
Class ToolRunner
java.lang.Object
org.apache.hadoop.util.ToolRunner
A utility to help run
Tools.
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:
-
ToolGenericOptionsParser
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanconfirmPrompt(String prompt) Print out a prompt to the user, and return true if the user responds with "y" or "yes".static voidPrints generic command-line argurments and usage information.static intrun(Configuration conf, Tool tool, String[] args) Runs the givenToolbyTool.run(String[]), after parsing with the given generic arguments.static intRuns theToolwith itsConfiguration.
-
Constructor Details
-
ToolRunner
public ToolRunner()
-
-
Method Details
-
run
Runs the givenToolbyTool.run(String[]), after parsing with the given generic arguments. Uses the givenConfiguration, or builds one if null. Sets theTool's configuration with the possibly modified version of theconf.- Parameters:
conf-Configurationfor theTool.tool-Toolto run.args- command-line arguments to the tool.- Returns:
- exit code of the
Tool.run(String[])method. - Throws:
Exception- Exception.
-
run
Runs theToolwith itsConfiguration. Equivalent torun(tool.getConf(), tool, args).- Parameters:
tool-Toolto run.args- command-line arguments to the tool.- Returns:
- exit code of the
Tool.run(String[])method. - Throws:
Exception- exception.
-
printGenericCommandUsage
Prints generic command-line argurments and usage information.- Parameters:
out- stream to write usage information to.
-
confirmPrompt
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.
-