Fork me on GitHub

MapReduce程序异常捕获存储

在Map或reduce中使用multipleOutput来进行异常存储:

1
2
3
4
5
6
7
8
9
try{
...
...
context.write(newKey,newValue);
}catch(Exception e){
multipleOutput.write(new Text( null == e.getMessage()? ("error:"): e.getMessage),new Text(value.toString()),"_error/part");
e.printStackTrace();
}

------------- The endThanks for reading-------------