YARN DistributedShell源码分析与修改(6)

// 把HDFS中的jar、archive加载到container的LocalResources,也就是从HDFS分发到container节点的过程 ↓↓↓↓↓↓↓↓↓↓↓↓↓ for (DshellFile perJar : DshellApplicationMaster.this.scistorJars) { LocalResource jarRsrc = (LocalResource) Records.newRecord(LocalResource.class); jarRsrc.setType(LocalResourceType.FILE); jarRsrc.setVisibility(LocalResourceVisibility.APPLICATION); try { jarRsrc.setResource( ConverterUtils.getYarnUrlFromURI(new URI(perJar.getJarPath() .toString()))); } catch (URISyntaxException e1) { DshellApplicationMaster.LOG.error("Error when trying to use JAR path specified in env, path=" + perJar.getJarPath(), e1); DshellApplicationMaster.this.numCompletedContainers.incrementAndGet(); DshellApplicationMaster.this.numFailedContainers.incrementAndGet(); return; } jarRsrc.setTimestamp(perJar.getTimestamp().longValue()); jarRsrc.setSize(perJar.getSize().longValue()); String[] tmp = perJar.getJarPath().split("/"); localResources.put(tmp[(tmp.length - 1)], jarRsrc); } String[] tmp; for (DshellArchive perArchive : DshellApplicationMaster.this.scistorArchives) { LocalResource archiveRsrc = (LocalResource) Records.newRecord(LocalResource.class); archiveRsrc.setType(LocalResourceType.ARCHIVE); archiveRsrc.setVisibility(LocalResourceVisibility.APPLICATION); try { archiveRsrc.setResource( ConverterUtils.getYarnUrlFromURI(new URI(perArchive .getArchivePath().toString()))); } catch (URISyntaxException e1) { DshellApplicationMaster.LOG.error("Error when trying to use ARCHIVE path specified in env, path=" + perArchive.getArchivePath(), e1); DshellApplicationMaster.this.numCompletedContainers.incrementAndGet(); DshellApplicationMaster.this.numFailedContainers.incrementAndGet(); return; } archiveRsrc.setTimestamp(perArchive.getTimestamp().longValue()); archiveRsrc.setSize(perArchive.getSize().longValue()); tmp = perArchive.getArchivePath().split("/"); String[] tmptmp = tmp[(tmp.length - 1)].split("[.]"); localResources.put(tmptmp[0], archiveRsrc); } // ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

4.3 DSConstants类

DSConstants类中是在Client和ApplicationMaster中的常量,对DSConstants类的修改为:增加了container_files、container_archives相关常量。修改代码如下:

// 增加container_files、container_archives相关常量 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ public static final String DISTRIBUTEDJARLOCATION = "DISTRIBUTEDJARLOCATION"; public static final String DISTRIBUTEDJARTIMESTAMP = "DISTRIBUTEDJARTIMESTAMP"; public static final String DISTRIBUTEDJARLEN = "DISTRIBUTEDJARLEN"; public static final String DISTRIBUTEDARCHIVELOCATION = "DISTRIBUTEDARCHIVELOCATION"; public static final String DISTRIBUTEDARCHIVETIMESTAMP = "DISTRIBUTEDARCHIVETIMESTAMP"; public static final String DISTRIBUTEDARCHIVELEN = "DISTRIBUTEDARCHIVELEN"; // ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

4.4 Log4jPropertyHelper类

对Log4jPropertyHelper类无任何改动。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/cb101bc55df5e3fc8538c314a0022fe0.html