NIFI-6424 Created a proper transit URL for Gremlin and OpenCypher services.

Signed-off-by: Matthew Burgess <mattyb149@apache.org>

This closes #3571
This commit is contained in:
Mike Thomsen 2019-07-03 08:06:28 -04:00 committed by Matthew Burgess
parent bfbf3b7532
commit fc3477bd69
No known key found for this signature in database
GPG Key ID: 05D3DEB8126DAD24
5 changed files with 13 additions and 3 deletions

View File

@ -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();
}
}

View File

@ -88,6 +88,6 @@ public class GremlinClientService extends AbstractTinkerpopClientService impleme
@Override
public String getTransitUrl() {
return null;
return transitUrl;
}
}

View File

@ -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

View File

@ -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

View File

@ -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\"})");