List of usage examples for org.apache.hadoop.yarn.api.records LocalResource setType
@Public @Stable public abstract void setType(LocalResourceType type);
LocalResourceType
of the resource to be localized. From source file:tachyon.yarn.Utils.java
License:Apache License
/** * Creates a local resource for a file on HDFS. * * @param yarnConf YARN configuration// www . jav a 2s. co m * @param resourcePath known path of resource file on HDFS * @throws IOException if the file can not be found on HDFS */ public static LocalResource createLocalResourceOfFile(YarnConfiguration yarnConf, String resourcePath) throws IOException { LocalResource localResource = Records.newRecord(LocalResource.class); Path jarHdfsPath = new Path(resourcePath); FileStatus jarStat = FileSystem.get(yarnConf).getFileStatus(jarHdfsPath); localResource.setResource(ConverterUtils.getYarnUrlFromPath(jarHdfsPath)); localResource.setSize(jarStat.getLen()); localResource.setTimestamp(jarStat.getModificationTime()); localResource.setType(LocalResourceType.FILE); localResource.setVisibility(LocalResourceVisibility.PUBLIC); return localResource; }
From source file:terasort.utils.Utils.java
License:Apache License
public static LocalResource createLocalResource(FileSystem fs, Path file) throws IOException { final LocalResourceType type = LocalResourceType.FILE; final LocalResourceVisibility visibility = LocalResourceVisibility.APPLICATION; FileStatus fstat = fs.getFileStatus(file); org.apache.hadoop.yarn.api.records.URL resourceURL = ConverterUtils.getYarnUrlFromPath(file); long resourceSize = fstat.getLen(); long resourceModificationTime = fstat.getModificationTime(); LocalResource lr = Records.newRecord(LocalResource.class); lr.setResource(resourceURL);// ww w. j ava 2s.com lr.setType(type); lr.setSize(resourceSize); lr.setVisibility(visibility); lr.setTimestamp(resourceModificationTime); return lr; }
From source file:yarnkit.utils.YarnUtils.java
License:Apache License
@Nonnull public static LocalResource createLocalResource(@Nonnull FileSystem fs, @Nonnull Path hdfsPath) throws IOException { LocalResource resource = Records.newRecord(LocalResource.class); FileStatus fileStat = fs.getFileStatus(hdfsPath); resource.setResource(ConverterUtils.getYarnUrlFromPath(hdfsPath)); resource.setSize(fileStat.getLen()); resource.setTimestamp(fileStat.getModificationTime()); resource.setType(fileStat.isFile() ? LocalResourceType.FILE : LocalResourceType.ARCHIVE); resource.setVisibility(LocalResourceVisibility.APPLICATION); return resource; }
From source file:yrun.YarnRunner.java
License:Apache License
private void setupAppMasterArgs(Path yarnRunnerArgsPath, LocalResource appMasterArgs) throws IOException { FileSystem fileSystem = yarnRunnerArgsPath.getFileSystem(_configuration); FileStatus jarStatus = fileSystem.getFileStatus(yarnRunnerArgsPath); appMasterArgs.setResource(ConverterUtils.getYarnUrlFromPath(yarnRunnerArgsPath)); appMasterArgs.setSize(jarStatus.getLen()); appMasterArgs.setTimestamp(jarStatus.getModificationTime()); appMasterArgs.setType(LocalResourceType.FILE); appMasterArgs.setVisibility(LocalResourceVisibility.PUBLIC); }
From source file:yrun.YarnRunner.java
License:Apache License
private void setupAppMasterJar(Path jarPath, LocalResource appMasterJar) throws IOException { FileSystem fileSystem = jarPath.getFileSystem(_configuration); FileStatus jarStatus = fileSystem.getFileStatus(jarPath); appMasterJar.setResource(ConverterUtils.getYarnUrlFromPath(jarPath)); appMasterJar.setSize(jarStatus.getLen()); appMasterJar.setTimestamp(jarStatus.getModificationTime()); appMasterJar.setType(LocalResourceType.FILE); appMasterJar.setVisibility(LocalResourceVisibility.PUBLIC); }