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);
}
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()));
}
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());
}
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());
}
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());
}
}
Aggregations