use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class StressJobServiceBench method deletePath.
private void deletePath(FileSystem fs, String dirPath) throws IOException, AlluxioException {
AlluxioURI path = new AlluxioURI(dirPath);
if (fs.exists(path)) {
DeletePOptions options = DeletePOptions.newBuilder().setRecursive(true).build();
fs.delete(path, options);
}
}
use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class UfsSyncIntegrationTest method deleteFileSync.
@Test
public void deleteFileSync() throws Exception {
DeletePOptions options = DeletePOptions.newBuilder().setCommonOptions(PSYNC_ALWAYS).build();
mFileSystem.delete(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
}
use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class UfsJournalIntegrationTest method delete.
/**
* Tests file and directory creation and deletion.
*/
@Test
public void delete() throws Exception {
CreateDirectoryPOptions recMkdir = CreateDirectoryPOptions.newBuilder().setRecursive(true).build();
DeletePOptions recDelete = DeletePOptions.newBuilder().setRecursive(true).build();
for (int i = 0; i < 10; i++) {
String dirPath = "/i" + i;
mFileSystem.createDirectory(new AlluxioURI(dirPath), recMkdir);
for (int j = 0; j < 10; j++) {
CreateFilePOptions option = CreateFilePOptions.newBuilder().setBlockSizeBytes((i + j + 1) * 64).build();
String filePath = dirPath + "/j" + j;
mFileSystem.createFile(new AlluxioURI(filePath), option).close();
if (j >= 5) {
mFileSystem.delete(new AlluxioURI(filePath), recDelete);
}
}
if (i >= 5) {
mFileSystem.delete(new AlluxioURI(dirPath), recDelete);
}
}
mLocalAlluxioCluster.stopFS();
deleteTestUtil();
deleteFsMasterJournalLogs();
deleteTestUtil();
}
use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class CheckConsistencyCommand method runConsistencyCheck.
/**
* Checks the inconsistent files and directories which exist in Alluxio but don't exist in the
* under storage, repairs the inconsistent paths by deleting them if repairConsistency is true.
*
* @param path the specified path to be checked
* @param repairConsistency whether to repair the consistency or not
* @throws AlluxioException
* @throws IOException
*/
private void runConsistencyCheck(AlluxioURI path, boolean repairConsistency, int repairThreads) throws AlluxioException, IOException {
List<AlluxioURI> inconsistentUris = checkConsistency(path, FileSystemOptions.checkConsistencyDefaults(mFsContext.getPathConf(path)));
if (inconsistentUris.isEmpty()) {
System.out.println(path + " is consistent with the under storage system.");
return;
}
if (!repairConsistency) {
Collections.sort(inconsistentUris);
System.out.println("The following files are inconsistent:");
for (AlluxioURI uri : inconsistentUris) {
System.out.println(uri);
}
} else {
Collections.sort(inconsistentUris);
System.out.println(String.format("%s has: %d inconsistent files. Repairing with %d threads.", path, inconsistentUris.size(), repairThreads));
ConcurrentHashSet<AlluxioURI> inconsistentDirs = new ConcurrentHashSet<>();
ExecutorService svc = Executors.newFixedThreadPool(repairThreads);
CompletionService<Boolean> completionService = new ExecutorCompletionService<>(svc);
ConcurrentHashSet<Exception> exceptions = new ConcurrentHashSet<>();
int totalUris = inconsistentUris.size();
for (AlluxioURI inconsistentUri : inconsistentUris) {
completionService.submit(() -> {
try {
URIStatus status = mFileSystem.getStatus(inconsistentUri);
if (status.isFolder()) {
inconsistentDirs.add(inconsistentUri);
return;
}
System.out.println("repairing path: " + inconsistentUri);
DeletePOptions deleteOptions = DeletePOptions.newBuilder().setAlluxioOnly(true).build();
mFileSystem.delete(inconsistentUri, deleteOptions);
mFileSystem.exists(inconsistentUri);
System.out.println(inconsistentUri + " repaired");
System.out.println();
} catch (AlluxioException | IOException e) {
exceptions.add(e);
}
}, true);
}
waitForTasks(completionService, totalUris, exceptions);
int totalDirs = inconsistentDirs.size();
for (AlluxioURI uri : inconsistentDirs) {
completionService.submit(() -> {
try {
DeletePOptions deleteOptions = DeletePOptions.newBuilder().setAlluxioOnly(true).setRecursive(true).build();
System.out.println("repairing path: " + uri);
mFileSystem.delete(uri, deleteOptions);
mFileSystem.exists(uri);
System.out.println(uri + "repaired");
System.out.println();
} catch (AlluxioException | IOException e) {
exceptions.add(e);
}
}, true);
}
waitForTasks(completionService, totalDirs, exceptions);
svc.shutdown();
}
}
use of alluxio.grpc.DeletePOptions 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());
}
Aggregations