简体   繁体   English

如何从Java运行MapReduceIndexerTool作业?

[英]How to run MapReduceIndexerTool job from Java?

I want to run MapReduceIndexerTool from Java. 我想从Java运行MapReduceIndexerTool。

Right now I do it from command line using hadoop jar as you can see here , but I want to check it's status (to see if it's finalized, in progress, etc.) from Java code. 现在,我可以从命令行使用hadoop jar如您在此处看到的那样,但是我想从Java代码中检查它的状态(以查看它是否已完成,正在进行中,等等)。

So basically I want to run it from Java in order to be able to check it's status from Java. 因此,基本上我想从Java运行它,以便能够从Java检查它的状态。 Is there a way to run it from command line and check it's status from Java? 有没有一种方法可以从命令行运行它并从Java检查它的状态?

Also, there is a way to make Map Reduce to send an event (on a callback for example) when a job is completed? 另外,有一种方法可以使Map Reduce在作业完成时发送事件(例如在回调上)? Something like a webhook? 像个网络挂钩?

As far as I know Tool interface exposes only int run(String[] args) method, so in general you would create new instance, form proper argument string and call that method. 据我所知,Tool接口仅公开int run(String[] args)方法,因此通常您将创建新实例,形成适当的参数字符串并调用该方法。

From other hand, MapReduceIndexerTool has int run(Options options) method, that could be used to run it without forming shell-style argument. 另一方面, MapReduceIndexerTool具有int run(Options options)方法,该方法可用于运行它而无需形成shell样式参数。 However, this method is protected, so this will need to have calling class to be created in same package as MapReduceIndexerTool . 但是,此方法受到保护,因此需要在与MapReduceIndexerTool相同的程序包中创建调用类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM