本文整理汇总了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);
}
}
示例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;
}