You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2019/09/03 19:07:45 UTC

[nifi] branch master updated: NIFI-6425 Made executeQuery able to reconnect to the Gremlin cluster.

This is an automated email from the ASF dual-hosted git repository.

mattyb149 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new 768a7b8  NIFI-6425 Made executeQuery able to reconnect to the Gremlin cluster.
768a7b8 is described below

commit 768a7b8c004f2ab0a4284ab29479cd917f486c1b
Author: Mike Thomsen <mi...@gmail.com>
AuthorDate: Thu Jul 4 07:50:21 2019 -0400

    NIFI-6425 Made executeQuery able to reconnect to the Gremlin cluster.
    
    Signed-off-by: Matthew Burgess <ma...@apache.org>
    
    This closes #3572
---
 .../org/apache/nifi/graph/GremlinClientService.java    | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/GremlinClientService.java b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/GremlinClientService.java
index a79094f..e001fd0 100644
--- a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/GremlinClientService.java
+++ b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/GremlinClientService.java
@@ -37,9 +37,11 @@ public class GremlinClientService extends AbstractTinkerpopClientService impleme
     private Cluster cluster;
     protected Client client;
     public static final String NOT_SUPPORTED = "NOT_SUPPORTED";
+    private ConfigurationContext context;
 
     @OnEnabled
     public void onEnabled(ConfigurationContext context) {
+        this.context = context;
         cluster = buildCluster(context);
         client = cluster.connect();
     }
@@ -52,8 +54,7 @@ public class GremlinClientService extends AbstractTinkerpopClientService impleme
         cluster = null;
     }
 
-    @Override
-    public Map<String, String> executeQuery(String query, Map<String, Object> parameters, GraphQueryResultCallback handler) {
+    public Map<String, String> doQuery(String query, Map<String, Object> parameters, GraphQueryResultCallback handler) {
         try {
             Iterator<Result> iterator = client.submit(query, parameters).iterator();
             long count = 0;
@@ -87,6 +88,19 @@ public class GremlinClientService extends AbstractTinkerpopClientService impleme
     }
 
     @Override
+    public Map<String, String> executeQuery(String query, Map<String, Object> parameters, GraphQueryResultCallback handler) {
+        try {
+            return doQuery(query, parameters, handler);
+        } catch (Exception ex) {
+            cluster.close();
+            client.close();
+            cluster = buildCluster(context);
+            client = cluster.connect();
+            return doQuery(query, parameters, handler);
+        }
+    }
+
+    @Override
     public String getTransitUrl() {
         return transitUrl;
     }