Search in sources :

Example 1 with FileSystemMasterView

use of alluxio.master.file.meta.FileSystemMasterView in project alluxio by Alluxio.

the class CheckpointLatestPlannerTest method before.

/**
   * Sets up all dependencies before a test runs.
   */
@Before
public void before() {
    mLineageStore = new LineageStore(new LineageIdGenerator());
    mJob = new CommandLineJob("test", new JobConf("output"));
    mFileSystemMaster = Mockito.mock(FileSystemMaster.class);
    mPlanner = new CheckpointLatestPlanner(new LineageStoreView(mLineageStore), new FileSystemMasterView(mFileSystemMaster));
}
Also used : FileSystemMasterView(alluxio.master.file.meta.FileSystemMasterView) LineageStore(alluxio.master.lineage.meta.LineageStore) FileSystemMaster(alluxio.master.file.FileSystemMaster) LineageIdGenerator(alluxio.master.lineage.meta.LineageIdGenerator) CommandLineJob(alluxio.job.CommandLineJob) JobConf(alluxio.job.JobConf) LineageStoreView(alluxio.master.lineage.meta.LineageStoreView) Before(org.junit.Before)

Example 2 with FileSystemMasterView

use of alluxio.master.file.meta.FileSystemMasterView in project alluxio by Alluxio.

the class RecomputePlannerTest method before.

/**
   * Sets up the dependencies before a test runs.
   */
@Before
public void before() {
    mLineageStore = new LineageStore(new LineageIdGenerator());
    mJob = new CommandLineJob("test", new JobConf("output"));
    mFileSystemMaster = Mockito.mock(FileSystemMaster.class);
    Mockito.when(mFileSystemMaster.getFileSystemMasterView()).thenReturn(new FileSystemMasterView(mFileSystemMaster));
    mPlanner = new RecomputePlanner(mLineageStore, mFileSystemMaster);
}
Also used : FileSystemMasterView(alluxio.master.file.meta.FileSystemMasterView) LineageStore(alluxio.master.lineage.meta.LineageStore) FileSystemMaster(alluxio.master.file.FileSystemMaster) LineageIdGenerator(alluxio.master.lineage.meta.LineageIdGenerator) CommandLineJob(alluxio.job.CommandLineJob) JobConf(alluxio.job.JobConf) Before(org.junit.Before)

Example 3 with FileSystemMasterView

use of alluxio.master.file.meta.FileSystemMasterView in project alluxio by Alluxio.

the class TestRecomputeExecutor method recomputeLauncher.

/**
   * Tests recompute executor creates a recompute plan and launches the recompute job at heartbeat.
   *
   * @throws Exception if anything wrong happens
   */
@Test
public void recomputeLauncher() throws Exception {
    long fileId = 5L;
    // mock planner
    RecomputePlanner planner = Mockito.mock(RecomputePlanner.class);
    Job job = Mockito.mock(Job.class);
    Lineage lineage = new Lineage(1, new ArrayList<Long>(), Lists.newArrayList(fileId), job);
    Mockito.when(planner.plan()).thenReturn(new RecomputePlan(Lists.newArrayList(lineage)));
    // mock file system master
    FileSystemMaster fileSystemMaster = Mockito.mock(FileSystemMaster.class);
    Mockito.when(fileSystemMaster.getFileSystemMasterView()).thenReturn(new FileSystemMasterView(fileSystemMaster));
    Mockito.when(fileSystemMaster.getLostFiles()).thenReturn(Lists.newArrayList(fileId));
    RecomputeExecutor executor = new RecomputeExecutor(planner, fileSystemMaster);
    // wait for the executor to finish running
    executor.heartbeatWithFuture().get(5, TimeUnit.SECONDS);
    executor.close();
    Mockito.verify(fileSystemMaster).resetFile(fileId);
    Mockito.verify(job).run();
}
Also used : FileSystemMasterView(alluxio.master.file.meta.FileSystemMasterView) Lineage(alluxio.master.lineage.meta.Lineage) FileSystemMaster(alluxio.master.file.FileSystemMaster) Job(alluxio.job.Job) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with FileSystemMasterView

