Search in sources :

Example 91 with FileDoesNotExistException

use of alluxio.exception.FileDoesNotExistException 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 92 with FileDoesNotExistException

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

the class LoadMetadataIntegrationTest method checkFunctionCall.

private Object checkFunctionCall(final String path, CheckedBiFunction<String, Message, Object> function, Message options, boolean expectExistsAlluxio, boolean expectExistsUfs, int expectedAccesses) throws Exception {
    long startMs = CommonUtils.getCurrentMs();
    Object result = null;
    try {
        result = function.apply(path, options);
        UfsAbsentPathCache cache = getUfsAbsentPathCache();
        if (!expectExistsAlluxio) {
            Assert.fail("Path is not expected to exist: " + path);
        }
    } catch (FileDoesNotExistException e) {
        if (expectExistsAlluxio) {
            throw e;
        }
    }
    long durationMs = CommonUtils.getCurrentMs() - startMs;
    assertTrue("Expected to be take between " + expectedAccesses * SLEEP_MS + " and " + (expectedAccesses + 0.5) * SLEEP_MS + ". actual duration (ms): " + durationMs, durationMs >= expectedAccesses * SLEEP_MS && durationMs < (expectedAccesses + 0.5) * SLEEP_MS);
    if (!expectExistsUfs) {
        // The metadata is loaded from Ufs, but the path does not exist, so it will be added to the
        // absent cache. Wait until the path shows up in the absent cache.
        UfsAbsentPathCache cache = getUfsAbsentPathCache();
        try {
            CommonUtils.waitFor("path (" + path + ") to be added to absent cache", () -> cache.isAbsentSince(new AlluxioURI(path), UfsAbsentPathCache.ALWAYS), WaitForOptions.defaults().setTimeoutMs(60000));
        } catch (TimeoutException e) {
            fail("Absent Path Cache addition timed out");
        }
    }
    if (expectExistsUfs) {
        // The metadata is loaded from Ufs, and the path exists, so it will be removed from the
        // absent cache. Wait until the path is removed.
        UfsAbsentPathCache cache = getUfsAbsentPathCache();
        try {
            CommonUtils.waitFor("path (" + path + ") to be removed from absent cache", () -> {
                if (cache.isAbsentSince(new AlluxioURI(path), UfsAbsentPathCache.ALWAYS)) {
                    return false;
                }
                return true;
            }, WaitForOptions.defaults().setTimeoutMs(60000));
        } catch (TimeoutException e) {
            fail("Absent Path Cache removal timed out");
        }
    }
    return result;
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) UfsAbsentPathCache(alluxio.master.file.meta.UfsAbsentPathCache) AlluxioURI(alluxio.AlluxioURI) TimeoutException(java.util.concurrent.TimeoutException)

Example 93 with FileDoesNotExistException

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

the class UfsSyncIntegrationTest method recursiveSync.

@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.USER_FILE_METADATA_LOAD_TYPE, "NEVER" })
@Test
public void recursiveSync() 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/fileA";
    String fileB = "/dir1/dir2/fileB";
    String fileC = "/dir1/dir2/fileC";
    writeUfsFile(ufsPath(fileA), 1);
    writeUfsFile(ufsPath(fileB), 1);
    // Should not exist, since no loading or syncing
    assertFalse(mFileSystem.exists(new AlluxioURI(alluxioPath(fileA)), ExistsPOptions.newBuilder().setCommonOptions(FileSystemOptions.commonDefaults(mFileSystem.getConf()).toBuilder().setSyncIntervalMs(-1).build()).build()));
    try {
        mFileSystem.setAttribute(new AlluxioURI(alluxioPath("/dir1")), SetAttributePOptions.newBuilder().setRecursive(true).setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(55555).setSyncIntervalMs(-1)).build());
    } catch (FileDoesNotExistException e) {
    // expected, continue
    }
    // Enable UFS sync, before next recursive setAttribute.
    FileSystemMasterCommonPOptions ttlOption = FileSystemMasterCommonPOptions.newBuilder().setTtl(123456789).setSyncIntervalMs(0).build();
    mFileSystem.setAttribute(new AlluxioURI(alluxioPath("/dir1")), SetAttributePOptions.newBuilder().setRecursive(true).setCommonOptions(ttlOption).build());
    // Verify recursive set TTL by getting info, without sync.
    ttlOption = ttlOption.toBuilder().setSyncIntervalMs(-1).build();
    URIStatus status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(fileA)));
    assertEquals(ttlOption.getTtl(), status.getTtl());
    // Add UFS fileC and remove existing UFS fileA.
    writeUfsFile(ufsPath(fileC), 1);
    assertTrue(new File(ufsPath(fileA)).delete());
    // Enable UFS sync, before next recursive setAttribute.
    ttlOption = FileSystemMasterCommonPOptions.newBuilder().setTtl(987654321).setSyncIntervalMs(0).build();
    mFileSystem.setAttribute(new AlluxioURI(alluxioPath("/dir1")), SetAttributePOptions.newBuilder().setRecursive(true).setCommonOptions(ttlOption).build());
    // Verify recursive set TTL by getting info, without sync.
    ttlOption = FileSystemMasterCommonPOptions.newBuilder().setSyncIntervalMs(-1).setTtl(987654321).build();
    status = mFileSystem.getStatus(new AlluxioURI(alluxioPath(fileB)));
    assertEquals(ttlOption.getTtl(), status.getTtl());
    // deleted UFS file should not exist.
    assertFalse(mFileSystem.exists(new AlluxioURI(alluxioPath(fileA))));
}
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 94 with FileDoesNotExistException

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

the class UfsSyncIntegrationTest method checkGetStatus.

private void checkGetStatus(String path, GetStatusPOptions options, boolean expectExists) throws Exception {
    try {
        URIStatus uriStatus = mFileSystem.getStatus(new AlluxioURI(alluxioPath(path)), options);
        if (!expectExists) {
            Assert.fail("Path is not expected to exist: " + alluxioPath(path));
        }
        checkUriStatus(uriStatus);
    } catch (FileDoesNotExistException e) {
        if (expectExists) {
            throw e;
        }
    }
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI)

Example 95 with FileDoesNotExistException

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

the class UfsSyncIntegrationTest method checkListStatus.

private void checkListStatus(String path, ListStatusPOptions options, boolean expectExists) throws Exception {
    try {
        List<URIStatus> statusList = mFileSystem.listStatus(new AlluxioURI(alluxioPath(path)), options);
        if (!expectExists) {
            Assert.fail("Path is not expected to exist: " + alluxioPath(path));
        }
        Assert.assertNotNull(statusList);
        for (URIStatus uriStatus : statusList) {
            checkUriStatus(uriStatus);
        }
        checkUfsListing(ufsPath(path), statusList);
    } catch (FileDoesNotExistException e) {
        if (expectExists) {
            throw e;
        }
    }
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI)

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