Search in sources :

Example 1 with Job

use of alluxio.job.Job 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 2 with Job

use of alluxio.job.Job in project alluxio by Alluxio.

the class Lineage method fromJournalEntry.

/**
   * Converts the entry to a {@link Lineage}.
   *
   * @param entry the entry to convert
   * @return the {@link Lineage} representation
   */
public static Lineage fromJournalEntry(LineageEntry entry) {
    List<Long> inputFiles = new ArrayList<>(entry.getInputFilesList());
    List<Long> outputFiles = new ArrayList<>(entry.getOutputFileIdsList());
    Job job = new CommandLineJob(entry.getJobCommand(), new JobConf(entry.getJobOutputPath()));
    return new Lineage(entry.getId(), inputFiles, outputFiles, job, entry.getCreationTimeMs());
}
Also used : ArrayList(java.util.ArrayList) Job(alluxio.job.Job) CommandLineJob(alluxio.job.CommandLineJob) CommandLineJob(alluxio.job.CommandLineJob) JobConf(alluxio.job.JobConf)

Aggregations

Job (alluxio.job.Job)2 CommandLineJob (alluxio.job.CommandLineJob)1 JobConf (alluxio.job.JobConf)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 FileSystemMasterView (alluxio.master.file.meta.FileSystemMasterView)1 Lineage (alluxio.master.lineage.meta.Lineage)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1