Search in sources :

Example 6 with FileSystemMasterView

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());
}
Also used : PersistFile(alluxio.wire.PersistFile) FileSystemMasterView(alluxio.master.file.meta.FileSystemMasterView) FileInfo(alluxio.wire.FileInfo) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) ArrayList(java.util.ArrayList) FileBlockInfo(alluxio.wire.FileBlockInfo) BlockLocation(alluxio.wire.BlockLocation) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 7 with FileSystemMasterView

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());
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) FileSystemMasterView(alluxio.master.file.meta.FileSystemMasterView) ArrayList(java.util.ArrayList) FileBlockInfo(alluxio.wire.FileBlockInfo) BlockLocation(alluxio.wire.BlockLocation) PersistFile(alluxio.wire.PersistFile) FileInfo(alluxio.wire.FileInfo) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

FileSystemMasterView (alluxio.master.file.meta.FileSystemMasterView)7 Test (org.junit.Test)5 FileInfo (alluxio.wire.FileInfo)4 AlluxioURI (alluxio.AlluxioURI)3 FileSystemMaster (alluxio.master.file.FileSystemMaster)3 BlockInfo (alluxio.wire.BlockInfo)3 BlockLocation (alluxio.wire.BlockLocation)3 FileBlockInfo (alluxio.wire.FileBlockInfo)3 ArrayList (java.util.ArrayList)3 CommandLineJob (alluxio.job.CommandLineJob)2 JobConf (alluxio.job.JobConf)2 LineageIdGenerator (alluxio.master.lineage.meta.LineageIdGenerator)2 LineageStore (alluxio.master.lineage.meta.LineageStore)2 LineageStoreView (alluxio.master.lineage.meta.LineageStoreView)2 PersistFile (alluxio.wire.PersistFile)2 Before (org.junit.Before)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)1 Job (alluxio.job.Job)1 Lineage (alluxio.master.lineage.meta.Lineage)1