当前位置: 首页>>代码示例>>Java>>正文


Java LocalResource.newInstance方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.api.records.LocalResource.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java LocalResource.newInstance方法的具体用法?Java LocalResource.newInstance怎么用?Java LocalResource.newInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.api.records.LocalResource的用法示例。


在下文中一共展示了LocalResource.newInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpLocalResources

import org.apache.hadoop.yarn.api.records.LocalResource; //导入方法依赖的package包/类
private void setUpLocalResources(ContainerLauncherEvent event) {
  String resourceFileName = event.getResourceFileName();
  String resourcePath = event.getResourceFilePath();
  if (resourcePath != "") {
    FileSystem fs = null;
    try {
      fs = FileSystem.get(new YarnConfiguration());
      Path dst = new Path(fs.getHomeDirectory(), resourcePath);
      boolean exists = fs.exists(dst);
      if (exists) {
        FileStatus scFileStatus = fs.getFileStatus(dst);
        LocalResource scRsrc = LocalResource.newInstance(ConverterUtils.getYarnUrlFromURI(dst.toUri()),
          LocalResourceType.FILE, LocalResourceVisibility.APPLICATION, scFileStatus.getLen(),
          scFileStatus.getModificationTime());
        localResources.put(resourceFileName, scRsrc);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
 
开发者ID:intel-hadoop,项目名称:yacop,代码行数:22,代码来源:DelegatingYacopEngine.java

示例2: addToLocalResources

import org.apache.hadoop.yarn.api.records.LocalResource; //导入方法依赖的package包/类
private void addToLocalResources(FileSystem fs, String fileSrcPath, String fileDstPath, String appId, Map<String, LocalResource> localResources, String resources) throws IOException {
  String suffix = yacopConfig.getName() + "/" + appId + "/" + fileDstPath;
  Path dst = new Path(fs.getHomeDirectory(), suffix);
  if (fileSrcPath == null) {
    FSDataOutputStream ostream = null;
    try {
      ostream = FileSystem.create(fs, dst, new FsPermission((short) 0710));
      ostream.writeUTF(resources);
    } finally {
      IOUtils.closeQuietly(ostream);
    }
  } else {
    fs.copyFromLocalFile(new Path(fileSrcPath), dst);
  }
  FileStatus scFileStatus = fs.getFileStatus(dst);
  LocalResource scRsrc = LocalResource.newInstance(ConverterUtils.getYarnUrlFromURI(dst.toUri()), LocalResourceType.FILE, LocalResourceVisibility.APPLICATION, scFileStatus.getLen(), scFileStatus.getModificationTime());
  localResources.put(fileDstPath, scRsrc);
}
 
开发者ID:intel-hadoop,项目名称:yacop,代码行数:19,代码来源:ActionSubmitApp.java

示例3: toLocalResource

import org.apache.hadoop.yarn.api.records.LocalResource; //导入方法依赖的package包/类
private LocalResource toLocalResource(Path path, LocalResourceVisibility visibility) throws IOException {
  FileSystem fs = path.getFileSystem(clusterConf.conf());
  FileStatus stat = fs.getFileStatus(path);
  return LocalResource.newInstance(
          ConverterUtils.getYarnUrlFromPath(path),
          LocalResourceType.FILE,
          visibility,
          stat.getLen(), stat.getModificationTime()
  );
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:11,代码来源:AthenaXYarnClusterDescriptor.java

示例4: addToLocalResources

import org.apache.hadoop.yarn.api.records.LocalResource; //导入方法依赖的package包/类
private static void addToLocalResources(FileSystem fs, String key, Path dst,
    Map<String, LocalResource> localResources) throws IOException {
  FileStatus scFileStatus = fs.getFileStatus(dst);
  LocalResource resource =
      LocalResource.newInstance(
          URL.fromURI(dst.toUri()),
          LocalResourceType.FILE, LocalResourceVisibility.APPLICATION,
          scFileStatus.getLen(), scFileStatus.getModificationTime());
  localResources.put(key, resource);
}
 
开发者ID:Intel-bigdata,项目名称:TensorFlowOnYARN,代码行数:11,代码来源:Utils.java

示例5: addToLocalResources

import org.apache.hadoop.yarn.api.records.LocalResource; //导入方法依赖的package包/类
private void addToLocalResources(FileSystem fs, String fileSrcPath,
    String fileDstPath, String appId, Map<String, LocalResource> localResources,
    String resources) throws IOException {
  String suffix =
      appName + "/" + appId + "/" + fileDstPath;
  Path dst =
      new Path(fs.getHomeDirectory(), suffix);
  if (fileSrcPath == null) {
    FSDataOutputStream ostream = null;
    try {
      ostream = FileSystem
          .create(fs, dst, new FsPermission((short) 0710));
      ostream.writeUTF(resources);
    } finally {
      IOUtils.closeQuietly(ostream);
    }
  } else {
    fs.copyFromLocalFile(new Path(fileSrcPath), dst);
  }
  FileStatus scFileStatus = fs.getFileStatus(dst);
  LocalResource scRsrc =
      LocalResource.newInstance(
          ConverterUtils.getYarnUrlFromURI(dst.toUri()),
          LocalResourceType.FILE, LocalResourceVisibility.APPLICATION,
          scFileStatus.getLen(), scFileStatus.getModificationTime());
  localResources.put(fileDstPath, scRsrc);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:Client.java

示例6: createLocalResource

import org.apache.hadoop.yarn.api.records.LocalResource; //导入方法依赖的package包/类
/**
 * Create a {@link LocalResource} record with all the given parameters.
 */
private static LocalResource createLocalResource(FileSystem fc, Path file,
    LocalResourceType type, LocalResourceVisibility visibility)
    throws IOException {
  FileStatus fstat = fc.getFileStatus(file);
  URL resourceURL = ConverterUtils.getYarnUrlFromPath(fc.resolvePath(fstat
      .getPath()));
  long resourceSize = fstat.getLen();
  long resourceModificationTime = fstat.getModificationTime();

  return LocalResource.newInstance(resourceURL, type, visibility,
    resourceSize, resourceModificationTime);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TaskAttemptImpl.java

示例7: getPathForLocalization

import org.apache.hadoop.yarn.api.records.LocalResource; //导入方法依赖的package包/类
/**
 * @return {@link Path} absolute path for localization which includes local
 *         directory path and the relative hierarchical path (if use local
 *         cache directory manager is enabled)
 * 
 * @param {@link LocalResourceRequest} Resource localization request to
 *        localize the resource.
 * @param {@link Path} local directory path
 */
@Override
public Path
    getPathForLocalization(LocalResourceRequest req, Path localDirPath) {
  Path rPath = localDirPath;
  if (useLocalCacheDirectoryManager && localDirPath != null) {

    if (!directoryManagers.containsKey(localDirPath)) {
      directoryManagers.putIfAbsent(localDirPath,
        new LocalCacheDirectoryManager(conf));
    }
    LocalCacheDirectoryManager dir = directoryManagers.get(localDirPath);

    rPath = localDirPath;
    String hierarchicalPath = dir.getRelativePathForLocalization();
    // For most of the scenarios we will get root path only which
    // is an empty string
    if (!hierarchicalPath.isEmpty()) {
      rPath = new Path(localDirPath, hierarchicalPath);
    }
    inProgressLocalResourcesMap.put(req, rPath);
  }

  rPath = new Path(rPath,
      Long.toString(uniqueNumberGenerator.incrementAndGet()));
  Path localPath = new Path(rPath, req.getPath().getName());
  LocalizedResource rsrc = localrsrc.get(req);
  rsrc.setLocalPath(localPath);
  LocalResource lr = LocalResource.newInstance(req.getResource(),
      req.getType(), req.getVisibility(), req.getSize(),
      req.getTimestamp());
  try {
    stateStore.startResourceLocalization(user, appId,
        ((LocalResourcePBImpl) lr).getProto(), localPath);
  } catch (IOException e) {
    LOG.error("Unable to record localization start for " + rsrc, e);
  }
  return rPath;
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:48,代码来源:LocalResourcesTrackerImpl.java

示例8: getPathForLocalization

import org.apache.hadoop.yarn.api.records.LocalResource; //导入方法依赖的package包/类
/**
 * @return {@link Path} absolute path for localization which includes local
 *         directory path and the relative hierarchical path (if use local
 *         cache directory manager is enabled)
 * 
 * @param {@link LocalResourceRequest} Resource localization request to
 *        localize the resource.
 * @param {@link Path} local directory path
 * @param {@link DeletionService} Deletion Service to delete existing
 *        path for localization.
 */
@Override
public Path getPathForLocalization(LocalResourceRequest req,
    Path localDirPath, DeletionService delService) {
  Path rPath = localDirPath;
  if (useLocalCacheDirectoryManager && localDirPath != null) {

    if (!directoryManagers.containsKey(localDirPath)) {
      directoryManagers.putIfAbsent(localDirPath,
        new LocalCacheDirectoryManager(conf));
    }
    LocalCacheDirectoryManager dir = directoryManagers.get(localDirPath);

    rPath = localDirPath;
    String hierarchicalPath = dir.getRelativePathForLocalization();
    // For most of the scenarios we will get root path only which
    // is an empty string
    if (!hierarchicalPath.isEmpty()) {
      rPath = new Path(localDirPath, hierarchicalPath);
    }
    inProgressLocalResourcesMap.put(req, rPath);
  }

  while (true) {
    Path uniquePath = new Path(rPath,
        Long.toString(uniqueNumberGenerator.incrementAndGet()));
    File file = new File(uniquePath.toUri().getRawPath());
    if (!file.exists()) {
      rPath = uniquePath;
      break;
    }
    // If the directory already exists, delete it and move to next one.
    LOG.warn("Directory " + uniquePath + " already exists, " +
        "try next one.");
    if (delService != null) {
      delService.delete(getUser(), uniquePath);
    }
  }

  Path localPath = new Path(rPath, req.getPath().getName());
  LocalizedResource rsrc = localrsrc.get(req);
  rsrc.setLocalPath(localPath);
  LocalResource lr = LocalResource.newInstance(req.getResource(),
      req.getType(), req.getVisibility(), req.getSize(),
      req.getTimestamp());
  try {
    stateStore.startResourceLocalization(user, appId,
        ((LocalResourcePBImpl) lr).getProto(), localPath);
  } catch (IOException e) {
    LOG.error("Unable to record localization start for " + rsrc, e);
  }
  return rPath;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:64,代码来源:LocalResourcesTrackerImpl.java


注:本文中的org.apache.hadoop.yarn.api.records.LocalResource.newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。