Search in sources :

Example 1 with LineageStoreView

use of alluxio.master.lineage.meta.LineageStoreView 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 LineageStoreView

use of alluxio.master.lineage.meta.LineageStoreView 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)2 LineageStoreView (alluxio.master.lineage.meta.LineageStoreView)2 CommandLineJob (alluxio.job.CommandLineJob)1 JobConf (alluxio.job.JobConf)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 LineageIdGenerator (alluxio.master.lineage.meta.LineageIdGenerator)1 LineageStore (alluxio.master.lineage.meta.LineageStore)1 FileInfo (alluxio.wire.FileInfo)1 Before (org.junit.Before)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1