Search in sources :

Example 36 with GetStatusPOptions

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());
}
Also used : DeletePOptions(alluxio.grpc.DeletePOptions) URIStatus(alluxio.client.file.URIStatus) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test)

Example 37 with GetStatusPOptions

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;
}
Also used : GetStatusPOptions(alluxio.grpc.GetStatusPOptions)

Example 38 with GetStatusPOptions

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());
    }
}
Also used : IOException(java.io.IOException) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) AlluxioException(alluxio.exception.AlluxioException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

GetStatusPOptions (alluxio.grpc.GetStatusPOptions)38 Test (org.junit.Test)34 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)26 AlluxioURI (alluxio.AlluxioURI)17 URIStatus (alluxio.client.file.URIStatus)12 File (java.io.File)9 ListStatusPOptions (alluxio.grpc.ListStatusPOptions)6 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)4 DeletePOptions (alluxio.grpc.DeletePOptions)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 FileInfo (alluxio.wire.FileInfo)2 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 AlluxioException (alluxio.exception.AlluxioException)1 SetAttributePOptions (alluxio.grpc.SetAttributePOptions)1 GrpcCallTracker (alluxio.master.file.contexts.GrpcCallTracker)1 Mode (alluxio.security.authorization.Mode)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1