Search in sources :

Example 16 with GetStatusPOptions

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

the class UfsSyncIntegrationTest method ufsDirUpdatePermissions.

@Test
public void ufsDirUpdatePermissions() throws Exception {
    new File(ufsPath("/dir1")).mkdirs();
    new File(ufsPath("/dir1/dir2")).mkdirs();
    String fileA = "/dir1/dir2/fileA";
    writeUfsFile(ufsPath(fileA), 1);
    // Set the mode for the directory
    FileUtils.changeLocalFilePermission(ufsPath("/dir1"), "rwxrwxrwx");
    GetStatusPOptions options = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_ALWAYS).build();
    URIStatus status = mFileSystem.getStatus(new AlluxioURI(alluxioPath("/dir1")), options);
    Assert.assertNotNull(status);
    assertEquals(FileUtils.translatePosixPermissionToMode(PosixFilePermissions.fromString("rwxrwxrwx")), status.getMode());
    // Change the mode for the directory
    FileUtils.changeLocalFilePermission(ufsPath("/dir1"), "rwxr-xr-x");
    status = mFileSystem.getStatus(new AlluxioURI(alluxioPath("/dir1")), options);
    Assert.assertNotNull(status);
    assertEquals(FileUtils.translatePosixPermissionToMode(PosixFilePermissions.fromString("rwxr-xr-x")), status.getMode());
}
Also used : URIStatus(alluxio.client.file.URIStatus) File(java.io.File) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 17 with GetStatusPOptions

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

the class LoadMetadataCommandIntegrationTest method loadMetadataFileWithWildcard.

@Test
public void loadMetadataFileWithWildcard() 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.THROUGH, 30);
    AlluxioURI uriA = new AlluxioURI(filePathA);
    AlluxioURI uriB = new AlluxioURI(filePathB);
    URIStatus statusBeforeA = sFileSystem.getStatus(uriA);
    URIStatus statusBeforeB = sFileSystem.getStatus(uriB);
    // Delete testFileA's metadata and testFileB's metadata.
    DeletePOptions deletePOptions = DeletePOptions.newBuilder().setAlluxioOnly(true).setRecursive(true).build();
    sFileSystem.delete(uriA, deletePOptions);
    sFileSystem.delete(uriB, deletePOptions);
    // Load metadata from ufs.
    sFsShell.run("loadMetadata", "/*/*/*/*/testFile*");
    // 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 18 with GetStatusPOptions

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

the class LoadMetadataCommandIntegrationTest method loadMetadataFileRecursive.

@Test
public void loadMetadataFileRecursive() throws IOException, AlluxioException {
    String filePath = "/testRoot/layer1/layer2/layer3/testFile";
    FileSystemTestUtils.createByteFile(sFileSystem, filePath, WritePType.CACHE_THROUGH, 10);
    AlluxioURI uri = new AlluxioURI(filePath);
    URIStatus statusBefore = sFileSystem.getStatus(uri);
    DeletePOptions deletePOptions = DeletePOptions.newBuilder().setAlluxioOnly(true).setRecursive(true).build();
    sFileSystem.delete(uri, deletePOptions);
    // Load metadata at /testRoot layer with -R option.
    sFsShell.run("loadMetadata", "-R", "/testRoot");
    // Use LoadMetadataPType.NEVER to avoid loading metadata during get file status
    GetStatusPOptions getStatusPOptions = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).build();
    URIStatus statusAfter = sFileSystem.getStatus(uri, getStatusPOptions);
    assertEquals(statusBefore.getFileInfo().getName(), statusAfter.getFileInfo().getName());
    assertEquals(statusBefore.getFileInfo().getLength(), statusAfter.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 19 with GetStatusPOptions

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

the class PinIntegrationTest method pinDiscoverNewFiles.

/**
 * Make sure Pinning and Unpinning would recursively sync the directory if ufs sync is on.
 */
@Test
public void pinDiscoverNewFiles() throws Exception {
    String deeplyNestedDir = "/tmp/tmp2/tmp3";
    // Create a dir
    new File(ufsPath(deeplyNestedDir)).mkdirs();
    // Write a file in UFS
    FileWriter fileWriter = new FileWriter(ufsPath(PathUtils.concatPath(deeplyNestedDir, "/newfile")));
    fileWriter.write("test");
    fileWriter.close();
    SetAttributePOptions attributeOption = SetAttributePOptions.newBuilder().setPinned(true).setCommonOptions(SYNC_ALWAYS).build();
    GetStatusPOptions getStatusOption = GetStatusPOptions.newBuilder().setCommonOptions(SYNC_NEVER).build();
    // Pin the dir
    mFileSystem.setAttribute(new AlluxioURI("/mnt/tmp/"), attributeOption);
    ServerConfiguration.set(PropertyKey.USER_FILE_METADATA_LOAD_TYPE, LoadMetadataType.NEVER.toString());
    URIStatus dirStat = mFileSystem.getStatus(new AlluxioURI("/mnt/tmp/"), getStatusOption);
    URIStatus fileStat = mFileSystem.getStatus(new AlluxioURI(PathUtils.concatPath("/mnt", deeplyNestedDir, "newfile")), getStatusOption);
    Assert.assertTrue(dirStat.isPinned());
    Assert.assertTrue(fileStat.isPinned());
}
Also used : SetAttributePOptions(alluxio.grpc.SetAttributePOptions) FileWriter(java.io.FileWriter) URIStatus(alluxio.client.file.URIStatus) File(java.io.File) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 20 with GetStatusPOptions

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

the class UfsSyncIntegrationTest method getStatusFileSyncInterval.

@Test
public void getStatusFileSyncInterval() throws Exception {
    GetStatusPOptions options = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_INTERVAL).build();
    long startMs = System.currentTimeMillis();
    URIStatus status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
    long startLength = status.getLength();
    int sizeFactor = 10;
    while (true) {
        writeUfsFile(ufsPath(EXISTING_FILE), sizeFactor);
        status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
        if (status.getLength() != startLength) {
            break;
        }
        sizeFactor++;
    }
    long endMs = System.currentTimeMillis();
    assertTrue((endMs - startMs) >= INTERVAL_MS);
}
Also used : URIStatus(alluxio.client.file.URIStatus) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) 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