Java Code Examples for org.apache.hadoop.yarn.api.records.LocalResource#setPattern()

The following examples show how to use org.apache.hadoop.yarn.api.records.LocalResource#setPattern() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestFSDownload.java    From hadoop with Apache License 2.0 6 votes vote down vote up
static LocalResource createJar(FileContext files, Path p,
    LocalResourceVisibility vis) throws IOException {
  LOG.info("Create jar file " + p);
  File jarFile = new File((files.makeQualified(p)).toUri());
  FileOutputStream stream = new FileOutputStream(jarFile);
  LOG.info("Create jar out stream ");
  JarOutputStream out = new JarOutputStream(stream, new Manifest());
  LOG.info("Done writing jar stream ");
  out.close();
  LocalResource ret = recordFactory.newRecordInstance(LocalResource.class);
  ret.setResource(ConverterUtils.getYarnUrlFromPath(p));
  FileStatus status = files.getFileStatus(p);
  ret.setSize(status.getLen());
  ret.setTimestamp(status.getModificationTime());
  ret.setType(LocalResourceType.PATTERN);
  ret.setVisibility(vis);
  ret.setPattern("classes/.*");
  return ret;
}
 
Example 2
Source File: TestFSDownload.java    From big-c with Apache License 2.0 6 votes vote down vote up
static LocalResource createJar(FileContext files, Path p,
    LocalResourceVisibility vis) throws IOException {
  LOG.info("Create jar file " + p);
  File jarFile = new File((files.makeQualified(p)).toUri());
  FileOutputStream stream = new FileOutputStream(jarFile);
  LOG.info("Create jar out stream ");
  JarOutputStream out = new JarOutputStream(stream, new Manifest());
  LOG.info("Done writing jar stream ");
  out.close();
  LocalResource ret = recordFactory.newRecordInstance(LocalResource.class);
  ret.setResource(ConverterUtils.getYarnUrlFromPath(p));
  FileStatus status = files.getFileStatus(p);
  ret.setSize(status.getLen());
  ret.setTimestamp(status.getModificationTime());
  ret.setType(LocalResourceType.PATTERN);
  ret.setVisibility(vis);
  ret.setPattern("classes/.*");
  return ret;
}
 
Example 3
Source File: DagTypeConverters.java    From incubator-tez with Apache License 2.0 6 votes vote down vote up
public static Map<String, LocalResource> createLocalResourceMapFromDAGPlan(
    List<PlanLocalResource> localResourcesList) {
  Map<String, LocalResource> map = new HashMap<String, LocalResource>();
  for(PlanLocalResource res : localResourcesList){
    LocalResource r = new LocalResourcePBImpl();

    //NOTE: have to check every optional field in protobuf generated classes for existence before accessing
    //else we will receive a default value back, eg ""
    if(res.hasPattern()){
      r.setPattern(res.getPattern());
    }
    r.setResource(ConverterUtils.getYarnUrlFromPath(new Path(res.getUri())));  // see above notes on HDFS URL handling
    r.setSize(res.getSize());
    r.setTimestamp(res.getTimeStamp());
    r.setType(DagTypeConverters.convertFromDAGPlan(res.getType()));
    r.setVisibility(DagTypeConverters.convertFromDAGPlan(res.getVisibility()));
    map.put(res.getName(), r);
  }
  return map;
}
 
Example 4
Source File: DagTypeConverters.java    From tez with Apache License 2.0 6 votes vote down vote up
public static Map<String, LocalResource> createLocalResourceMapFromDAGPlan(
    List<PlanLocalResource> localResourcesList) {
  Map<String, LocalResource> map = new HashMap<String, LocalResource>();
  for(PlanLocalResource res : localResourcesList){
    LocalResource r = new LocalResourcePBImpl();

    //NOTE: have to check every optional field in protobuf generated classes for existence before accessing
    //else we will receive a default value back, eg ""
    if(res.hasPattern()){
      r.setPattern(res.getPattern());
    }
    r.setResource(convertToYarnURL(res.getUri()));
    r.setSize(res.getSize());
    r.setTimestamp(res.getTimeStamp());
    r.setType(DagTypeConverters.convertFromDAGPlan(res.getType()));
    r.setVisibility(DagTypeConverters.convertFromDAGPlan(res.getVisibility()));
    map.put(res.getName(), r);
  }
  return map;
}