use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class InodeDirectoryTest method generateClientFileInfo.
/**
* Tests the {@link InodeDirectory#generateClientFileInfo(String)} method.
*/
@Test
public void generateClientFileInfo() {
InodeDirectory inodeDirectory = createInodeDirectory();
String path = "/test/path";
FileInfo info = inodeDirectory.generateClientFileInfo(path);
Assert.assertEquals(inodeDirectory.getId(), info.getFileId());
Assert.assertEquals(inodeDirectory.getName(), info.getName());
Assert.assertEquals(path, info.getPath());
Assert.assertEquals("", info.getUfsPath());
Assert.assertEquals(0, info.getLength());
Assert.assertEquals(0, info.getBlockSizeBytes());
Assert.assertEquals(inodeDirectory.getCreationTimeMs(), info.getCreationTimeMs());
Assert.assertTrue(info.isCompleted());
Assert.assertTrue(info.isFolder());
Assert.assertEquals(inodeDirectory.isPinned(), info.isPinned());
Assert.assertFalse(info.isCacheable());
Assert.assertNotNull(info.getBlockIds());
Assert.assertEquals(inodeDirectory.getLastModificationTimeMs(), info.getLastModificationTimeMs());
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class FileSystemMasterTest method listStatusWithLoadMetadataOnce.
@Test
public void listStatusWithLoadMetadataOnce() throws Exception {
AlluxioURI ufsMount = new AlluxioURI(mTestFolder.newFolder().getAbsolutePath());
mFileSystemMaster.createDirectory(new AlluxioURI("/mnt/"), CreateDirectoryOptions.defaults());
// Create ufs file
Files.createDirectory(Paths.get(ufsMount.join("dir1").getPath()));
Files.createFile(Paths.get(ufsMount.join("dir1").join("file1").getPath()));
Files.createFile(Paths.get(ufsMount.join("dir1").join("file2").getPath()));
mFileSystemMaster.mount(new AlluxioURI("/mnt/local"), ufsMount, MountOptions.defaults());
// 3 directories exist.
Assert.assertEquals(3, mFileSystemMaster.getNumberOfPaths());
// getFileId should load metadata automatically.
AlluxioURI uri = new AlluxioURI("/mnt/local/dir1");
List<FileInfo> fileInfoList = mFileSystemMaster.listStatus(uri, ListStatusOptions.defaults());
Set<String> paths = new HashSet<>();
for (FileInfo fileInfo : fileInfoList) {
paths.add(fileInfo.getPath());
}
Assert.assertEquals(2, paths.size());
Assert.assertTrue(paths.contains("/mnt/local/dir1/file1"));
Assert.assertTrue(paths.contains("/mnt/local/dir1/file2"));
// listStatus should have loaded another 3 files (dir1, dir1/file1, dir1/file2), so now 6
// paths exist.
Assert.assertEquals(6, mFileSystemMaster.getNumberOfPaths());
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class FileSystemMasterTest method listStatusWithLoadMetadataAlways.
@Test
public void listStatusWithLoadMetadataAlways() throws Exception {
AlluxioURI ufsMount = new AlluxioURI(mTestFolder.newFolder().getAbsolutePath());
mFileSystemMaster.createDirectory(new AlluxioURI("/mnt/"), CreateDirectoryOptions.defaults());
// Create ufs file
Files.createDirectory(Paths.get(ufsMount.join("dir1").getPath()));
mFileSystemMaster.mount(new AlluxioURI("/mnt/local"), ufsMount, MountOptions.defaults());
// 3 directories exist.
Assert.assertEquals(3, mFileSystemMaster.getNumberOfPaths());
// getFileId should load metadata automatically.
AlluxioURI uri = new AlluxioURI("/mnt/local/dir1");
List<FileInfo> fileInfoList = mFileSystemMaster.listStatus(uri, ListStatusOptions.defaults());
Assert.assertEquals(0, fileInfoList.size());
// listStatus should have loaded another files (dir1), so now 4 paths exist.
Assert.assertEquals(4, mFileSystemMaster.getNumberOfPaths());
// Add two files.
Files.createFile(Paths.get(ufsMount.join("dir1").join("file1").getPath()));
Files.createFile(Paths.get(ufsMount.join("dir1").join("file2").getPath()));
fileInfoList = mFileSystemMaster.listStatus(uri, ListStatusOptions.defaults());
Assert.assertEquals(0, fileInfoList.size());
// No file is loaded since dir1 has been loaded once.
Assert.assertEquals(4, mFileSystemMaster.getNumberOfPaths());
fileInfoList = mFileSystemMaster.listStatus(uri, ListStatusOptions.defaults().setLoadMetadataType(LoadMetadataType.Always));
Set<String> paths = new HashSet<>();
for (FileInfo fileInfo : fileInfoList) {
paths.add(fileInfo.getPath());
}
Assert.assertEquals(2, paths.size());
Assert.assertTrue(paths.contains("/mnt/local/dir1/file1"));
Assert.assertTrue(paths.contains("/mnt/local/dir1/file2"));
// listStatus should have loaded another 2 files (dir1/file1, dir1/file2), so now 6
// paths exist.
Assert.assertEquals(6, mFileSystemMaster.getNumberOfPaths());
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class FileSystemMasterTest method ttlDirectoryDelete.
/**
* Tests that an exception is in the
* {@link FileSystemMaster#createDirectory(AlluxioURI, CreateDirectoryOptions)} with a TTL
* set in the {@link CreateDirectoryOptions} after the TTL check was done once.
*/
@Test
public void ttlDirectoryDelete() throws Exception {
CreateDirectoryOptions directoryOptions = CreateDirectoryOptions.defaults().setRecursive(true).setTtl(0);
long dirId = mFileSystemMaster.createDirectory(NESTED_DIR_URI, directoryOptions);
FileInfo fileInfo = mFileSystemMaster.getFileInfo(dirId);
Assert.assertEquals(fileInfo.getFileId(), dirId);
HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK);
mThrown.expect(FileDoesNotExistException.class);
mFileSystemMaster.getFileInfo(dirId);
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class FileSystemMasterTest method lostFilesDetection.
/**
* Tests that lost files can successfully be detected.
*/
@Test
public void lostFilesDetection() throws Exception {
createFileWithSingleBlock(NESTED_FILE_URI);
long fileId = mFileSystemMaster.getFileId(NESTED_FILE_URI);
mFileSystemMaster.reportLostFile(fileId);
FileInfo fileInfo = mFileSystemMaster.getFileInfo(fileId);
Assert.assertEquals(PersistenceState.NOT_PERSISTED.name(), fileInfo.getPersistenceState());
// Check with getPersistenceState
Assert.assertEquals(PersistenceState.NOT_PERSISTED, mFileSystemMaster.getPersistenceState(fileId));
// run the detector
HeartbeatScheduler.execute(HeartbeatContext.MASTER_LOST_FILES_DETECTION);
fileInfo = mFileSystemMaster.getFileInfo(fileId);
Assert.assertEquals(PersistenceState.LOST.name(), fileInfo.getPersistenceState());
// Check with getPersistenceState
Assert.assertEquals(PersistenceState.LOST, mFileSystemMaster.getPersistenceState(fileId));
}
Aggregations