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


Java FileSystem.access方法代码示例

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


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

示例1: assertDirPermissionGranted

import org.apache.hadoop.fs.FileSystem; //导入方法依赖的package包/类
/**
 * Asserts that permission is granted to the given fs/user for the given
 * directory.
 *
 * @param fs FileSystem to check
 * @param user UserGroupInformation owner of fs
 * @param pathToCheck Path directory to check
 * @throws Exception if there is an unexpected error
 */
private static void assertDirPermissionGranted(FileSystem fs,
    UserGroupInformation user, Path pathToCheck) throws Exception {
  try {
    fs.listStatus(pathToCheck);
    fs.access(pathToCheck, FsAction.READ);
  } catch (AccessControlException e) {
    fail("expected permission granted for user " + user + ", path = " +
      pathToCheck);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestAclWithSnapshot.java

示例2: compact

import org.apache.hadoop.fs.FileSystem; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public CompactionResponse compact() throws Exception {
    Validate.notNull(criteria, "Criteria cannot be null");
    log.info("In place compaction requested for input path {}", criteria.getSourcePath());
    final URI uri = URI.create(criteria.getSourcePath());
    final FileSystem fileSystem = FileSystem.get(uri, configuration);

    final String tempCompactedLocation = TEMP_OUTPUT_LOCATION + "compacted-" + UUID.randomUUID().toString() + "/";
    final Path tempLocation = new Path(TEMP_OUTPUT_LOCATION + UUID.randomUUID().toString() + "/");
    try {
        fileSystem.access(new Path(criteria.getSourcePath()), FsAction.WRITE);
    } catch (AccessControlException e) {
        throw new IllegalStateException(String.format("User does not have permissions to perform move/delete for location %s", criteria.getSourcePath()));
    }
    // Perform normal compaction from Source --> TempTargetLocation
    log.info("Performing Normal Compaction from Source {} to Temp Target {}", criteria.getSourcePath(), tempCompactedLocation);
    final CompactionCriteria compactionCriteria = new CompactionCriteria(criteria.getSourcePath(), tempCompactedLocation, criteria.getThresholdInBytes());
    final CompactionManager compactionManager = new CompactionManagerImpl(configuration, compactionCriteria);
    final CompactionResponse response = compactionManager.compact();

    log.info("Moving files from input path {} to temp path {}", criteria.getSourcePath(), tempLocation.toString());
    fileSystem.rename(new Path(criteria.getSourcePath()), tempLocation);

    log.info("Moving compacted files from temp compacted path {} to final location {}", tempCompactedLocation, criteria.getSourcePath());
    fileSystem.rename(new Path(tempCompactedLocation), new Path(criteria.getSourcePath()));
    return response;
}
 
开发者ID:ExpediaInceCommercePlatform,项目名称:dataSqueeze,代码行数:30,代码来源:CompactionManagerInPlaceImpl.java


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