You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ap...@apache.org on 2017/11/09 06:54:06 UTC

atlas git commit: ATLAS-2251: Lineage/DataSetLineage fixes

Repository: atlas
Updated Branches:
  refs/heads/ATLAS-2251 663e4f58a -> aa85a8ad4


ATLAS-2251: Lineage/DataSetLineage fixes


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/aa85a8ad
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/aa85a8ad
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/aa85a8ad

Branch: refs/heads/ATLAS-2251
Commit: aa85a8ad4820065423e1e5f34f15e21d5095f618
Parents: 663e4f5
Author: apoorvnaik <ap...@apache.org>
Authored: Wed Nov 8 22:53:49 2017 -0800
Committer: apoorvnaik <ap...@apache.org>
Committed: Wed Nov 8 22:54:02 2017 -0800

----------------------------------------------------------------------
 .../model/lineage/DataSetLineageResponse.java   | 43 +++++++++
 .../atlas/v1/model/lineage/LineageResponse.java | 53 +++++++++++
 .../atlas/discovery/AtlasLineageService.java    | 15 ++++
 .../atlas/discovery/EntityLineageService.java   | 87 +++++++++++++++---
 .../web/resources/DataSetLineageResource.java   | 93 ++++++++++++++------
 .../atlas/web/resources/LineageResource.java    | 47 +++++-----
 .../org/apache/atlas/web/util/LineageUtils.java | 17 ++--
 7 files changed, 282 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/aa85a8ad/intg/src/main/java/org/apache/atlas/v1/model/lineage/DataSetLineageResponse.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/lineage/DataSetLineageResponse.java b/intg/src/main/java/org/apache/atlas/v1/model/lineage/DataSetLineageResponse.java
