Search in sources :

Example 1 with Lineage

use of alluxio.master.lineage.meta.Lineage in project alluxio by Alluxio.

the class LineageMaster method deleteLineageInternal.

private boolean deleteLineageInternal(long lineageId, boolean cascade) throws LineageDoesNotExistException, LineageDeletionException {
    Lineage lineage = mLineageStore.getLineage(lineageId);
    LineageDoesNotExistException.check(lineage != null, ExceptionMessage.LINEAGE_DOES_NOT_EXIST, lineageId);
    // there should not be child lineage if not cascade
    if (!cascade && !mLineageStore.getChildren(lineage).isEmpty()) {
        throw new LineageDeletionException(ExceptionMessage.DELETE_LINEAGE_WITH_CHILDREN.getMessage(lineageId));
    }
    LOG.info("Delete lineage {}", lineageId);
    mLineageStore.deleteLineage(lineageId);
    return true;
}
Also used : Lineage(alluxio.master.lineage.meta.Lineage) LineageDeletionException(alluxio.exception.LineageDeletionException)

Example 2 with Lineage

use of alluxio.master.lineage.meta.Lineage in project alluxio by Alluxio.

the class RecomputePlanner method plan.

/**
   * @return a {@link RecomputePlan} that identifies the lineages to recompute
   */
public RecomputePlan plan() {
    List<Long> lostFiles = mFileSystemMaster.getLostFiles();
    // lineage to recompute
    Set<Lineage> toRecompute = new HashSet<>();
    if (!lostFiles.isEmpty()) {
        LOG.info("report lost files {}", lostFiles);
        // report lost files
        for (long lostFile : lostFiles) {
            if (!mLineageStore.hasOutputFile(lostFile)) {
                continue;
            }
            Lineage lineage;
            try {
                lineage = mLineageStore.getLineageOfOutputFile(lostFile);
            } catch (LineageDoesNotExistException e) {
                // should not happen
                throw new IllegalStateException(e);
            }
            try {
                if (!LineageStateUtils.isPersisted(lineage, mFileSystemMaster.getFileSystemMasterView())) {
                    toRecompute.add(lineage);
                }
            } catch (FileDoesNotExistException e) {
                // should not happen
                throw new IllegalStateException(e);
            }
        }
    }
    List<Lineage> toRecomputeAfterSort = mLineageStore.sortLineageTopologically(toRecompute);
    return new RecomputePlan(toRecomputeAfterSort);
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) Lineage(alluxio.master.lineage.meta.Lineage) LineageDoesNotExistException(alluxio.exception.LineageDoesNotExistException) HashSet(java.util.HashSet)

Example 3 with Lineage

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

use of alluxio.master.lineage.meta.Lineage in project alluxio by Alluxio.

the class LineageMaster method getLineageInfoList.

/**
   * @return the list of all the {@link LineageInfo}s
   * @throws LineageDoesNotExistException if the lineage does not exist
   * @throws FileDoesNotExistException if any associated file does not exist
   */
public synchronized List<LineageInfo> getLineageInfoList() throws LineageDoesNotExistException, FileDoesNotExistException {
    List<LineageInfo> lineages = new ArrayList<>();
    for (Lineage lineage : mLineageStore.getAllInTopologicalOrder()) {
        LineageInfo info = new LineageInfo();
        List<Long> parents = new ArrayList<>();
        for (Lineage parent : mLineageStore.getParents(lineage)) {
            parents.add(parent.getId());
        }
        info.setParents(parents);
        List<Long> children = new ArrayList<>();
        for (Lineage child : mLineageStore.getChildren(lineage)) {
            children.add(child.getId());
        }
        info.setChildren(children);
        info.setId(lineage.getId());
        List<String> inputFiles = new ArrayList<>();
        for (long inputFileId : lineage.getInputFiles()) {
            inputFiles.add(mFileSystemMaster.getPath(inputFileId).toString());
        }
        info.setInputFiles(inputFiles);
        List<String> outputFiles = new ArrayList<>();
        for (long outputFileId : lineage.getOutputFiles()) {
            outputFiles.add(mFileSystemMaster.getPath(outputFileId).toString());
        }
        info.setOutputFiles(outputFiles);
        info.setCreationTimeMs(lineage.getCreationTime());
        info.setJob(((CommandLineJob) lineage.getJob()).generateCommandLineJobInfo());
        lineages.add(info);
    }
    return lineages;
}
Also used : ArrayList(java.util.ArrayList) Lineage(alluxio.master.lineage.meta.Lineage) LineageInfo(alluxio.wire.LineageInfo)

Example 5 with Lineage

use of alluxio.master.lineage.meta.Lineage in project alluxio by Alluxio.

the class CheckpointLatestPlanner method generatePlan.

@Override
public CheckpointPlan generatePlan(LineageStoreView store, FileSystemMasterView fileSystemMasterView) {
    Lineage toCheckpoint = null;
    long latestCreated = 0;
    for (Lineage lineage : store.getAllLineagesInTopologicalOrder()) {
        try {
            if (!LineageStateUtils.isCompleted(lineage, fileSystemMasterView) || LineageStateUtils.isPersisted(lineage, fileSystemMasterView) || LineageStateUtils.needRecompute(lineage, fileSystemMasterView) || LineageStateUtils.isInCheckpointing(lineage, fileSystemMasterView)) {
                continue;
            }
        } catch (FileDoesNotExistException | AccessControlException e) {
            LOG.error("The lineage file does not exist", e);
            continue;
        }
        if (lineage.getCreationTime() > latestCreated) {
            latestCreated = lineage.getCreationTime();
            toCheckpoint = lineage;
        }
    }
    return toCheckpoint == null ? new CheckpointPlan(new ArrayList<Long>()) : new CheckpointPlan(Lists.newArrayList(toCheckpoint.getId()));
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) Lineage(alluxio.master.lineage.meta.Lineage) ArrayList(java.util.ArrayList) AccessControlException(alluxio.exception.AccessControlException)

Aggregations

Lineage (alluxio.master.lineage.meta.Lineage)5 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)2 ArrayList (java.util.ArrayList)2 AccessControlException (alluxio.exception.AccessControlException)1 LineageDeletionException (alluxio.exception.LineageDeletionException)1 LineageDoesNotExistException (alluxio.exception.LineageDoesNotExistException)1 Job (alluxio.job.Job)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 FileSystemMasterView (alluxio.master.file.meta.FileSystemMasterView)1 LineageInfo (alluxio.wire.LineageInfo)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1