简体   繁体   English

如何在Java中停止Hadoop作业

[英]How to stop a Hadoop job from within Java

I have an server setup that consists of 8 machines on which I run a Hadoop job to download certain assets. 我有一个服务器设置,由8台机器组成,我在其上运行Hadoop作业以下载某些资产。 A client side agent uses JobConf to start the Hadoop jobs. 客户端代理使用JobConf来启动Hadoop作业。

The agent gets a response code from the server based on which it can determine how the download proceeded. 代理从服务器获取响应代码,根据该代码可以确定下载的进行方式。 In the below code, invoke() creates a connection to the REST API exposed by the server. 在下面的代码中,invoke()创建与服务器公开的REST API的连接。 ResponseData is a custom class that can read the downloaded data off the connection associated with the response as below: ResponseData是一个自定义类,可以从与响应关联的连接中读取下载的数据,如下所示:

ResponseData res = invoke(downloadUrl, contentType);
downloadedAssetStream = New ObjectInputStream(res.connection.getInputStream);

if(res.code != 200)
{
    //Stop hadoop job
}

For stopping the job, what do I need? 为了停止工作,我需要什么? I've heard somewhere that throwing an IOException would do, but I haven't been able to verify it yet. 我听说过抛出一个IOException就可以了,但是我还没能验证它。

使用新MR API的Job#killJob或使用旧MR API的RunningJob#killJob终止 Job。

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

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