Search in sources :

Example 16 with DeletePOptions

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

Example 17 with DeletePOptions

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());
}
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 18 with DeletePOptions

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());
}
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 19 with DeletePOptions

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

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