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