use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.
the class LoadMetadataCommandIntegrationTest method loadMetadataDir.
@Test
public void loadMetadataDir() throws IOException, AlluxioException {
String dirPath = "/testRoot/layer1/layer2/layer3/";
String filePathA = PathUtils.concatPath(dirPath, "testFileA");
String filePathB = PathUtils.concatPath(dirPath, "testFileB");
FileSystemTestUtils.createByteFile(sFileSystem, filePathA, WritePType.CACHE_THROUGH, 10);
FileSystemTestUtils.createByteFile(sFileSystem, filePathB, WritePType.CACHE_THROUGH, 30);
AlluxioURI uriDir = new AlluxioURI(dirPath);
AlluxioURI uriA = new AlluxioURI(filePathA);
AlluxioURI uriB = new AlluxioURI(filePathB);
URIStatus statusBeforeA = sFileSystem.getStatus(uriA);
URIStatus statusBeforeB = sFileSystem.getStatus(uriB);
// Delete layer3 directory metadata recursively.
DeletePOptions deletePOptions = DeletePOptions.newBuilder().setAlluxioOnly(true).setRecursive(true).build();
sFileSystem.delete(uriDir, deletePOptions);
// Load metadata from ufs.
sFsShell.run("loadMetadata", dirPath);
// Use LoadMetadataPType.NEVER to avoid loading metadata during get file status.
GetStatusPOptions getStatusPOptions = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).build();
// Check testFileA's metadata.
URIStatus statusAfterA = sFileSystem.getStatus(uriA, getStatusPOptions);
assertEquals(statusBeforeA.getFileInfo().getName(), statusAfterA.getFileInfo().getName());
assertEquals(statusBeforeA.getFileInfo().getLength(), statusAfterA.getFileInfo().getLength());
// Check testFileB's metadata.
URIStatus statusAfterB = sFileSystem.getStatus(uriB, getStatusPOptions);
assertEquals(statusBeforeB.getFileInfo().getName(), statusAfterB.getFileInfo().getName());
assertEquals(statusBeforeB.getFileInfo().getLength(), statusAfterB.getFileInfo().getLength());
}
use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.
the class BaseFileSystem method getStatus.
@Override
public URIStatus getStatus(AlluxioURI path, final GetStatusPOptions options) throws FileDoesNotExistException, IOException, AlluxioException {
checkUri(path);
URIStatus status = rpc(client -> {
GetStatusPOptions mergedOptions = FileSystemOptions.getStatusDefaults(mFsContext.getPathConf(path)).toBuilder().mergeFrom(options).build();
return client.getStatus(path, mergedOptions);
});
if (!status.isCompleted()) {
LOG.debug("File {} is not yet completed. getStatus will see incomplete metadata.", path);
}
return status;
}
use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.
the class MetadataCachingBaseFileSystem method asyncUpdateFileAccessTime.
/**
* Asynchronously update file's last access time.
*
* @param path the path to the file
*/
@VisibleForTesting
public void asyncUpdateFileAccessTime(AlluxioURI path) {
if (mDisableUpdateFileAccessTime) {
return;
}
try {
mAccessTimeUpdater.submit(() -> {
try {
AlluxioConfiguration conf = mFsContext.getPathConf(path);
GetStatusPOptions getStatusOptions = FileSystemOptions.getStatusDefaults(conf).toBuilder().setAccessMode(Bits.READ).setUpdateTimestamps(true).build();
super.getStatus(path, getStatusOptions);
} catch (IOException | AlluxioException e) {
LOG.error("Failed to update access time for " + path, e);
}
});
} catch (RejectedExecutionException e) {
LOG.warn("Failed to submit a task to update access time for {}: {}", path, e.toString());
}
}
Aggregations