Search in sources :

Example 11 with DeletePOptions

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());
}
Also used : DeletePOptions(alluxio.grpc.DeletePOptions) URIStatus(alluxio.client.file.URIStatus) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test)

Example 12 with DeletePOptions

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());
}
Also used : DeletePOptions(alluxio.grpc.DeletePOptions) Test(org.junit.Test)

Example 13 with DeletePOptions

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;
    });
}
Also used : DeletePOptions(alluxio.grpc.DeletePOptions) FileSystem(alluxio.client.file.FileSystem) AlluxioException(alluxio.exception.AlluxioException) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) DirectoryNotEmptyException(alluxio.exception.DirectoryNotEmptyException) FileAlreadyExistsException(alluxio.exception.FileAlreadyExistsException) IOException(java.io.IOException) AlluxioURI(alluxio.AlluxioURI) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 14 with DeletePOptions

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
    }
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) DeletePOptions(alluxio.grpc.DeletePOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 15 with DeletePOptions

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();
}
Also used : DeletePOptions(alluxio.grpc.DeletePOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

DeletePOptions (alluxio.grpc.DeletePOptions)19 AlluxioURI (alluxio.AlluxioURI)15 Test (org.junit.Test)10 URIStatus (alluxio.client.file.URIStatus)6 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)6 IOException (java.io.IOException)6 AlluxioException (alluxio.exception.AlluxioException)5 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)4 GetStatusPOptions (alluxio.grpc.GetStatusPOptions)4 DirectoryNotEmptyException (alluxio.exception.DirectoryNotEmptyException)3 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)3 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)3 FileSystem (alluxio.client.file.FileSystem)2 CreateDirectoryPOptions (alluxio.grpc.CreateDirectoryPOptions)2 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Constants (alluxio.Constants)1 FileInStream (alluxio.client.file.FileInStream)1 FileOutStream (alluxio.client.file.FileOutStream)1 ConcurrentHashSet (alluxio.collections.ConcurrentHashSet)1