Search in sources :

Example 56 with FileDoesNotExistException

use of alluxio.exception.FileDoesNotExistException in project alluxio by Alluxio.

the class ReadOnlyMountIntegrationTest method loadMetadata.

@Test
public void loadMetadata() throws IOException, AlluxioException {
    AlluxioURI fileUri = new AlluxioURI(FILE_PATH);
    try {
        mFileSystem.getStatus(fileUri, GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).build());
        Assert.fail("File should not exist before loading metadata.");
    } catch (FileDoesNotExistException e) {
        Assert.assertEquals(e.getMessage(), ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage(FILE_PATH));
    }
    Assert.assertNotNull(mFileSystem.getStatus(fileUri));
    fileUri = new AlluxioURI(SUB_FILE_PATH);
    try {
        mFileSystem.getStatus(fileUri, GetStatusPOptions.newBuilder().setLoadMetadataType(LoadMetadataPType.NEVER).build());
        Assert.fail("File should not exist before loading metadata.");
    } catch (FileDoesNotExistException e) {
        Assert.assertEquals(e.getMessage(), ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage(SUB_FILE_PATH));
    }
    Assert.assertNotNull(mFileSystem.getStatus(fileUri));
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 57 with FileDoesNotExistException

use of alluxio.exception.FileDoesNotExistException in project alluxio by Alluxio.

the class UfsSyncIntegrationTest method recursiveSyncCacheDescendants.

@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.USER_FILE_METADATA_LOAD_TYPE, "NEVER" })
@Test
public void recursiveSyncCacheDescendants() throws Exception {
    // make nested directories/files in UFS
    new File(ufsPath("/dir1")).mkdirs();
    new File(ufsPath("/dir1/dir2")).mkdirs();
    new File(ufsPath("/dir1/dir2/dir3")).mkdirs();
    String fileA = "/dir1/dir2/dir3/fileA";
    String fileB = "/dir1/dir2/dir3/fileB";
    String fileNew = "/dir1/dir2/dir3/fileNew";
    writeUfsFile(ufsPath(fileA), 1);
    writeUfsFile(ufsPath(fileB), 1);
    FileSystemMasterCommonPOptions longinterval = FileSystemMasterCommonPOptions.newBuilder().setSyncIntervalMs(Constants.HOUR_MS).build();
    // Should not exist, since no loading or syncing
    assertFalse(mFileSystem.exists(new AlluxioURI(alluxioPath(fileA)), ExistsPOptions.newBuilder().setCommonOptions(PSYNC_NEVER).build()));
    try {
        mFileSystem.listStatus(new AlluxioURI(alluxioPath("/dir1")), ListStatusPOptions.newBuilder().setCommonOptions(PSYNC_NEVER).build());
        Assert.fail("paths are not expected to exist without sync");
    } catch (FileDoesNotExistException e) {
    // expected, continue
    }
    // recursively sync the top dir
    List<URIStatus> paths = mFileSystem.listStatus(new AlluxioURI(alluxioPath("/dir1")), ListStatusPOptions.newBuilder().setCommonOptions(PSYNC_ALWAYS).setRecursive(true).build());
    assertEquals(4, paths.size());
    // write a new UFS file
    writeUfsFile(ufsPath(fileNew), 1);
    // the new UFS file should not exist, since the sync interval is 1 hour, and an ancestor
    // already synced recently.
    assertFalse(mFileSystem.exists(new AlluxioURI(alluxioPath(fileNew)), ExistsPOptions.newBuilder().setCommonOptions(longinterval).build()));
    // newly created file should not exist
    paths = mFileSystem.listStatus(new AlluxioURI(alluxioPath("/dir1/dir2/dir3")), ListStatusPOptions.newBuilder().setCommonOptions(longinterval).build());
    assertEquals(2, paths.size());
    // create a new UFS dir
    new File(ufsPath("/dir1/dir2/dirNew")).mkdirs();
    // newly created dir should not exist, since sync interval is long, and an ancestor is
    // already synced
    assertFalse(mFileSystem.exists(new AlluxioURI(alluxioPath("/dir1/dir2/dirNew")), ExistsPOptions.newBuilder().setCommonOptions(longinterval).build()));
    // newly created dir should not exist
    paths = mFileSystem.listStatus(new AlluxioURI(alluxioPath("/dir1/dir2")), ListStatusPOptions.newBuilder().setCommonOptions(longinterval).build());
    assertEquals(1, paths.size());
    // check the original path, and verify no new files/dirs are picked up from UFS
    paths = mFileSystem.listStatus(new AlluxioURI(alluxioPath("/dir1")), ListStatusPOptions.newBuilder().setCommonOptions(longinterval).setRecursive(true).build());
    assertEquals(4, paths.size());
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) FileSystemMasterCommonPOptions(alluxio.grpc.FileSystemMasterCommonPOptions) URIStatus(alluxio.client.file.URIStatus) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 58 with FileDoesNotExistException

use of alluxio.exception.FileDoesNotExistException in project alluxio by Alluxio.

the class UfsSyncIntegrationTest method deleteUfsFileGetStatus.

