Search in sources :

Example 1 with LineageInfo

use of alluxio.wire.LineageInfo in project alluxio by Alluxio.

the class LineageMasterIntegrationTest method lineageCreation.

@Test
public void lineageCreation() throws Exception {
    try (LineageMasterClient lineageMasterClient = getLineageMasterClient()) {
        ArrayList<String> outFiles = new ArrayList<>();
        Collections.addAll(outFiles, OUT_FILE);
        lineageMasterClient.createLineage(new ArrayList<String>(), outFiles, mJob);
        List<LineageInfo> infos = lineageMasterClient.getLineageInfoList();
        Assert.assertEquals(1, infos.size());
        AlluxioURI uri = new AlluxioURI(infos.get(0).getOutputFiles().get(0));
        URIStatus status = getFileSystemMasterClient().getStatus(uri);
        Assert.assertEquals(PersistenceState.NOT_PERSISTED.toString(), status.getPersistenceState());
        Assert.assertFalse(status.isCompleted());
    }
}
Also used : ArrayList(java.util.ArrayList) LineageMasterClient(alluxio.client.lineage.LineageMasterClient) URIStatus(alluxio.client.file.URIStatus) LineageInfo(alluxio.wire.LineageInfo) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 2 with LineageInfo

use of alluxio.wire.LineageInfo in project alluxio by Alluxio.

the class ListLineagesCommand method run.

@Override
public void run(CommandLine cl) throws IOException {
    AlluxioLineage tl = AlluxioLineage.get(LineageContext.INSTANCE);
    List<LineageInfo> infos = tl.getLineageInfoList();
    for (LineageInfo info : infos) {
        System.out.println(info);
    }
}
Also used : AlluxioLineage(alluxio.client.lineage.AlluxioLineage) LineageInfo(alluxio.wire.LineageInfo)

Example 3 with LineageInfo

use of alluxio.wire.LineageInfo 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 4 with LineageInfo

use of alluxio.wire.LineageInfo in project alluxio by Alluxio.

the class LineageMasterTest method listLineages.

/**
   * Tests the {@link LineageMaster#getLineageInfoList()} method.
   */
@Test
public void listLineages() throws Exception {
    Mockito.when(mFileSystemMaster.getPath(Mockito.anyLong())).thenReturn(new AlluxioURI("test"));
    mLineageMaster.start(true);
    mLineageMaster.createLineage(new ArrayList<AlluxioURI>(), Lists.newArrayList(new AlluxioURI("/test1")), mJob);
    mLineageMaster.createLineage(Lists.newArrayList(new AlluxioURI("/test1")), Lists.newArrayList(new AlluxioURI("/test2")), mJob);
    List<LineageInfo> info = mLineageMaster.getLineageInfoList();
    Assert.assertEquals(2, info.size());
}
Also used : LineageInfo(alluxio.wire.LineageInfo) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with LineageInfo

use of alluxio.wire.LineageInfo in project alluxio by Alluxio.

the class LineageMasterClientRestApiTest method getLineageInfoList.

@Test
@Config(confParams = { PropertyKey.Name.USER_LINEAGE_ENABLED, "true" })
public void getLineageInfoList() throws Exception {
    AlluxioURI input = new AlluxioURI("/input");
    AlluxioURI output = new AlluxioURI("/output");
    LineageMaster lineageMaster = mMaster.getLineageMaster();
    mLineageClient.createFile(new AlluxioURI("/input")).close();
    long lineageId = lineageMaster.createLineage(Lists.newArrayList(input), Lists.newArrayList(output), new CommandLineJob("test", new JobConf(output.getPath())));
    String result = new TestCase(mHostname, mPort, getEndpoint(LineageMasterClientRestServiceHandler.GET_LINEAGE_INFO_LIST), NO_PARAMS, HttpMethod.GET, null).call();
    List<LineageInfo> lineageInfos = new ObjectMapper().readValue(result, new TypeReference<List<LineageInfo>>() {
    });
    LineageInfo lineageInfo = Iterables.getOnlyElement(lineageInfos);
    Assert.assertEquals(ImmutableList.of(input.toString()), lineageInfo.getInputFiles());
    Assert.assertEquals(ImmutableList.of(output.toString()), lineageInfo.getOutputFiles());
    Assert.assertEquals(lineageId, lineageInfo.getId());
}
Also used : TestCase(alluxio.rest.TestCase) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) CommandLineJob(alluxio.job.CommandLineJob) JobConf(alluxio.job.JobConf) LineageInfo(alluxio.wire.LineageInfo) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest) Config(alluxio.LocalAlluxioClusterResource.Config)

Aggregations

LineageInfo (alluxio.wire.LineageInfo)6 AlluxioURI (alluxio.AlluxioURI)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 URIStatus (alluxio.client.file.URIStatus)2 LineageMasterClient (alluxio.client.lineage.LineageMasterClient)2 Config (alluxio.LocalAlluxioClusterResource.Config)1 FileOutStream (alluxio.client.file.FileOutStream)1 CreateFileOptions (alluxio.client.file.options.CreateFileOptions)1 AlluxioLineage (alluxio.client.lineage.AlluxioLineage)1 LineageFileSystem (alluxio.client.lineage.LineageFileSystem)1 CommandLineJob (alluxio.job.CommandLineJob)1 JobConf (alluxio.job.JobConf)1 Lineage (alluxio.master.lineage.meta.Lineage)1 RestApiTest (alluxio.rest.RestApiTest)1 TestCase (alluxio.rest.TestCase)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1