Map错误-尝试在600秒后超时

s4chpxco  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(372)

我使用的是hadoop2.2.0,在运行map任务时出现以下错误
尝试\u 在1800000秒后超时
(这是1800000,因为我更改了mapreduce.task.timeout的配置)。
下面是我的Map代码:

public class MapTask
{
 ContentOfFiles fileContent= new ContentOfFiles();
 @Override
 public void map(LongWritable key, Text value, Context context)
 {
   String line = value.toString(); 
   String splits[] = line.split("\\t");
   List<String> sourceList = Arrays.aslist(splits);
   String finalOutput = fileContent.getContentOfFile(sourceList);
   context.write(NullWritable.get, new Text(finalOutput));  
 }
}

这是我的contentoffiles课程

public class ContentOFFiles
{
  public String getContentOfFile(List<String>sourceList)
   {
     String returnContentOfFile;
     for(List sourceList:sourceLists)
      {
        //Open the files and get the content and then append it to the String returnContentOfFile
      }
    return returnContentOfFile;
   }
}

当我运行我的Map任务时,我得到的错误是
尝试在1800000秒后超时。
我想知道的是如何告诉hadoop我的任务仍在运行。
我在Map中调用contentoffiles类。那么有没有办法告诉我的Map任务还在运行呢。我尝试将配置mapreduce.task.timeout更改为1800000,但仍然会出现相同的错误。
我再次使用hadoop2.2,如果有人能告诉我如何在新的api中处理这个问题,那就太好了。

bttbmeg0

bttbmeg01#

你可以尝试添加 context.progress(); 在mapper中的每个长操作结束后。据我所知,最好的地方是 for 周期:

public String getContentOfFile(List < String > sourceList, Context context) {
    String returnContentOfFile;
    for (List sourceList: sourceLists) {
        //Open the files and get the content and then append it to the String returnContentOfFile
        context.progres(); // report on progress
    }
    return returnContentOfFile;
}

相关问题