Search in sources :

Example 1 with DataSetLineageResponse

use of org.apache.atlas.v1.model.lineage.DataSetLineageResponse in project atlas by apache.

the class DataSetLineageResource method inputsGraph.

/**
 * Returns the inputs graph for a given entity.
 *
 * @param tableName table name
 */
@GET
@Path("table/{tableName}/inputs/graph")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public DataSetLineageResponse inputsGraph(@Context HttpServletRequest request, @PathParam("tableName") String tableName) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> DataSetLineageResource.inputsGraph({})", tableName);
    }
    DataSetLineageResponse ret = new DataSetLineageResponse();
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DataSetLineageResource.inputsGraph(tableName=" + tableName + ")");
        }
        String guid = getGuid(tableName);
        AtlasLineageInfo lineageInfo = atlasLineageService.getAtlasLineageInfo(guid, LineageDirection.INPUT, -1);
        ret.setTableName(tableName);
        ret.setRequestId(Servlets.getRequestId());
        ret.setResults(LineageUtils.toLineageStruct(lineageInfo, typeRegistry));
        return ret;
    } catch (IllegalArgumentException e) {
        LOG.error("Unable to get lineage inputs graph for table {}", tableName, e);
        throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
    } catch (WebApplicationException e) {
        LOG.error("Unable to get lineage inputs graph for table {}", tableName, e);
        throw e;
    } catch (Throwable e) {
        LOG.error("Unable to get lineage inputs graph for table {}", tableName, e);
        throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasLineageInfo(org.apache.atlas.model.lineage.AtlasLineageInfo) WebApplicationException(javax.ws.rs.WebApplicationException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) DataSetLineageResponse(org.apache.atlas.v1.model.lineage.DataSetLineageResponse) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with DataSetLineageResponse

use of org.apache.atlas.v1.model.lineage.DataSetLineageResponse in project atlas by apache.

the class DataSetLineageResource method outputsGraph.

/**
 * Returns the outputs graph for a given entity.
 *
 * @param tableName table name
 */
@GET
@Path("table/{tableName}/outputs/graph")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public DataSetLineageResponse outputsGraph(@Context HttpServletRequest request, @PathParam("tableName") String tableName) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> DataSetLineageResource.outputsGraph({})", tableName);
    }
    DataSetLineageResponse ret = new DataSetLineageResponse();
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DataSetLineageResource.outputsGraph(tableName=" + tableName + ")");
        }
        String guid = getGuid(tableName);
        AtlasLineageInfo lineageInfo = atlasLineageService.getAtlasLineageInfo(guid, LineageDirection.OUTPUT, -1);
        ret.setTableName(tableName);
        ret.setRequestId(Servlets.getRequestId());
        ret.setResults(LineageUtils.toLineageStruct(lineageInfo, typeRegistry));
        return ret;
    } catch (IllegalArgumentException e) {
        LOG.error("Unable to get lineage outputs graph for table {}", tableName, e);
        throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
    } catch (WebApplicationException e) {
        LOG.error("Unable to get lineage outputs graph for table {}", tableName, e);
        throw e;
    } catch (Throwable e) {
        LOG.error("Unable to get lineage outputs graph for table {}", tableName, e);
        throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasLineageInfo(org.apache.atlas.model.lineage.AtlasLineageInfo) WebApplicationException(javax.ws.rs.WebApplicationException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) DataSetLineageResponse(org.apache.atlas.v1.model.lineage.DataSetLineageResponse) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 AtlasLineageInfo (org.apache.atlas.model.lineage.AtlasLineageInfo)2 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)2 DataSetLineageResponse (org.apache.atlas.v1.model.lineage.DataSetLineageResponse)2