@Test
public void deleteUfsFileGetStatus() throws Exception {
    new File(ufsPath("/delete")).mkdirs();
    writeUfsFile(ufsPath("/delete/file"), 10);
    List<URIStatus> paths = mFileSystem.listStatus(new AlluxioURI(alluxioPath("/delete")), ListStatusPOptions.newBuilder().setRecursive(false).setCommonOptions(PSYNC_ALWAYS).build());
    assertEquals(1, paths.size());
    assertEquals("file", paths.get(0).getName());
    // delete the file and wait a bit
    new File(ufsPath("/delete/file")).delete();
    CommonUtils.sleepMs(2000);
    // getStatus (not listStatus) on the root, with a shorter interval than the sleep.
    // This will sync that directory. The sync interval has to be long enough for the internal
    // syncing process to finish within that time.
    mFileSystem.getStatus(new AlluxioURI(alluxioPath("/delete")), GetStatusPOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setSyncIntervalMs(1000).build()).build());
    // verify that the file is deleted, without syncing
    try {
        mFileSystem.getStatus(new AlluxioURI(alluxioPath("/delete/file")), GetStatusPOptions.newBuilder().setCommonOptions(PSYNC_NEVER).build());
        Assert.fail("the ufs deleted file is not expected to exist after sync via getStatus");
    } catch (FileDoesNotExistException e) {
    // expected
    }
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) URIStatus(alluxio.client.file.URIStatus) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 59 with FileDoesNotExistException

use of alluxio.exception.FileDoesNotExistException in project alluxio by Alluxio.

the class UfsSyncIntegrationTest method renameFileNoSync.

@Test
public void renameFileNoSync() throws Exception {
    RenamePOptions options = RenamePOptions.newBuilder().setCommonOptions(PSYNC_NEVER).build();
    try {
        mFileSystem.rename(new AlluxioURI(alluxioPath(EXISTING_FILE)), new AlluxioURI(alluxioPath(NEW_FILE)), options);
        Assert.fail("Rename expected to fail.");
    } catch (FileDoesNotExistException e) {
    // expected
    }
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) RenamePOptions(alluxio.grpc.RenamePOptions) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 60 with FileDoesNotExistException

use of alluxio.exception.FileDoesNotExistException in project alluxio by Alluxio.

the class FileSystemMasterFaultToleranceIntegrationTest method partitionTolerantDeleteFile.

@Test
public void partitionTolerantDeleteFile() throws Exception {
    // Create paths for the test.
    AlluxioURI testPath1 = new AlluxioURI("/testPath1");
    // Create context1 with unique operation id.
    DeleteContext context = DeleteContext.mergeFrom(DeletePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto())));
    // Create context2 with unique operation id.
    DeleteContext context2 = DeleteContext.mergeFrom(DeletePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto())));
    {
        // Acquire file-system-master of leading master.
        FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class);
        // Create the path to delete.
        leadingFsMaster.createFile(testPath1, CreateFileContext.defaults());
        leadingFsMaster.completeFile(testPath1, CompleteFileContext.defaults());
        // Delete the path the first time.
        leadingFsMaster.delete(testPath1, context);
        // Delete the path the second time with the same context.
        // It should just return successfully.
        leadingFsMaster.delete(testPath1, context);
        // Delete the path again with a different context.
        // It should fail with `FileDoesNotExistException`.
        assertThrows(FileDoesNotExistException.class, () -> leadingFsMaster.delete(testPath1, context2));
    }
    // Promote standby to be a leader and reset test state.
    mMultiMasterLocalAlluxioCluster.stopLeader();
    mMultiMasterLocalAlluxioCluster.waitForNewMaster(CLUSTER_WAIT_TIMEOUT_MS);
    mAuthenticatedUser.resetUser();
    // Run partition tolerance test on the *new* leading master.
    {
        // Acquire file-system-master of leading master.
        FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class);
        // Deleting the file on the new leader with the original operation-id should succeed.
        leadingFsMaster.delete(testPath1, context);
        // Deleting on the new leader with a different operation-id.
        // It should fail with `FileDoesNotExistException`.
        assertThrows(FileDoesNotExistException.class, () -> leadingFsMaster.delete(testPath1, context2));
    }
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) DeleteContext(alluxio.master.file.contexts.DeleteContext) OperationId(alluxio.wire.OperationId) FileSystemMaster(alluxio.master.file.FileSystemMaster) AlluxioURI(alluxio.AlluxioURI) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Aggregations

FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)126 AlluxioURI (alluxio.AlluxioURI)90 InvalidPathException (alluxio.exception.InvalidPathException)42 IOException (java.io.IOException)39 URIStatus (alluxio.client.file.URIStatus)34 Test (org.junit.Test)31 AlluxioException (alluxio.exception.AlluxioException)26 ArrayList (java.util.ArrayList)26 LockedInodePath (alluxio.master.file.meta.LockedInodePath)22 AccessControlException (alluxio.exception.AccessControlException)19 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)14 Inode (alluxio.master.file.meta.Inode)14 FileInfo (alluxio.wire.FileInfo)14 BlockInfoException (alluxio.exception.BlockInfoException)13 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)10 UnavailableException (alluxio.exception.status.UnavailableException)9 BlockInfo (alluxio.wire.BlockInfo)9 FileBlockInfo (alluxio.wire.FileBlockInfo)9 DirectoryNotEmptyException (alluxio.exception.DirectoryNotEmptyException)8 InodeFile (alluxio.master.file.meta.InodeFile)7