Search in sources :

Example 6 with GetStatusPOptions

use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.

the class UfsSyncIntegrationTest method getStatusDirSyncOnlyTouchingChildren.

// https://github.com/Alluxio/alluxio/issues/12372
@Test
public void getStatusDirSyncOnlyTouchingChildren() throws Exception {
    String dir1 = PathUtils.concatPath(EXISTING_DIR, "dir_should_sync");
    String dir2 = PathUtils.concatPath(dir1, "dir_should_not_sync");
    new File(ufsPath(dir1)).mkdirs();
    new File(ufsPath(dir2)).mkdirs();
    GetStatusPOptions optionsAlways = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_ALWAYS).build();
    checkGetStatus(EXISTING_DIR, optionsAlways, true);
    ListStatusPOptions optionsNever = ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_NEVER).setRecursive(false).build();
    checkListStatus(dir2, optionsNever, false);
}
Also used : File(java.io.File) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) ListStatusPOptions(alluxio.grpc.ListStatusPOptions) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 7 with GetStatusPOptions

use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.

the class UfsSyncIntegrationTest method ufsMetadataContentChange.

@Test
public void ufsMetadataContentChange() throws Exception {
    FileSystemTestUtils.loadFile(mFileSystem, alluxioPath(EXISTING_FILE));
    GetStatusPOptions options = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_ALWAYS).build();
    URIStatus status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
    Assert.assertNotNull(status);
    long prevFileid = status.getFileId();
    // Set the mode for the file
    FileUtils.changeLocalFilePermission(ufsPath(EXISTING_FILE), "rwxrwxrwx");
    status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
    Assert.assertNotNull(status);
    // Make sure the mode is correctly updated with a metadata change only
    assertEquals(FileUtils.translatePosixPermissionToMode(PosixFilePermissions.fromString("rwxrwxrwx")), status.getMode());
    // Change the permission of the file and the file id should not change
    assertEquals(prevFileid, status.getFileId());
    // Change the content of the file and the file id should change as a result because it is
    // deleted and reloaded.
    writeUfsFile(ufsPath(EXISTING_FILE), 2);
    status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
    Assert.assertNotNull(status);
    Assert.assertNotEquals(prevFileid, status.getFileId());
}
Also used : URIStatus(alluxio.client.file.URIStatus) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 8 with GetStatusPOptions

use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.

the class LoadMetadataIntegrationTest method loadAlwaysConfiguration.

@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.USER_FILE_METADATA_LOAD_TYPE, "ALWAYS" })
@Test
public void loadAlwaysConfiguration() throws Exception {
    GetStatusPOptions options = GetStatusPOptions.getDefaultInstance();
    checkGetStatus("/mnt/dir1/dirA/fileDNE1", options, false, false, 1);
    checkGetStatus("/mnt/dir1/dirA/fileDNE1", options, false, false, 1);
}
Also used : GetStatusPOptions(alluxio.grpc.GetStatusPOptions) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 9 with GetStatusPOptions

use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.

the class LoadMetadataIntegrationTest method loadMetadataOnceAfterUfsCreate.

@Test
public void loadMetadataOnceAfterUfsCreate() throws Exception {
    GetStatusPOptions options = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.ONCE).build();
    // dirB does not exist yet
    checkGetStatus("/mnt/dir1/dirA/dirB/file", options, false, false, 1);
    // create dirB in UFS
    assertTrue(new File(mLocalUfsPath + "/dir1/dirA/dirB").mkdirs());
    // 'ONCE' still should not load the metadata
    checkGetStatus("/mnt/dir1/dirA/dirB/file", options, false, false, 0);
    // load metadata for dirB with 'ALWAYS'
    checkGetStatus("/mnt/dir1/dirA/dirB", GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.ALWAYS).build(), true, true, 3);
    // 'ONCE' should now load the metadata, but will be handled by the absent cache,
    // so no need to go to the ufs
    checkGetStatus("/mnt/dir1/dirA/dirB/file", options, false, false, 0);
}
Also used : File(java.io.File) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 10 with GetStatusPOptions

use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.

the class LoadMetadataIntegrationTest method loadMetadataOnceAfterUfsDelete.

@Test
public void loadMetadataOnceAfterUfsDelete() throws Exception {
    GetStatusPOptions options = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.ONCE).build();
    // create dirB in UFS
    assertTrue(new File(mLocalUfsPath + "/dir1/dirA/dirB").mkdirs());
    checkGetStatus("/mnt/dir1/dirA/dirB/file", options, false, false, 1);
    checkGetStatus("/mnt/dir1/dirA/dirB/file", options, false, false, 0);
    // delete dirB in UFS
    assertTrue(new File(mLocalUfsPath + "/dir1/dirA/dirB").delete());
    // 'ONCE' should not be affected if UFS is changed
    checkGetStatus("/mnt/dir1/dirA/dirB/file", options, false, false, 0);
    // force load metadata with 'ALWAYS'
    checkGetStatus("/mnt/dir1/dirA/dirB", GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.ALWAYS).build(), false, false, 1);
    // 'ONCE' should still not load metadata, since the ancestor is absent
    checkGetStatus("/mnt/dir1/dirA/dirB/file", options, false, false, 0);
}
Also used : File(java.io.File) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

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