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

时间:2015-10-15 16:23:18

标签: hadoop mapreduce visibility yarn

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

1 个答案:

答案 0 :(得分:1)

我浏览了Hadoop代码。这些参数( mapreduce.job.cache.files.visibilities mapreduce.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。可见性没有默认配置参数。