Search in sources :

Example 26 with ListStatusPOptions

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

the class UfsSyncIntegrationTest method listStatusNoSync.

@Test
public void listStatusNoSync() throws Exception {
    ListStatusPOptions options = ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_NEVER).build();
    checkListStatus(EXISTING_DIR, options, false);
    checkListStatus(EXISTING_FILE, options, false);
    // Create new ufs paths.
    new File(ufsPath(NEW_DIR)).mkdirs();
    writeUfsFile(ufsPath(NEW_FILE), 2);
    checkListStatus(NEW_DIR, options, false);
    checkListStatus(NEW_FILE, options, false);
}
Also used : File(java.io.File) ListStatusPOptions(alluxio.grpc.ListStatusPOptions) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 27 with ListStatusPOptions

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

the class UfsSyncIntegrationTest method unpersistedFileSync.

@Test
public void unpersistedFileSync() throws Exception {
    ListStatusPOptions options = ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_ALWAYS).build();
    List<String> initialStatusList = mFileSystem.listStatus(new AlluxioURI(alluxioPath(ROOT_DIR)), options).stream().map(URIStatus::getName).collect(Collectors.toList());
    // write a MUST_CACHE file
    writeMustCacheFile(alluxioPath(NEW_FILE), 1);
    // List the status with force sync.
    List<String> syncStatusList = mFileSystem.listStatus(new AlluxioURI(alluxioPath(ROOT_DIR)), options).stream().map(URIStatus::getName).collect(Collectors.toList());
    Set<String> initialSet = Sets.newHashSet(initialStatusList);
    Set<String> syncSet = Sets.newHashSet(syncStatusList);
    assertTrue(syncSet.size() > initialSet.size());
    syncSet.removeAll(initialSet);
    // only the MUST_CACHE file should remain.
    assertTrue(syncSet.size() == 1);
    String file = syncSet.iterator().next();
    assertTrue(file.equals(new AlluxioURI(NEW_FILE).getName()));
}
Also used : ListStatusPOptions(alluxio.grpc.ListStatusPOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 28 with ListStatusPOptions

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

the class UfsSyncIntegrationTest method ufsDeleteChildrenSync.

@Test
public void ufsDeleteChildrenSync() throws Exception {
    // Create a UFS directory with several files
    // Force each file to have many blocks
    String baseDir = "/base_dir";
    int numChildren = 20;
    new File(ufsPath(baseDir)).mkdirs();
    for (int i = 0; i < numChildren; i++) {
        writeUfsFile(ufsPath(baseDir + "/child" + i), 10000);
    }
    ListStatusPOptions lsOptions = ListStatusPOptions.newBuilder().setCommonOptions(PSYNC_ALWAYS).build();
    // initial sync
    List<URIStatus> statuses = mFileSystem.listStatus(new AlluxioURI(alluxioPath(baseDir)), lsOptions);
    assertEquals(numChildren, statuses.size());
    // Delete all the children from UFS only
    for (int i = 0; i < numChildren; i++) {
        new File(ufsPath(baseDir + "/child" + i)).delete();
    }
    // this is a parallel sync, check to see if BlockDeletionContext is thread-safe.
    statuses = mFileSystem.listStatus(new AlluxioURI(alluxioPath(baseDir)), lsOptions);
    assertTrue(statuses.isEmpty());
}
Also used : URIStatus(alluxio.client.file.URIStatus) File(java.io.File) ListStatusPOptions(alluxio.grpc.ListStatusPOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 29 with ListStatusPOptions

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

the class UfsSyncIntegrationTest method mountPointConflict.

@Test
public void mountPointConflict() throws Exception {
    GetStatusPOptions gsOptions = GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_ALWAYS).build();
    URIStatus status = mFileSystem.getStatus(new AlluxioURI("/"), gsOptions);
    // add a UFS dir which conflicts with a mount point.
    String fromRootUfs = status.getUfsPath() + "/mnt";
    assertTrue(new File(fromRootUfs).mkdirs());
    ListStatusPOptions options = ListStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).setCommonOptions(PSYNC_ALWAYS).build();
    List<URIStatus> rootListing = mFileSystem.listStatus(new AlluxioURI("/"), options);
    assertEquals(1, rootListing.size());
    assertEquals("mnt", rootListing.get(0).getName());
    Assert.assertNotEquals(fromRootUfs, rootListing.get(0).getUfsPath());
}
Also used : URIStatus(alluxio.client.file.URIStatus) File(java.io.File) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) ListStatusPOptions(alluxio.grpc.ListStatusPOptions) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 30 with ListStatusPOptions

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

the class LoadMetadataCommand method loadMetadata.

private void loadMetadata(AlluxioURI path, boolean recursive, boolean force) throws IOException {
    try {
        ListStatusPOptions options;
        if (force) {
            options = ListStatusPOptions.newBuilder().setRecursive(recursive).setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setSyncIntervalMs(0).build()).build();
        } else {
            options = ListStatusPOptions.newBuilder().setRecursive(recursive).build();
        }
        mFileSystem.loadMetadata(path, options);
    } catch (AlluxioException e) {
        throw new IOException(e.getMessage());
    }
}
Also used : IOException(java.io.IOException) ListStatusPOptions(alluxio.grpc.ListStatusPOptions) AlluxioException(alluxio.exception.AlluxioException)

Aggregations

ListStatusPOptions (alluxio.grpc.ListStatusPOptions)34 Test (org.junit.Test)24 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)21 AlluxioURI (alluxio.AlluxioURI)17 URIStatus (alluxio.client.file.URIStatus)14 File (java.io.File)9 GetStatusPOptions (alluxio.grpc.GetStatusPOptions)7 HashMap (java.util.HashMap)3 FileSystem (alluxio.client.file.FileSystem)2 AlluxioException (alluxio.exception.AlluxioException)2 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)2 ListBucketResult (alluxio.proxy.s3.ListBucketResult)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 AuthenticatedUserRule (alluxio.AuthenticatedUserRule)1 Constants (alluxio.Constants)1 UnderFileSystemFactoryRegistryRule (alluxio.UnderFileSystemFactoryRegistryRule)1 FileOutStream (alluxio.client.file.FileOutStream)1 PropertyKey (alluxio.conf.PropertyKey)1