【发布时间】:2023-03-30 23:20:01
【问题描述】:
我写了一个 Map only hadoop 作业,我在其中使用了 MultipleOutputs 概念。这里的问题是,我想用 MRUnit 测试这段代码。我没有看到 MultipleOutputs 测试的任何工作示例。
我的映射器代码会是这样的,
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
String inputString = value.toString();
String outputString = null;
Text resultValue = null;
String finalResult = null;
String exceptionMessage = null;
try {
outputString = processInput(dataSet, inputString);
} catch (MalformedURLException me) {
System.out.println("MalformedURLException Occurred in Mapper:"
+ me.getMessage());
exceptionMessage = me.getMessage();
} catch (SolrServerException se) {
System.out.println("SolrServerException Occurred in Mapper:"
+ se.getMessage());
exceptionMessage = se.getMessage();
}
if (outputString == null || outputString.isEmpty()
&& exceptionMessage != null) {
exceptionMessage = exceptionMessage.replaceAll("\n", ", ");
finalResult = inputString + "\t[Error] =" + exceptionMessage;
resultValue = new Text(finalResult);
multipleOutputs.write(SearchConstants.FAILURE_FILE,NullWritable.get(), resultValue);
} else {
finalResult = inputString + outputString;
resultValue = new Text(finalResult);
multipleOutputs.write(SearchConstants.SUCCESS_FILE,NullWritable.get(), resultValue);
}
}
你们谁能给我一个使用 MultipleOutputs 进行 MRUnit 测试的工作示例吗?
【问题讨论】:
标签: mapreduce elastic-map-reduce amazon-emr mrunit multipleoutputs