Search in sources :

Example 6 with LineageRecord

use of io.cdap.cdap.proto.metadata.lineage.LineageRecord in project cdap by caskdata.

the class GetDatasetLineageCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    long currentTime = System.currentTimeMillis();
    DatasetId dataset = cliConfig.getCurrentNamespace().dataset(arguments.get(ArgumentName.DATASET.toString()));
    long start = getTimestamp(arguments.getOptional("start", "min"), currentTime);
    long end = getTimestamp(arguments.getOptional("end", "max"), currentTime);
    Integer levels = arguments.getIntOptional("levels", null);
    LineageRecord lineage = client.getLineage(dataset, start, end, levels);
    Table table = Table.builder().setHeader("start", "end", "relations", "programs", "data").setRows(Collections.<List<String>>singletonList(Lists.newArrayList(Long.toString(lineage.getStart()), Long.toString(lineage.getEnd()), GSON.toJson(lineage.getRelations()), GSON.toJson(lineage.getPrograms()), GSON.toJson(lineage.getData())))).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : Table(io.cdap.cdap.cli.util.table.Table) LineageRecord(io.cdap.cdap.proto.metadata.lineage.LineageRecord) List(java.util.List) DatasetId(io.cdap.cdap.proto.id.DatasetId)

Aggregations

LineageRecord (io.cdap.cdap.proto.metadata.lineage.LineageRecord)6 DatasetId (io.cdap.cdap.proto.id.DatasetId)4 Table (io.cdap.cdap.cli.util.table.Table)2 AllProgramsApp (io.cdap.cdap.client.app.AllProgramsApp)2 Lineage (io.cdap.cdap.data2.metadata.lineage.Lineage)2 Relation (io.cdap.cdap.data2.metadata.lineage.Relation)2 NamespaceMeta (io.cdap.cdap.proto.NamespaceMeta)2 ApplicationId (io.cdap.cdap.proto.id.ApplicationId)2 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)2 ProgramId (io.cdap.cdap.proto.id.ProgramId)2 DataRecord (io.cdap.cdap.proto.metadata.lineage.DataRecord)2 ProgramRecord (io.cdap.cdap.proto.metadata.lineage.ProgramRecord)2 RelationRecord (io.cdap.cdap.proto.metadata.lineage.RelationRecord)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 RunId (org.apache.twill.api.RunId)2 Test (org.junit.Test)2