use of org.apache.atlas.model.lineage.AtlasLineageInfo in project incubator-atlas by apache.
the class EntityLineageJerseyResourceIT method testOutputLineageInfo.
@Test
public void testOutputLineageInfo() throws Exception {
String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesFactTable).getId()._getId();
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(DIRECTION_PARAM, OUTPUT_DIRECTION);
queryParams.add(DEPTH_PARAM, "5");
JSONObject response = atlasClientV1.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
Assert.assertNotNull(response);
System.out.println("output lineage info = " + response);
AtlasLineageInfo outputLineageInfo = gson.fromJson(response.toString(), AtlasLineageInfo.class);
Map<String, AtlasEntityHeader> entities = outputLineageInfo.getGuidEntityMap();
Assert.assertNotNull(entities);
Set<AtlasLineageInfo.LineageRelation> relations = outputLineageInfo.getRelations();
Assert.assertNotNull(relations);
Assert.assertEquals(entities.size(), 5);
Assert.assertEquals(relations.size(), 4);
Assert.assertEquals(outputLineageInfo.getLineageDirection(), AtlasLineageInfo.LineageDirection.OUTPUT);
Assert.assertEquals(outputLineageInfo.getLineageDepth(), 5);
Assert.assertEquals(outputLineageInfo.getBaseEntityGuid(), tableId);
}
use of org.apache.atlas.model.lineage.AtlasLineageInfo in project incubator-atlas by apache.
the class EntityLineageJerseyResourceIT method testLineageInfo.
@Test
public void testLineageInfo() throws Exception {
String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId();
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(DIRECTION_PARAM, BOTH_DIRECTION);
queryParams.add(DEPTH_PARAM, "5");
JSONObject response = atlasClientV1.callAPI(LINEAGE_V2_API, JSONObject.class, queryParams, tableId);
Assert.assertNotNull(response);
System.out.println("both lineage info = " + response);
AtlasLineageInfo bothLineageInfo = gson.fromJson(response.toString(), AtlasLineageInfo.class);
Map<String, AtlasEntityHeader> entities = bothLineageInfo.getGuidEntityMap();
Assert.assertNotNull(entities);
Set<AtlasLineageInfo.LineageRelation> relations = bothLineageInfo.getRelations();
Assert.assertNotNull(relations);
Assert.assertEquals(entities.size(), 6);
Assert.assertEquals(relations.size(), 5);
Assert.assertEquals(bothLineageInfo.getLineageDirection(), AtlasLineageInfo.LineageDirection.BOTH);
Assert.assertEquals(bothLineageInfo.getLineageDepth(), 5);
Assert.assertEquals(bothLineageInfo.getBaseEntityGuid(), tableId);
}
use of org.apache.atlas.model.lineage.AtlasLineageInfo in project incubator-atlas by apache.
the class EntityLineageServiceTest method testGetOutputLineageInfo.
@Test
public void testGetOutputLineageInfo() throws Exception {
TestUtils.skipForGremlin3EnabledGraphDb();
String entityGuid = getEntityId(HIVE_TABLE_TYPE, "name", "sales_fact");
AtlasLineageInfo outputLineage = getOutputLineageInfo(entityGuid, 4);
assertNotNull(outputLineage);
System.out.println("output lineage = " + outputLineage);
Map<String, AtlasEntityHeader> entities = outputLineage.getGuidEntityMap();
assertNotNull(entities);
Set<LineageRelation> relations = outputLineage.getRelations();
assertNotNull(relations);
Assert.assertEquals(entities.size(), 5);
Assert.assertEquals(relations.size(), 4);
Assert.assertEquals(outputLineage.getLineageDepth(), 4);
Assert.assertEquals(outputLineage.getLineageDirection(), LineageDirection.OUTPUT);
assertTrue(entities.containsKey(outputLineage.getBaseEntityGuid()));
}
use of org.apache.atlas.model.lineage.AtlasLineageInfo in project incubator-atlas by apache.
the class EntityLineageServiceTest method testGetInputLineageInfo.
@Test
public void testGetInputLineageInfo() throws Exception {
TestUtils.skipForGremlin3EnabledGraphDb();
String entityGuid = getEntityId(HIVE_TABLE_TYPE, "name", "sales_fact_monthly_mv");
AtlasLineageInfo inputLineage = getInputLineageInfo(entityGuid, 4);
assertNotNull(inputLineage);
System.out.println("input lineage = " + inputLineage);
Map<String, AtlasEntityHeader> entities = inputLineage.getGuidEntityMap();
assertNotNull(entities);
Set<LineageRelation> relations = inputLineage.getRelations();
assertNotNull(relations);
Assert.assertEquals(entities.size(), 6);
Assert.assertEquals(relations.size(), 5);
Assert.assertEquals(inputLineage.getLineageDepth(), 4);
Assert.assertEquals(inputLineage.getLineageDirection(), LineageDirection.INPUT);
assertTrue(entities.containsKey(inputLineage.getBaseEntityGuid()));
}
use of org.apache.atlas.model.lineage.AtlasLineageInfo in project incubator-atlas by apache.
the class LineageResource method inputsGraph.
/**
* Returns input lineage graph for the given entity id.
* @param guid dataset entity id
* @return
*/
@GET
@Path("{guid}/inputs/graph")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response inputsGraph(@PathParam("guid") String guid) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> LineageResource.inputsGraph({})", guid);
}
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "LineageResource.inputsGraph(" + guid + ")");
}
AtlasLineageInfo lineageInfo = atlasLineageService.getAtlasLineageInfo(guid, LineageDirection.INPUT, -1);
final String result = LineageUtils.toLineageStruct(lineageInfo, typeRegistry);
JSONObject response = new JSONObject();
response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
response.put(AtlasClient.RESULTS, new JSONObject(result));
return Response.ok(response).build();
} catch (AtlasBaseException e) {
LOG.error("Unable to get lineage inputs graph for entity guid={}", guid, e);
throw new WebApplicationException(Servlets.getErrorResponse(e));
} catch (WebApplicationException e) {
LOG.error("Unable to get lineage inputs graph for entity guid={}", guid, e);
throw e;
} catch (JSONException e) {
LOG.error("Unable to get lineage inputs graph for entity guid={}", guid, e);
throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
} finally {
AtlasPerfTracer.log(perf);
if (LOG.isDebugEnabled()) {
LOG.debug("<== LineageResource.inputsGraph({})", guid);
}
}
}
Aggregations