atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sar...@apache.org
Subject atlas git commit: ATLAS-2062: Add flag to disable v1 gremlin search API using atlas-application property
Date Fri, 18 Aug 2017 23:51:21 GMT
Repository: atlas
Updated Branches:
  refs/heads/0.8-incubating db317a470 -> caf89a309


ATLAS-2062: Add flag to disable v1 gremlin search API using atlas-application property


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

Branch: refs/heads/0.8-incubating
Commit: caf89a3098d3187514a8412294b0d84dec68b097
Parents: db317a4
Author: Sarath Subramanian <ssubramanian@hortonworks.com>
Authored: Fri Aug 18 16:51:16 2017 -0700
Committer: Sarath Subramanian <ssubramanian@hortonworks.com>
Committed: Fri Aug 18 16:51:16 2017 -0700

----------------------------------------------------------------------
 distro/src/conf/atlas-application.properties         |  5 +++++
 .../web/resources/MetadataDiscoveryResource.java     | 15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/caf89a30/distro/src/conf/atlas-application.properties
----------------------------------------------------------------------
diff --git a/distro/src/conf/atlas-application.properties b/distro/src/conf/atlas-application.properties
index 29a4cc1..585a579 100755
--- a/distro/src/conf/atlas-application.properties
+++ b/distro/src/conf/atlas-application.properties
@@ -252,6 +252,11 @@ atlas.metric.query.cache.ttlInSecs=900
 #Set to false to disable full text search.
 #atlas.search.fulltext.enable=true
 
+#########  Gremlin Search Configuration  #########
+
+#Set to false to disable gremlin search.
+atlas.search.gremlin.enable=false
+
 
 ########## Add http headers ###########
 

http://git-wip-us.apache.org/repos/asf/atlas/blob/caf89a30/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
index d29c8da..d7c66d3 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
@@ -28,6 +28,7 @@ import org.apache.atlas.query.QueryParams;
 import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.atlas.utils.ParamChecker;
 import org.apache.atlas.web.util.Servlets;
+import org.apache.commons.configuration.Configuration;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
@@ -66,6 +67,10 @@ public class MetadataDiscoveryResource {
 
     private final DiscoveryService discoveryService;
 
+    private final  boolean       gremlinSearchEnabled;
+    private static Configuration applicationProperties          = null;
+    private static final String  ENABLE_GREMLIN_SEARCH_PROPERTY = "atlas.search.gremlin.enable";
+
     /**
      * Created by the Guice ServletModule and injected with the
      * configured DiscoveryService.
@@ -73,8 +78,10 @@ public class MetadataDiscoveryResource {
      * @param discoveryService metadata service handle
      */
     @Inject
-    public MetadataDiscoveryResource(DiscoveryService discoveryService) {
-        this.discoveryService = discoveryService;
+    public MetadataDiscoveryResource(DiscoveryService discoveryService, Configuration configuration)
{
+        this.discoveryService  = discoveryService;
+        applicationProperties  = configuration;
+        gremlinSearchEnabled   = applicationProperties != null && applicationProperties.getBoolean(ENABLE_GREMLIN_SEARCH_PROPERTY,
false);
     }
 
     /**
@@ -212,6 +219,10 @@ public class MetadataDiscoveryResource {
                 perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "MetadataDiscoveryResource.searchUsingGremlinQuery("
+ gremlinQuery + ")");
             }
 
+            if (!gremlinSearchEnabled) {
+                throw new DiscoveryException("Gremlin search is not enabled.");
+            }
+
             gremlinQuery = ParamChecker.notEmpty(gremlinQuery, "gremlinQuery cannot be null
or empty");
             final List<Map<String, String>> results = discoveryService.searchByGremlin(gremlinQuery);
 


Mime
View raw message