gpt4 book ai didi

java - 找到接口(interface) org.apache.hadoop.mapreduce.TaskAttemptContext

转载 作者:可可西里 更新时间:2023-11-01 14:16:14 25 4
gpt4 key购买 nike

到目前为止还没有找到解决我的特定问题的方法。它至少不起作用。这让我很疯狂。这个特殊的组合在谷歌空间中似乎并不多。据我所知,我的错误发生在作业进入映射器时。该作业的输入是 avro 模式的输出,虽然我也尝试过未压缩,但它是用 deflate 压缩的。

阿夫罗:1.7.7Hadoop:2.4.1

我收到此错误,但我不确定原因。这是我的工作,mapper 和 reduce。映射器进来时发生错误。

示例未压缩的 Avro 输入文件(StockReport.SCHEMA 以这种方式定义)

{"day": 3, "month": 2, "year": 1986, "stocks": [{"symbol": "AAME", "timestamp": 507833213000, "dividend": 10.59}]}

工作

@Override
public int run(String[] strings) throws Exception {
Job job = Job.getInstance();
job.setJobName("GenerateGraphsJob");
job.setJarByClass(GenerateGraphsJob.class);

configureJob(job);

int resultCode = job.waitForCompletion(true) ? 0 : 1;

return resultCode;
}

private void configureJob(Job job) throws IOException {
try {
Configuration config = getConf();
Path inputPath = ConfigHelper.getChartInputPath(config);
Path outputPath = ConfigHelper.getChartOutputPath(config);

job.setInputFormatClass(AvroKeyInputFormat.class);
AvroKeyInputFormat.addInputPath(job, inputPath);
AvroJob.setInputKeySchema(job, StockReport.SCHEMA$);


job.setMapperClass(StockAverageMapper.class);
job.setCombinerClass(StockAverageCombiner.class);
job.setReducerClass(StockAverageReducer.class);

FileOutputFormat.setOutputPath(job, outputPath);

} catch (IOException | ClassCastException e) {
LOG.error("An job error has occurred.", e);
}
}

映射器:

public class StockAverageMapper extends
Mapper<AvroKey<StockReport>, NullWritable, StockYearSymbolKey, StockReport> {
private static Logger LOG = LoggerFactory.getLogger(StockAverageMapper.class);

private final StockReport stockReport = new StockReport();
private final StockYearSymbolKey stockKey = new StockYearSymbolKey();

@Override
protected void map(AvroKey<StockReport> inKey, NullWritable ignore, Context context)
throws IOException, InterruptedException {
try {
StockReport inKeyDatum = inKey.datum();
for (Stock stock : inKeyDatum.getStocks()) {
updateKey(inKeyDatum, stock);
updateValue(inKeyDatum, stock);
context.write(stockKey, stockReport);
}
} catch (Exception ex) {
LOG.debug(ex.toString());
}
}

map 输出键的架构:

    {
"namespace": "avro.model",
"type": "record",
"name": "StockYearSymbolKey",
"fields": [
{
"name": "year",
"type": "int"
},
{
"name": "symbol",
"type": "string"
}
]
}

堆栈跟踪:

java.lang.Exception: java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskAttemptContext, but class was expected
at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:522)
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskAttemptContext, but class was expected
at org.apache.avro.mapreduce.AvroKeyInputFormat.createRecordReader(AvroKeyInputFormat.java:47)
at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.<init>(MapTask.java:492)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:735)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340)
at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:243)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

编辑:这并不重要,但我正在努力将其减少为我可以从中创建 JFreeChart 输出的数据。没有通过映射器,所以不应该相关。

最佳答案

问题是 org.apache.hadoop.mapreduce.TaskAttemptContext 是 class in Hadoop 1但变成了interface in Hadoop 2 .

这就是为什么依赖于 Hadoop 库的库需要为 Hadoop 1 和 Hadoop 2 分别编译 jarfile 的原因之一。根据你的堆栈跟踪,你似乎以某种方式得到了一个 Hadoop1 编译的 Avro jarfile,尽管使用 Hadoop 2.4.1 运行。

download mirrors for Avroavro-mapred-1.7.7-hadoop1.jar 提供很好的单独下载对比avro-mapred-1.7.7-hadoop2.jar .

关于java - 找到接口(interface) org.apache.hadoop.mapreduce.TaskAttemptContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29448222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com