将 Hadoop MapReduce 本地资源可见性更改为 PUBLIC

Change Hadoop MapReduce local resource visibility to PUBLIC

有没有办法设置由 hadoop 通用选项 -files 或 -archives 提供的 hadoop mapreduce 本地资源的 YARN 可见性。查看 yarn-site.xml 我发现使用 -archives 选项将文件写入工作节点的位置,但根据我读过的其他文章和它所在的目录 (/hadoop/yarn/local/usercache/myusername/appcache)被视为私人。我找不到任何通用选项或 -D some.yarn.setting 将其从私有更改为应用程序或更好,public。

我查看了 Hadoop 代码。这些参数(mapreduce.job.cache.files.visibilitiesmapreduce.job.cache.archives.visibilities)不能通过配置设置。

这些参数定义在MRJobConfig.java:

  public static final String CACHE_FILE_VISIBILITIES = "mapreduce.job.cache.files.visibilities";

  public static final String CACHE_ARCHIVES_VISIBILITIES = "mapreduce.job.cache.archives.visibilities";

org.apache.hadoop.mapreduce.JobResourceUploader.java,有一个函数 uploadFiles()。此函数将临时文件、jar 和存档上传到分布式缓存:

此函数通过调用以下函数来确定文件和存档的可见性:

// set the public/private visibility of the archives and files
ClientDistributedCacheManager.determineTimestampsAndCacheVisibilities(conf);

上述函数调用,最终命中了org.apache.hadoop.mapreduce.filecache.ClientDistributedCacheManager.java

中的determineCacheVisibilities()函数

根据这个函数的描述:

/**
   * Determines the visibilities of the distributed cache files and 
   * archives. The visibility of a cache path is "public" if the leaf component
   * has READ permissions for others, and the parent subdirs have 
   * EXECUTE permissions for others
   * @param job
   * @throws IOException
   */
  public static void determineCacheVisibilities(Configuration job,

因此可见性是根据叶文件和父目录的权限确定的。

ClientDistributedCacheManager.java中,isPublic()方法有计算可见度的逻辑:

//the leaf level file should be readable by others
if (!checkPermissionOfOther(fs, current, FsAction.READ, statCache)) {
  return false;
}
return ancestorsHaveExecutePermissions(fs, current.getParent(), statCache);

最后确定权限后,在以下函数中设置可见性:

  static void setArchiveVisibilities(Configuration conf, String booleans) {
    conf.set(MRJobConfig.CACHE_ARCHIVES_VISIBILITIES, booleans);
  }

  static void setFileVisibilities(Configuration conf, String booleans) {
    conf.set(MRJobConfig.CACHE_FILE_VISIBILITIES, booleans);
  }

所以,即使你在命令行中指定了这些配置,也不会考虑配置参数。这些配置由框架本身以编程方式设置。

此外,我检查了 mapred-default.xml。可见性没有默认配置参数。