我收到 CDH4.0 错误 "The method addCacheFile(URI) is undefined for the type Job"

I am getting the error "The method addCacheFile(URI) is undefined for the type Job" with CDH4.0

我遇到错误

The method addCacheFile(URI) is undefined for the type Job

用CDH4.0尝试调用addCacheFile(URI uri)方法时,如下图:

import java.net.URI;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

public class DistributedCacheDriver {

    public static void main(String[] args) throws Exception {
        String inputPath = args[0];
        String outputPath = args[1];

        String fileName = args[2];
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf, "TestingDistributedCache");
        job.setJarByClass(DistributedCache.class);


        job.addCacheFile(new URI(fileName)); //Getting error here -The method addCacheFile(URI) is undefined for the type Job

        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0 : 1);
    }
}

任何 suggestions/hints 来消除这个错误?

如果您选择安装 MapReduce 版本 1,则应将 job.addCacheFile() 命令替换为 DistributeddCache.addCacheFile(); 并相应地更改 setup() 方法(将其命名为 configure() ).

查找一些官方文档和示例here