Hadoop实践(三)---Hadoop API 之 ToolRunner

来源:互联网 发布:淘宝标题商标侵权 编辑:程序博客网 时间:2024/05/17 04:34

ToolRunner

ToolRunner可用于运行实现Tool接口的类。 它与GenericOptionsParser(通用选项解析器)一起工作以解析通用hadoop命令行参数并修改Tool的配置。 应用程序特定的选项将会不经修改就传递。

包含的方法

类型 方法 描述 static boolean confirmPrompt(String prompt) 向用户打印提示,如果用户使用“y”或“yes”响应,则返回true static void printGenericCommandUsage(PrintStream out) 打印通用命令行参数和使用信息 static int run(Configuration conf, Tool tool, String[] args) 在使用给定的泛型参数解析之后,通过Tool.run(String [])运行给定的工具 static int run(Tool tool, String[] args) 运行工具及其配置

从类java.lang.Object继承的方法:

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

例子:

public static boolean confirmPrompt(String prompt) throws IOException向用户打印提示,如果用户使用“y”或“yes”响应,则返回true。 (不区分大小写)Throws:IOException
public static void printGenericCommandUsage(PrintStream out)打印通用命令行参数和使用信息Parameters:out - stream to write usage information to.
public static int run(Configuration conf,Tool tool,String[] args)throws Exception在使用给定的泛型参数解析之后,通过Tool.run(String [])运行给定的工具。使用给定的配置,或如果为null则构建一个。使用可能修改的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
public static int run(Tool tool,String[] args)throws Exception运行工具及其配置。相当于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.(Tool.run方法的退出代码)Throws:Exception
0 0
原创粉丝点击