Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache Hadoop DistributedCache缓存没有绝对路径的文件?_Apache_Hadoop_Mapreduce_Yarn_Distributed Caching - Fatal编程技术网

Apache Hadoop DistributedCache缓存没有绝对路径的文件?

Apache Hadoop DistributedCache缓存没有绝对路径的文件?,apache,hadoop,mapreduce,yarn,distributed-caching,Apache,Hadoop,Mapreduce,Yarn,Distributed Caching,我正在迁移到Thread的过程中,DistributedCache的行为似乎发生了变化 在此之前,我将向缓存中添加一些文件,如下所示: for (String file : args) { Path path = new Path(cache_root, file); URI uri = new URI(path.toUri().toString()); DistributedCache.addCacheFile(uri, conf); } 路径通常如下所示 /some/pa

我正在迁移到Thread的过程中,DistributedCache的行为似乎发生了变化

在此之前,我将向缓存中添加一些文件,如下所示:

for (String file : args) {
   Path path = new Path(cache_root, file);
   URI uri = new URI(path.toUri().toString());
   DistributedCache.addCacheFile(uri, conf);
}
路径通常如下所示

/some/path/to/my/file.txt
它预先存在于HDFS上,基本上会作为

/$DISTRO_CACHE/some/path/to/my/file.txt
我可以在当前工作目录中对其进行符号链接,并与DistributedCache.getLocalCacheFiles()一起使用

对于Thread,该文件似乎会在缓存中以以下形式结束:

/$DISTRO_CACHE/file.txt
也就是说,文件URI的“路径”部分被删除,只剩下文件名

with如何处理以相同文件名结尾的不同绝对路径?考虑以下情况:

DistributedCache.addCacheFile("some/path/to/file.txt", conf);
DistributedCache.addCacheFile("some/other/path/to/file.txt", conf);
可以说有人可以使用片段:

DistributedCache.addCacheFile("some/path/to/file.txt#file1", conf);
DistributedCache.addCacheFile("some/other/path/to/file.txt#file2", conf);
但这似乎不必要地难以管理。想象一下,如果这些都是命令行参数,您需要管理这两个文件名,尽管不同的绝对路径在DistributedCache中肯定会冲突,因此需要将这些文件名重新映射到片段并传播到程序的其余部分


有没有更简单的方法来管理

尝试将文件添加到作业中

这很可能是您实际配置作业,然后在映射器中访问作业的方式

当你开始工作的时候,你会做一些类似的事情

    job.addCacheFile(new Path("cache/file1.txt").toUri());
    job.addCacheFile(new Path("cache/file2.txt").toUri());
然后在映射程序代码中,URL将存储在一个数组中,可以像这样访问

    URI file1Uri = context.getCacheFiles()[0];
    URI file2Uri = context.getCacheFiles()[1];

希望这能对您有所帮助。

这也行,但获取文件并不是真正的问题。它删除相对路径的部分使其有问题,原因有二:如果文件是参数,我不能简单地传播参数,因为它找不到(路径被删除)。还有两个文件名相同(但路径不同)的文件现在发生冲突(没有任何异常或错误)。这在之前不是一个问题,因为路径是按原样添加到DistributedCache的。