我在 Hadoop 2.x 的新 API 中的 DistributedCache 中遇到问题,我发现有人在解决这个问题,但它并没有解决我的问题示例
这个解决方案对我不起作用因为我在尝试检索 DistributedCache 中的数据时遇到了 NullPointerException
我的配置如下:
司机
public int run(String[] arg) throws Exception {
Configuration conf = this.getConf();
Job job= new Job(conf,"job Name");
...
job.addCacheFile(new URI(arg[1]);
设置
protected void setup(Context context)
throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
URI[] cacheFiles = context.getCacheFiles();
BufferedReader dtardr = new BufferedReader(new FileReader(cacheFiles[0].toString()));
在这里,当它开始创建缓冲读取器时,它会抛出 NullPointerException,这是因为context.getCacheFiles(); 始终返回 NULL。如何解决这个问题,缓存文件存储在哪里(HDFS,或本地文件系统)