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 fc3477b  NIFI-6424 Created a proper transit URL for Gremlin and 
OpenCypher services.
fc3477b is described below

commit fc3477bd69be066ba7f75b90f9e58e18ee3b176c
Author: Mike Thomsen <[email protected]>
AuthorDate: Wed Jul 3 08:06:28 2019 -0400

    NIFI-6424 Created a proper transit URL for Gremlin and OpenCypher services.
    
    Signed-off-by: Matthew Burgess <[email protected]>
    
    This closes #3571
---
 .../java/org/apache/nifi/graph/AbstractTinkerpopClientService.java | 7 +++++++
 .../src/main/java/org/apache/nifi/graph/GremlinClientService.java  | 2 +-
 .../main/java/org/apache/nifi/graph/OpenCypherClientService.java   | 2 --
 .../test/java/org/apache/nifi/graph/GremlinClientServiceIT.java    | 2 ++
 .../test/java/org/apache/nifi/graph/OpenCypherClientServiceIT.java | 3 +++
 5 files changed, 13 insertions(+), 3 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/AbstractTinkerpopClientService.java
 
b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/AbstractTinkerpopClientService.java
index 4bf7bec..929e6df 100644
--- 
a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/AbstractTinkerpopClientService.java
+++ 
b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/AbstractTinkerpopClientService.java
@@ -85,11 +85,15 @@ public abstract class AbstractTinkerpopClientService 
extends AbstractControllerS
                     .keyStoreType(service.getKeyStoreType())
                     .trustStore(service.getTrustStoreFile())
                     .trustStorePassword(service.getTrustStorePassword());
+            usesSSL = true;
         }
 
         return builder;
     }
 
+    boolean usesSSL;
+    protected String transitUrl;
+
     protected Cluster buildCluster(ConfigurationContext context) {
         String contactProp = 
context.getProperty(CONTACT_POINTS).evaluateAttributeExpressions().getValue();
         int port = 
context.getProperty(PORT).evaluateAttributeExpressions().asInteger();
@@ -104,6 +108,9 @@ public abstract class AbstractTinkerpopClientService 
extends AbstractControllerS
 
         builder = setupSSL(context, builder);
 
+        transitUrl = String.format("gremlin%s://%s:%s%s", usesSSL ? "+ssl" : 
"",
+                contactProp, port, path);
+
         return builder.create();
     }
 }
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 4b51623..a79094f 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
@@ -88,6 +88,6 @@ public class GremlinClientService extends 
AbstractTinkerpopClientService impleme
 
     @Override
     public String getTransitUrl() {
-        return null;
+        return transitUrl;
     }
 }
diff --git 
a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/OpenCypherClientService.java
 
b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/OpenCypherClientService.java
index 4fb4699..47e44ee 100644
--- 
a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/OpenCypherClientService.java
+++ 
b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/OpenCypherClientService.java
@@ -40,14 +40,12 @@ import java.util.Map;
 @Tags({ "cypher", "opencypher", "graph", "database", "janus" })
 public class OpenCypherClientService extends AbstractTinkerpopClientService 
implements GraphClientService {
     private volatile Driver gremlinDriver;
-    private volatile String transitUrl;
 
     @OnEnabled
     public void onEnabled(ConfigurationContext context) {
         Cluster cluster = buildCluster(context);
 
         gremlinDriver = GremlinDatabase.driver(cluster);
-        transitUrl = String.format("gremlin://%s", 
context.getProperty(CONTACT_POINTS).getValue());
     }
 
     @OnDisabled
diff --git 
a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/GremlinClientServiceIT.java
 
b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/GremlinClientServiceIT.java
index ee8dc60..bdec0bd 100644
--- 
a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/GremlinClientServiceIT.java
+++ 
b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/GremlinClientServiceIT.java
@@ -48,6 +48,8 @@ public class GremlinClientServiceIT {
 
         String setup = 
IOUtils.toString(getClass().getResourceAsStream("/setup.gremlin"), "UTF-8");
         clientService.getClient().submit(setup);
+
+        Assert.assertEquals("gremlin://localhost:8182/gremlin", 
clientService.getTransitUrl());
     }
 
     @After
diff --git 
a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/OpenCypherClientServiceIT.java
 
b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/OpenCypherClientServiceIT.java
index b4b3faa..340b81a 100644
--- 
a/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/OpenCypherClientServiceIT.java
+++ 
b/nifi-nar-bundles/nifi-graph-bundle/nifi-other-graph-services/src/test/java/org/apache/nifi/graph/OpenCypherClientServiceIT.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.neo4j.driver.v1.Driver;
@@ -63,6 +64,8 @@ public class OpenCypherClientServiceIT {
         runner.enableControllerService(service);
         runner.assertValid();
 
+        Assert.assertEquals("gremlin://localhost:8182/gremlin", 
service.getTransitUrl());
+
         driver = GremlinDatabase.driver("//localhost:8182");
         executeSession("MATCH (n) detach delete n");
         executeSession("CREATE (rover:dog { name: \"Rover\"})");

Reply via email to