use of alluxio.master.file.meta.FileSystemMasterView in project alluxio by Alluxio.
the class DefaultAsyncPersistHandlerTest method scheduleAsyncPersist.
@Test
public void scheduleAsyncPersist() throws Exception {
DefaultAsyncPersistHandler handler = new DefaultAsyncPersistHandler(new FileSystemMasterView(mFileSystemMaster));
AlluxioURI path = new AlluxioURI("/test");
long blockId = 0;
long workerId = 1;
long fileId = 2;
List<FileBlockInfo> blockInfoList = new ArrayList<>();
BlockLocation location = new BlockLocation().setWorkerId(workerId);
blockInfoList.add(new FileBlockInfo().setBlockInfo(new BlockInfo().setBlockId(blockId).setLocations(Lists.newArrayList(location))));
when(mFileSystemMaster.getFileBlockInfoList(path)).thenReturn(blockInfoList);
when(mFileSystemMaster.getFileId(path)).thenReturn(fileId);
when(mFileSystemMaster.getPath(fileId)).thenReturn(path);
when(mFileSystemMaster.getFileInfo(fileId)).thenReturn(new FileInfo().setLength(1).setCompleted(true));
handler.scheduleAsyncPersistence(path);
List<PersistFile> persistFiles = handler.pollFilesToPersist(workerId);
assertEquals(1, persistFiles.size());
assertEquals(Lists.newArrayList(blockId), persistFiles.get(0).getBlockIds());
}
use of alluxio.master.file.meta.FileSystemMasterView in project alluxio by Alluxio.
the class DefaultAsyncPersistHandlerTest method persistenceFileAfterDeletion.
/**
* Tests persistence after deletion of files.
*/
@Test
public void persistenceFileAfterDeletion() throws Exception {
DefaultAsyncPersistHandler handler = new DefaultAsyncPersistHandler(new FileSystemMasterView(mFileSystemMaster));
AlluxioURI path = new AlluxioURI("/test");
long blockId = 0;
long workerId = 1;
long fileId = 2;
List<FileBlockInfo> blockInfoList = new ArrayList<>();
BlockLocation location = new BlockLocation().setWorkerId(workerId);
blockInfoList.add(new FileBlockInfo().setBlockInfo(new BlockInfo().setBlockId(blockId).setLocations(Lists.newArrayList(location))));
when(mFileSystemMaster.getFileBlockInfoList(path)).thenReturn(blockInfoList);
when(mFileSystemMaster.getFileId(path)).thenReturn(fileId);
when(mFileSystemMaster.getPath(fileId)).thenReturn(path);
when(mFileSystemMaster.getFileInfo(fileId)).thenReturn(new FileInfo().setLength(1).setCompleted(true));
handler.scheduleAsyncPersistence(path);
when(mFileSystemMaster.getFileInfo(fileId)).thenThrow(new FileDoesNotExistException("no file"));
List<PersistFile> persistFiles = handler.pollFilesToPersist(workerId);
assertEquals(0, persistFiles.size());
}
Aggregations