hadoop 失败的原因是什么?

What's the reason for this failure in hadoop?

我的hadoop作业在执行reduce任务时经常出现。 这个问题的一些原因可能是reducer 很长时间没有写上下文,所以你需要在你的代码中添加context.progress()。但是在我的reduce函数中,上下文写的很频繁。这是我的reduce函数:

public void reduce(Text key, Iterable<Text> values, Context context) throws 
      IOException,InterruptedException{
            Text s=new Text();
            Text exist=new Text("e");
            ArrayList<String> T=new ArrayList<String>();
            for(Text val:values){
                String value=val.toString();
                T.add(value);
                s.set(key.toString()+"-"+value);
                context.write(s,exist);
            }
            Text need=new Text("n");
            for(int i=0;i<T.size();++i){
                String a=T.get(i);
                for(int j=i+1;j<T.size();++j){
                    String b=T.get(j);
                    int f=a.compareTo(b);
                    if(f<0){
                        s.set(a+"-"+b);
                        context.write(s,need);
                    }
                    if(f>0){
                        s.set(b+"-"+a);
                        context.write(s,need);
                    }
                }
            }
        } 

可以看到循环中频繁写入上下文。 这次失败的原因是什么?我该如何处理?

您的任务需要超过 600 秒才能完成。

从 Apache 文档 page,您可以找到更多详细信息。

mapreduce.task.timeout

600000 ( default value in milli seconds)

The number of milliseconds before a task will be terminated if it neither reads an input, writes an output, nor updates its status string. A value of 0 disables the timeout.

可能的选项:

  1. 微调您的应用程序以在 600 秒内完成任务

  2. mapred-site.xml

    中增加参数mapreduce.task.timeout的超时