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
}
}
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;
}
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))));
}
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;
}
}
}
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;
}
}
}
Aggregations