new file mode 100644
index 0000000..e6d4815
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/v1/model/lineage/DataSetLineageResponse.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.v1.model.lineage;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class DataSetLineageResponse extends LineageResponse {
+    private String tableName;
+
+    public DataSetLineageResponse() {
+    }
+
+    public String getTableName() {
+        return tableName;
+    }
+
+    public void setTableName(final String tableName) {
+        this.tableName = tableName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/aa85a8ad/intg/src/main/java/org/apache/atlas/v1/model/lineage/LineageResponse.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/v1/model/lineage/LineageResponse.java b/intg/src/main/java/org/apache/atlas/v1/model/lineage/LineageResponse.java
new file mode 100644
index 0000000..e1c392d
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/v1/model/lineage/LineageResponse.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.v1.model.lineage;
+
+import org.apache.atlas.v1.model.instance.Struct;
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class LineageResponse {
+    private String      requestId;
+    private Struct results;
+
+    public LineageResponse() {
+    }
+
+    public Struct getResults() {
+        return results;
+    }
+
+    public void setResults(final Struct results) {
+        this.results = results;
+    }
+
+    public String getRequestId() {
+        return requestId;
+    }
+
+    public void setRequestId(final String requestId) {
+        this.requestId = requestId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/aa85a8ad/repository/src/main/java/org/apache/atlas/discovery/AtlasLineageService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/AtlasLineageService.java b/repository/src/main/java/org/apache/atlas/discovery/AtlasLineageService.java
index 5f49625..4282429 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/AtlasLineageService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/AtlasLineageService.java
@@ -32,4 +32,19 @@ public interface AtlasLineageService {
      */
     AtlasLineageInfo getAtlasLineageInfo(String entityGuid, LineageDirection direction, int depth) throws AtlasBaseException;
 
+    /**
+     * Return the schema for the given datasetName.
+     *
+     * @param datasetName datasetName
+     * @return Schema as JSON
+     */
+    String getSchema(String datasetName) throws AtlasBaseException;
+
+    /**
+     * Return the schema for the given entity id.
+     *
+     * @param guid tableName
+     * @return Schema as JSON
+     */
+    String getSchemaForEntity(String guid) throws AtlasBaseException;
 }

http://git-wip-us.apache.org/repos/asf/atlas/blob/aa85a8ad/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
index 3ae41c8..0faedab 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,9 +20,11 @@ package org.apache.atlas.discovery;
 
 
 import org.apache.atlas.AtlasClient;
+import org.apache.atlas.AtlasConfiguration;
 import org.apache.atlas.AtlasErrorCode;
 import org.apache.atlas.annotation.GraphTransaction;
 import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.model.discovery.AtlasSearchResult;
 import org.apache.atlas.model.instance.AtlasEntityHeader;
 import org.apache.atlas.model.lineage.AtlasLineageInfo;
 import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
@@ -36,6 +38,8 @@ import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.util.AtlasGremlinQueryProvider;
 import org.apache.atlas.util.AtlasGremlinQueryProvider.AtlasGremlinQuery;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
@@ -48,18 +52,24 @@ import java.util.Set;
 
 @Service
 public class EntityLineageService implements AtlasLineageService {
-    private static final String INPUT_PROCESS_EDGE      =  "__Process.inputs";
-    private static final String OUTPUT_PROCESS_EDGE     =  "__Process.outputs";
+    private static final String INPUT_PROCESS_EDGE  = "__Process.inputs";
+    private static final String OUTPUT_PROCESS_EDGE = "__Process.outputs";
+
+    public static final String DATASET_SCHEMA_QUERY_PREFIX = "atlas.lineage.schema.query.";
 
     private final AtlasGraph                graph;
     private final AtlasGremlinQueryProvider gremlinQueryProvider;
     private final EntityGraphRetriever      entityRetriever;
+    private final AtlasDiscoveryService     atlasDiscoveryService;
+    private final Configuration             atlasConfiguration;
 
     @Inject
-    EntityLineageService(AtlasTypeRegistry typeRegistry, AtlasGraph atlasGraph) throws DiscoveryException {
-        this.graph                = atlasGraph;
+    EntityLineageService(AtlasTypeRegistry typeRegistry, AtlasGraph atlasGraph, final AtlasDiscoveryService atlasDiscoveryService, final Configuration atlasConfiguration) throws DiscoveryException {
+        this.graph = atlasGraph;
+        this.atlasDiscoveryService = atlasDiscoveryService;
+        this.atlasConfiguration = atlasConfiguration;
         this.gremlinQueryProvider = AtlasGremlinQueryProvider.INSTANCE;
-        this.entityRetriever      = new EntityGraphRetriever(typeRegistry);
+        this.entityRetriever = new EntityGraphRetriever(typeRegistry);
     }
 
     @Override
@@ -88,6 +98,46 @@ public class EntityLineageService implements AtlasLineageService {
         return lineageInfo;
     }
 
+    @Override
+    @GraphTransaction
+    public String getSchema(final String datasetName) throws AtlasBaseException {
+        if (StringUtils.isEmpty(datasetName)) {
+            // TODO: Complete error handling here
+            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST);
+        }
+        Iterator<AtlasVertex> vertices = graph.query().has("Referenceable.qualifiedName", datasetName)
+                                              .has(Constants.STATE_PROPERTY_KEY, "ACTIVE")
+                                              .has(Constants.SUPER_TYPES_PROPERTY_KEY, "DataSet")
+                                              .vertices().iterator();
+
+        if (vertices.hasNext()) {
+            AtlasVertex vertex   = vertices.next();
+            String      typeName = GraphHelper.getTypeName(vertex);
+            String      guid     = GraphHelper.getGuid(vertex);
+            return getSchemaForId(typeName, guid);
+        }
+        return null;
+    }
+
+    @Override
+    @GraphTransaction
+    public String getSchemaForEntity(final String guid) throws AtlasBaseException {
+        if (StringUtils.isEmpty(guid)) {
+            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST);
+        }
+        Iterator<AtlasVertex> vertices = graph.query().has(Constants.GUID_PROPERTY_KEY, guid)
+                                              .has(Constants.SUPER_TYPES_PROPERTY_KEY, AtlasClient.DATA_SET_SUPER_TYPE)
+                                              .vertices().iterator();
+
+        if (vertices.hasNext()) {
+            AtlasVertex vertex = vertices.next();
+            String      typeName = GraphHelper.getTypeName(vertex);
+            return getSchemaForId(typeName, guid);
+
+        }
+        return null;
+    }
+
     private AtlasLineageInfo getLineageInfo(String guid, LineageDirection direction, int depth) throws AtlasBaseException {
         Map<String, AtlasEntityHeader> entities     = new HashMap<>();
         Set<LineageRelation>           relations    = new HashSet<>();
@@ -108,7 +158,7 @@ public class EntityLineageService implements AtlasLineageService {
                                 continue;
                             }
 
-                            AtlasEntityHeader entity = entityRetriever.toAtlasEntityHeader((AtlasVertex)vertex);
+                            AtlasEntityHeader entity = entityRetriever.toAtlasEntityHeader((AtlasVertex) vertex);
 
                             if (!entities.containsKey(entity.getGuid())) {
                                 entities.put(entity.getGuid(), entity);
@@ -169,10 +219,10 @@ public class EntityLineageService implements AtlasLineageService {
     }
 
     private boolean entityExists(String guid) {
-        boolean               ret     = false;
+        boolean ret = false;
         Iterator<AtlasVertex> results = graph.query()
-                                        .has(Constants.GUID_PROPERTY_KEY, guid)
-                                        .vertices().iterator();
+                                             .has(Constants.GUID_PROPERTY_KEY, guid)
+                                             .vertices().iterator();
 
         while (results.hasNext()) {
             AtlasVertex  entityVertex = results.next();
@@ -183,4 +233,17 @@ public class EntityLineageService implements AtlasLineageService {
 
         return ret;
     }
+
+    private String getSchemaForId(String typeName, String guid) throws AtlasBaseException {
+        String configName     = DATASET_SCHEMA_QUERY_PREFIX + typeName;
+        String schemaTemplate = atlasConfiguration.getString(configName);
+        if (schemaTemplate != null) {
+            final String      schemaQuery  = String.format(schemaTemplate, guid);
+            int               limit        = AtlasConfiguration.SEARCH_MAX_LIMIT.getInt();
+            AtlasSearchResult searchResult = atlasDiscoveryService.searchUsingDslQuery(schemaQuery, limit, 0);
+            // TODO: Fix the return there
+            return null;
+        }
+        throw new AtlasBaseException("Schema is not configured for type " + typeName + ". Configure " + configName);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/atlas/blob/aa85a8ad/webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
index 278d7ca..bb7a122 100644
--- a/webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/DataSetLineageResource.java
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,8 +19,20 @@
 package org.apache.atlas.web.resources;
 
 import org.apache.atlas.AtlasClient;
+import org.apache.atlas.AtlasErrorCode;
+import org.apache.atlas.discovery.AtlasLineageService;
+import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.model.instance.AtlasEntity;
+import org.apache.atlas.model.lineage.AtlasLineageInfo;
+import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
+import org.apache.atlas.repository.store.graph.AtlasEntityStore;
+import org.apache.atlas.type.AtlasEntityType;
+import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.utils.AtlasPerfTracer;
+import org.apache.atlas.v1.model.lineage.DataSetLineageResponse;
+import org.apache.atlas.web.util.LineageUtils;
 import org.apache.atlas.web.util.Servlets;
+import org.apache.commons.lang.StringUtils;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -29,9 +41,16 @@ import org.springframework.stereotype.Service;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Jersey Resource for Hive Table Lineage.
@@ -42,16 +61,18 @@ import javax.ws.rs.core.Response;
 @Deprecated
 public class DataSetLineageResource {
 
-    private static final Logger LOG = LoggerFactory.getLogger(DataSetLineageResource.class);
+    private static final Logger LOG      = LoggerFactory.getLogger(DataSetLineageResource.class);
     private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.DataSetLineageResource");
 
-    /**
-     * Created by the Guice ServletModule and injected with the
-     * configured LineageService.
-     *
-     */
+    private final AtlasLineageService atlasLineageService;
+    private final AtlasTypeRegistry   typeRegistry;
+    private final AtlasEntityStore    atlasEntityStore;
+
     @Inject
-    public DataSetLineageResource() {
+    public DataSetLineageResource(final AtlasLineageService atlasLineageService, final AtlasTypeRegistry typeRegistry, final AtlasEntityStore atlasEntityStore) {
+        this.atlasLineageService = atlasLineageService;
+        this.typeRegistry = typeRegistry;
+        this.atlasEntityStore = atlasEntityStore;
     }
 
     /**
@@ -63,26 +84,27 @@ public class DataSetLineageResource {
     @Path("table/{tableName}/inputs/graph")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public Response inputsGraph(@Context HttpServletRequest request, @PathParam("tableName") String tableName) {
+    public DataSetLineageResponse inputsGraph(@Context HttpServletRequest request, @PathParam("tableName") String tableName) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> DataSetLineageResource.inputsGraph({})", tableName);
         }
 
-        AtlasPerfTracer perf = null;
+        DataSetLineageResponse ret  = new DataSetLineageResponse();
+        AtlasPerfTracer        perf = null;
 
         try {
             if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
                 perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DataSetLineageResource.inputsGraph(tableName=" + tableName + ")");
             }
 
-            final String jsonResult = ""; // TODO-typeSystem-removal: lineageService.getInputsGraph(tableName);
+            String guid = getGuid(tableName);
 
-            JSONObject response = new JSONObject();
-            response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
-            response.put("tableName", tableName);
-            response.put(AtlasClient.RESULTS, new JSONObject(jsonResult));
+            AtlasLineageInfo lineageInfo = atlasLineageService.getAtlasLineageInfo(guid, LineageDirection.INPUT, -1);
+            ret.setTableName(tableName);
+            ret.setRequestId(Servlets.getRequestId());
+            ret.setResults(LineageUtils.toLineageStruct(lineageInfo, typeRegistry));
 
-            return Response.ok(response).build();
+            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));
@@ -106,26 +128,27 @@ public class DataSetLineageResource {
     @Path("table/{tableName}/outputs/graph")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public Response outputsGraph(@Context HttpServletRequest request, @PathParam("tableName") String tableName) {
+    public DataSetLineageResponse outputsGraph(@Context HttpServletRequest request, @PathParam("tableName") String tableName) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> DataSetLineageResource.outputsGraph({})", tableName);
         }
 
-        AtlasPerfTracer perf = null;
+        DataSetLineageResponse ret  = new DataSetLineageResponse();
+        AtlasPerfTracer        perf = null;
 
         try {
             if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
                 perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DataSetLineageResource.outputsGraph(tableName=" + tableName + ")");
             }
 
-            final String jsonResult = ""; // TODO-typeSystem-removal: lineageService.getOutputsGraph(tableName);
+            String guid = getGuid(tableName);
 
-            JSONObject response = new JSONObject();
-            response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
-            response.put("tableName", tableName);
-            response.put(AtlasClient.RESULTS, new JSONObject(jsonResult));
+            AtlasLineageInfo lineageInfo = atlasLineageService.getAtlasLineageInfo(guid, LineageDirection.OUTPUT, -1);
+            ret.setTableName(tableName);
+            ret.setRequestId(Servlets.getRequestId());
+            ret.setResults(LineageUtils.toLineageStruct(lineageInfo, typeRegistry));
 
-            return Response.ok(response).build();
+            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));
@@ -182,4 +205,20 @@ public class DataSetLineageResource {
             AtlasPerfTracer.log(perf);
         }
     }
+
+    private String getGuid(String tableName) throws AtlasBaseException {
+        if (StringUtils.isEmpty(tableName)) {
+            // TODO: Fix the error code if mismatch
+            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST);
+        }
+        Map<String, Object> lookupAttributes = new HashMap<>();
+        lookupAttributes.put("qualifiedName", tableName);
+        AtlasEntityType                    entityType = typeRegistry.getEntityTypeByName("hive_table");
+        AtlasEntity.AtlasEntityWithExtInfo hive_table = atlasEntityStore.getByUniqueAttributes(entityType, lookupAttributes);
+        if (hive_table != null) {
+            return hive_table.getEntity().getGuid();
+        } else {
+            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_NOT_FOUND, tableName);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/atlas/blob/aa85a8ad/webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
index cada5ee..66e5942 100644
--- a/webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/LineageResource.java
@@ -25,9 +25,9 @@ import org.apache.atlas.model.lineage.AtlasLineageInfo;
 import org.apache.atlas.model.lineage.AtlasLineageInfo.LineageDirection;
 import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.utils.AtlasPerfTracer;
+import org.apache.atlas.v1.model.lineage.LineageResponse;
 import org.apache.atlas.web.util.LineageUtils;
 import org.apache.atlas.web.util.Servlets;
-import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -58,8 +58,6 @@ public class LineageResource {
      * Created by the Guice ServletModule and injected with the
      * configured LineageService.
      *
-     * @param atlasLineageService lineage service handle
-     * @param typeRegistry        type registry
      */
     @Inject
     public LineageResource(AtlasLineageService atlasLineageService, AtlasTypeRegistry typeRegistry) {
@@ -76,11 +74,13 @@ public class LineageResource {
     @Path("{guid}/inputs/graph")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public Response inputsGraph(@PathParam("guid") String guid) {
+    public LineageResponse inputsGraph(@PathParam("guid") String guid) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> LineageResource.inputsGraph({})", guid);
         }
 
+        LineageResponse ret = new LineageResponse();
+
         AtlasPerfTracer perf = null;
         try {
             if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
@@ -88,22 +88,16 @@ public class LineageResource {
             }
 
             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));
+            ret.setRequestId(Servlets.getRequestId());
+            ret.setResults(LineageUtils.toLineageStruct(lineageInfo, typeRegistry));
 
-            return Response.ok(response).build();
+            return ret;
         } 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);
 
@@ -122,11 +116,13 @@ public class LineageResource {
     @Path("{guid}/outputs/graph")
     @Consumes(Servlets.JSON_MEDIA_TYPE)
     @Produces(Servlets.JSON_MEDIA_TYPE)
-    public Response outputsGraph(@PathParam("guid") String guid) {
+    public LineageResponse outputsGraph(@PathParam("guid") String guid) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> LineageResource.outputsGraph({})", guid);
         }
 
+        LineageResponse ret = new LineageResponse();
+
         AtlasPerfTracer perf = null;
 
         try {
@@ -135,22 +131,16 @@ public class LineageResource {
             }
 
             AtlasLineageInfo lineageInfo = atlasLineageService.getAtlasLineageInfo(guid, LineageDirection.OUTPUT, -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));
+            ret.setRequestId(Servlets.getRequestId());
+            ret.setResults(LineageUtils.toLineageStruct(lineageInfo, typeRegistry));
 
-            return Response.ok(response).build();
+            return ret;
         } catch (AtlasBaseException e) {
             LOG.error("Unable to get lineage outputs graph for entity guid={}", guid, e);
             throw new WebApplicationException(Servlets.getErrorResponse(e));
         } catch (WebApplicationException e) {
             LOG.error("Unable to get lineage outputs graph for entity guid={}", guid, e);
             throw e;
-        } catch (JSONException e) {
-            LOG.error("Unable to get lineage outputs graph for entity guid={}", guid, e);
-            throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
         } finally {
             AtlasPerfTracer.log(perf);
 
@@ -180,13 +170,22 @@ public class LineageResource {
                 perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "LineageResource.schema(" + guid + ")");
             }
 
-            final String jsonResult = ""; // TODO-typeSystem-removal: lineageService.getSchemaForEntity(guid);
+            final String jsonResult = atlasLineageService.getSchemaForEntity(guid);
 
             JSONObject response = new JSONObject();
             response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
             response.put(AtlasClient.RESULTS, new JSONObject(jsonResult));
 
             return Response.ok(response).build();
+//        } catch (SchemaNotFoundException e) {
+//            LOG.error("schema not found for {}", guid);
+//            throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND));
+//        } catch (EntityNotFoundException e) {
+//            LOG.error("table entity not found for {}", guid);
+//            throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND));
+//        } catch (DiscoveryException e) {
+//            LOG.error("Unable to get schema for entity guid={}", guid, e);
+//            throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
         } catch (IllegalArgumentException e) {
             LOG.error("Unable to get schema for entity guid={}", guid, e);
             throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));

http://git-wip-us.apache.org/repos/asf/atlas/blob/aa85a8ad/webapp/src/main/java/org/apache/atlas/web/util/LineageUtils.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/util/LineageUtils.java b/webapp/src/main/java/org/apache/atlas/web/util/LineageUtils.java
index 3145305..562d9b7 100644
--- a/webapp/src/main/java/org/apache/atlas/web/util/LineageUtils.java
+++ b/webapp/src/main/java/org/apache/atlas/web/util/LineageUtils.java
@@ -23,11 +23,11 @@ import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasEntityHeader;
 import org.apache.atlas.model.lineage.AtlasLineageInfo;
 import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
-import org.apache.atlas.v1.model.instance.Struct;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.type.AtlasEntityType;
 import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
+import org.apache.atlas.v1.model.instance.Struct;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -40,15 +40,15 @@ import java.util.concurrent.atomic.AtomicInteger;
 public final class LineageUtils {
     private LineageUtils() {}
 
-    private static final String VERTICES_ATTR_NAME    = "vertices";
-    private static final String EDGES_ATTR_NAME       = "edges";
     private static final String VERTEX_ID_ATTR_NAME   = "vertexId";
     private static final String TEMP_STRUCT_ID_RESULT = "__IdType";
 
     private static final AtomicInteger COUNTER = new AtomicInteger();
 
-    public static String toLineageStruct(AtlasLineageInfo lineageInfo, AtlasTypeRegistry registry) throws AtlasBaseException {
-        String ret = null;
+    public static Struct toLineageStruct(AtlasLineageInfo lineageInfo, AtlasTypeRegistry registry) throws AtlasBaseException {
+        Struct ret = new Struct();
+
+        ret.setTypeName(Constants.TEMP_STRUCT_NAME_PREFIX + COUNTER.getAndIncrement());
 
         if (lineageInfo != null) {
             Map<String, AtlasEntityHeader>        entities    = lineageInfo.getGuidEntityMap();
@@ -101,11 +101,8 @@ public final class LineageUtils {
                 }
             }
 
-            Map<String, Object> map = new HashMap<>();
-            map.put(VERTICES_ATTR_NAME, verticesMap);
-            map.put(EDGES_ATTR_NAME, edgesMap);
-
-            ret = AtlasType.toV1Json(constructResultStruct(map, false));
+            ret.set("vertices", verticesMap);
+            ret.set("edges", edgesMap);
         }
 
         return ret;