use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class BaseFileSystemTest method deleteException.
/**
* Ensures that an exception is propagated correctly when deleting a file.
*/
@Test
public void deleteException() throws Exception {
AlluxioURI file = new AlluxioURI("/file");
DeletePOptions deleteOptions = DeletePOptions.newBuilder().setRecursive(true).build();
doThrow(EXCEPTION).when(mFileSystemMasterClient).delete(file, FileSystemOptions.deleteDefaults(mConf).toBuilder().mergeFrom(deleteOptions).build());
try {
mFileSystem.delete(file, deleteOptions);
fail(SHOULD_HAVE_PROPAGATED_MESSAGE);
} catch (Exception e) {
assertSame(EXCEPTION, e);
}
verifyFilesystemContextAcquiredAndReleased();
}
use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class LoadMetadataCommandIntegrationTest method loadMetadataFile.
@Test
public void loadMetadataFile() 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);
sFsShell.run("loadMetadata", filePath);
// 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());
}
use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class LoadMetadataCommandIntegrationTest method loadMetadataDir.
@Test
public void loadMetadataDir() 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.CACHE_THROUGH, 30);
AlluxioURI uriDir = new AlluxioURI(dirPath);
AlluxioURI uriA = new AlluxioURI(filePathA);
AlluxioURI uriB = new AlluxioURI(filePathB);
URIStatus statusBeforeA = sFileSystem.getStatus(uriA);
URIStatus statusBeforeB = sFileSystem.getStatus(uriB);
// Delete layer3 directory metadata recursively.
DeletePOptions deletePOptions = DeletePOptions.newBuilder().setAlluxioOnly(true).setRecursive(true).build();
sFileSystem.delete(uriDir, deletePOptions);
// Load metadata from ufs.
sFsShell.run("loadMetadata", dirPath);
// 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());
}
use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class BaseFileSystem method delete.
@Override
public void delete(AlluxioURI path, DeletePOptions options) throws DirectoryNotEmptyException, FileDoesNotExistException, IOException, AlluxioException {
checkUri(path);
rpc(client -> {
DeletePOptions mergedOptions = FileSystemOptions.deleteDefaults(mFsContext.getPathConf(path)).toBuilder().mergeFrom(options).build();
client.delete(path, mergedOptions);
LOG.debug("Deleted {}, options: {}", path.getPath(), mergedOptions);
return null;
});
}
Aggregations