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());
}
}
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);
}
}
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;
}
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());
}
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());
}
Aggregations