use of alluxio.grpc.DeletePOptions 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());
}
use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class FileSystemOptionsTest method deleteOptionsDefaults.
@Test
public void deleteOptionsDefaults() {
DeletePOptions options = FileSystemOptions.deleteDefaults(mConf);
assertNotNull(options);
assertFalse(options.getRecursive());
assertFalse(options.getAlluxioOnly());
assertFalse(options.getUnchecked());
}
use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class S3RestServiceHandler method deleteBucket.
/**
* @summary deletes a bucket
* @param authorization header parameter authorization
* @param bucket the bucket name
* @return the response object
*/
@DELETE
@Path(BUCKET_PARAM)
public Response deleteBucket(@HeaderParam("Authorization") String authorization, @PathParam("bucket") final String bucket) {
return S3RestUtils.call(bucket, () -> {
Preconditions.checkNotNull(bucket, "required 'bucket' parameter is missing");
String bucketPath = S3RestUtils.parsePath(AlluxioURI.SEPARATOR + bucket);
final FileSystem fs = getFileSystem(authorization);
S3RestUtils.checkPathIsAlluxioDirectory(fs, bucketPath);
// Delete the bucket.
DeletePOptions options = DeletePOptions.newBuilder().setAlluxioOnly(ServerConfiguration.get(PropertyKey.PROXY_S3_DELETE_TYPE).equals(Constants.S3_DELETE_IN_ALLUXIO_ONLY)).build();
try {
fs.delete(new AlluxioURI(bucketPath), options);
} catch (Exception e) {
throw S3RestUtils.toBucketS3Exception(e, bucketPath);
}
return Response.Status.NO_CONTENT;
});
}
use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class UfsSyncIntegrationTest method deleteFileNoSync.
@Test
public void deleteFileNoSync() throws Exception {
DeletePOptions options = DeletePOptions.newBuilder().setCommonOptions(PSYNC_NEVER).build();
try {
mFileSystem.delete(new AlluxioURI(alluxioPath(EXISTING_FILE)), options);
Assert.fail("Delete expected to fail: " + alluxioPath(EXISTING_FILE));
} catch (FileDoesNotExistException e) {
// expected
}
}
use of alluxio.grpc.DeletePOptions in project alluxio by Alluxio.
the class BaseFileSystemTest method delete.
/**
* Tests for the {@link BaseFileSystem#delete(AlluxioURI, DeletePOptions)} method.
*/
@Test
public void delete() throws Exception {
AlluxioURI file = new AlluxioURI("/file");
DeletePOptions deleteOptions = DeletePOptions.newBuilder().setRecursive(true).build();
mFileSystem.delete(file, deleteOptions);
verify(mFileSystemMasterClient).delete(file, FileSystemOptions.deleteDefaults(mConf).toBuilder().mergeFrom(deleteOptions).build());
verifyFilesystemContextAcquiredAndReleased();
}
Aggregations