use of alluxio.master.file.meta.FileSystemMasterView in project alluxio by Alluxio.

the class DefaultAsyncPersistHandlerTest method persistenceFileWithBlocksOnMultipleWorkers.

/**
 * Tests the persistence of file with block on multiple workers.
 */
@Test
public void persistenceFileWithBlocksOnMultipleWorkers() throws Exception {
    DefaultAsyncPersistHandler handler = new DefaultAsyncPersistHandler(new FileSystemMasterView(mFileSystemMaster));
    AlluxioURI path = new AlluxioURI("/test");
    List<FileBlockInfo> blockInfoList = new ArrayList<>();
    BlockLocation location1 = new BlockLocation().setWorkerId(1);
    blockInfoList.add(new FileBlockInfo().setBlockInfo(new BlockInfo().setLocations(Lists.newArrayList(location1))));
    BlockLocation location2 = new BlockLocation().setWorkerId(2);
    blockInfoList.add(new FileBlockInfo().setBlockInfo(new BlockInfo().setLocations(Lists.newArrayList(location2))));
    long fileId = 2;
    when(mFileSystemMaster.getFileId(path)).thenReturn(fileId);
    when(mFileSystemMaster.getFileInfo(fileId)).thenReturn(new FileInfo().setLength(1).setCompleted(true));
    when(mFileSystemMaster.getFileBlockInfoList(path)).thenReturn(blockInfoList);
    // no persist scheduled on any worker
    assertEquals(0, handler.pollFilesToPersist(1).size());
    assertEquals(0, handler.pollFilesToPersist(2).size());
}
Also used : 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 5 with FileSystemMasterView

use of alluxio.master.file.meta.FileSystemMasterView in project alluxio by Alluxio.

the class CheckpointLatestPlannerTest method schedule.

/**
   * Tests the {@link CheckpointLatestPlanner#generatePlan(LineageStoreView, FileSystemMasterView)}
   * method.
   */
@Test
public void schedule() throws Exception {
    long fileId1 = 1L;
    long fileId2 = 2L;
    long l1 = mLineageStore.createLineage(new ArrayList<Long>(), Lists.newArrayList(fileId1), mJob);
    // Sleep for 1ms to guarantee that the next lineage's creation time is later than the first's
    CommonUtils.sleepMs(1);
    long l2 = mLineageStore.createLineage(Lists.newArrayList(fileId1), Lists.newArrayList(fileId2), mJob);
    Mockito.when(mFileSystemMaster.getPersistenceState(fileId1)).thenReturn(PersistenceState.NOT_PERSISTED);
    Mockito.when(mFileSystemMaster.getPersistenceState(fileId2)).thenReturn(PersistenceState.NOT_PERSISTED);
    FileInfo fileInfo1 = new FileInfo();
    fileInfo1.setCompleted(true);
    Mockito.when(mFileSystemMaster.getFileInfo(fileId1)).thenReturn(fileInfo1);
    FileInfo fileInfo2 = new FileInfo();
    fileInfo2.setCompleted(false);
    Mockito.when(mFileSystemMaster.getFileInfo(fileId2)).thenReturn(fileInfo2);
    CheckpointPlan plan = mPlanner.generatePlan(new LineageStoreView(mLineageStore), new FileSystemMasterView(mFileSystemMaster));
    Assert.assertEquals((Long) l1, plan.getLineagesToCheckpoint().get(0));
    // complete file 2 and it's ready for checkpoint
    fileInfo2.setCompleted(true);
    plan = mPlanner.generatePlan(new LineageStoreView(mLineageStore), new FileSystemMasterView(mFileSystemMaster));
    Assert.assertEquals((Long) l2, plan.getLineagesToCheckpoint().get(0));
}
Also used : FileSystemMasterView(alluxio.master.file.meta.FileSystemMasterView) FileInfo(alluxio.wire.FileInfo) LineageStoreView(alluxio.master.lineage.meta.LineageStoreView) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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