You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/03/17 21:23:56 UTC
[39/50] incubator-tinkerpop git commit: Pulled out embedded strings
to tokens and did some renaming of config options.
Pulled out embedded strings to tokens and did some renaming of config options.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/e20b90a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/e20b90a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/e20b90a1
Branch: refs/heads/TINKERPOP-575
Commit: e20b90a17e565cd3921b0ef6e361e138c80b6b93
Parents: d08a24c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Mar 17 08:23:25 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Mar 17 14:07:26 2016 -0400
----------------------------------------------------------------------
.../gremlin/process/remote/RemoteGraph.java | 11 +++++------
.../driver/remote/DriverRemoteConnection.java | 19 ++++++++++++-------
.../driver/remote/RemoteGraphProvider.java | 6 +++---
3 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e20b90a1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
index 8df85df..86b9940 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
@@ -32,7 +32,6 @@ import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
import java.lang.reflect.Constructor;
import java.util.Collections;
import java.util.Iterator;
-import java.util.Optional;
/**
* A {@code ServerGraph} represents a proxy by which traversals spawned from this graph are expected over a
@@ -83,7 +82,7 @@ public class RemoteGraph implements Graph {
private final RemoteConnection connection;
- public static final String GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS = "gremlin.servergraph.serverConnectionClass";
+ public static final String GREMLIN_REMOTEGRAPH_REMOTE_CONNECTION_CLASS = "gremlin.remotegraph.remoteConnectionClass";
private RemoteGraph(final RemoteConnection connection) {
this.connection = connection;
@@ -93,18 +92,18 @@ public class RemoteGraph implements Graph {
/**
* Creates a new {@link RemoteGraph} instance using the specified configuration, which allows {@link RemoteGraph}
- * to be compliant with {@link GraphFactory}. Expects key for {@link #GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS}
+ * to be compliant with {@link GraphFactory}. Expects key for {@link #GREMLIN_REMOTEGRAPH_REMOTE_CONNECTION_CLASS}
* as well as any configuration required by the underlying {@link RemoteConnection} which will be instantiated.
* Note that the {@code Configuration} object is passed down without change to the creation of the
* {@link RemoteConnection} instance.
*/
public static RemoteGraph open(final Configuration conf) {
- if (!conf.containsKey(GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS))
- throw new IllegalArgumentException("Configuration must contain the '" + GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS +"' key");
+ if (!conf.containsKey(GREMLIN_REMOTEGRAPH_REMOTE_CONNECTION_CLASS))
+ throw new IllegalArgumentException("Configuration must contain the '" + GREMLIN_REMOTEGRAPH_REMOTE_CONNECTION_CLASS +"' key");
final RemoteConnection remoteConnection;
try {
- final Class<? extends RemoteConnection> clazz = Class.forName(conf.getString(GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS)).asSubclass(RemoteConnection.class);
+ final Class<? extends RemoteConnection> clazz = Class.forName(conf.getString(GREMLIN_REMOTEGRAPH_REMOTE_CONNECTION_CLASS)).asSubclass(RemoteConnection.class);
final Constructor<? extends RemoteConnection> ctor = clazz.getConstructor(Configuration.class);
remoteConnection = ctor.newInstance(conf);
} catch (Exception ex) {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e20b90a1/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
index b8724eb..46ca03c 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
@@ -44,25 +44,30 @@ import java.util.function.Supplier;
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public class DriverRemoteConnection implements RemoteConnection {
+
+ public static final String GREMLIN_REMOTEGRAPH_DRIVER_CLUSTERFILE = "gremlin.remotegraph.driver.clusterFile";
+ public static final String GREMLIN_REMOTEGRAPH_DRIVER_GRAPHNAME = "gremlin.remotegraph.driver.graphName";
+ private static final String DEFAULT_GRAPH = "graph";
private static final boolean attachElements = Boolean.valueOf(System.getProperty("is.testing", "false"));
+
private final Client client;
private final boolean tryCloseCluster;
private final String connectionGraphName;
private transient Optional<Configuration> conf = Optional.empty();
public DriverRemoteConnection(final Configuration conf) {
- if (conf.containsKey("clusterConfigurationFile") && conf.containsKey("clusterConfiguration"))
- throw new IllegalStateException("A configuration should not contain both 'clusterConfigurationFile' and 'clusterConfiguration'");
+ if (conf.containsKey(GREMLIN_REMOTEGRAPH_DRIVER_CLUSTERFILE) && conf.containsKey("clusterConfiguration"))
+ throw new IllegalStateException(String.format("A configuration should not contain both '%s' and 'clusterConfiguration'", GREMLIN_REMOTEGRAPH_DRIVER_CLUSTERFILE));
- connectionGraphName = conf.getString("connectionGraphName", "graph");
+ connectionGraphName = conf.getString(GREMLIN_REMOTEGRAPH_DRIVER_GRAPHNAME, DEFAULT_GRAPH);
try {
final Cluster cluster;
- if (!conf.containsKey("clusterConfigurationFile") && !conf.containsKey("clusterConfiguration"))
+ if (!conf.containsKey(GREMLIN_REMOTEGRAPH_DRIVER_CLUSTERFILE) && !conf.containsKey("clusterConfiguration"))
cluster = Cluster.open();
else
- cluster = conf.containsKey("clusterConfigurationFile") ?
- Cluster.open(conf.getString("clusterConfigurationFile")) : Cluster.open(conf.subset("clusterConfiguration"));
+ cluster = conf.containsKey(GREMLIN_REMOTEGRAPH_DRIVER_CLUSTERFILE) ?
+ Cluster.open(conf.getString(GREMLIN_REMOTEGRAPH_DRIVER_CLUSTERFILE)) : Cluster.open(conf.subset("clusterConfiguration"));
client = cluster.connect(Client.Settings.build().unrollTraversers(false).create()).alias(connectionGraphName);
} catch (Exception ex) {
@@ -83,7 +88,7 @@ public class DriverRemoteConnection implements RemoteConnection {
* This constructor is largely just for unit testing purposes and should not typically be used externally.
*/
DriverRemoteConnection(final Cluster cluster, final Configuration conf) {
- connectionGraphName = conf.getString("connectionGraphName", "graph");
+ connectionGraphName = conf.getString(GREMLIN_REMOTEGRAPH_DRIVER_GRAPHNAME, DEFAULT_GRAPH);
client = cluster.connect(Client.Settings.build().unrollTraversers(false).create()).alias(connectionGraphName);
tryCloseCluster = false;
this.conf = Optional.of(conf);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e20b90a1/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
index 848c510..6366bbb 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
@@ -59,7 +59,7 @@ public class RemoteGraphProvider extends AbstractGraphProvider {
@Override
public Graph openTestGraph(final Configuration config) {
- final String serverGraphName = config.getString("connectionGraphName");
+ final String serverGraphName = config.getString(DriverRemoteConnection.GREMLIN_REMOTEGRAPH_DRIVER_GRAPHNAME);
return remoteCache.computeIfAbsent(serverGraphName,
k -> RemoteGraph.open(new DriverRemoteConnection(cluster, config)));
}
@@ -72,8 +72,8 @@ public class RemoteGraphProvider extends AbstractGraphProvider {
final Supplier<Graph> graphGetter = () -> server.getServerGremlinExecutor().getGraphManager().getGraphs().get(serverGraphName);
return new HashMap<String, Object>() {{
put(Graph.GRAPH, RemoteGraph.class.getName());
- put(RemoteGraph.GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS, DriverRemoteConnection.class.getName());
- put("connectionGraphName", serverGraphName);
+ put(RemoteGraph.GREMLIN_REMOTEGRAPH_REMOTE_CONNECTION_CLASS, DriverRemoteConnection.class.getName());
+ put(DriverRemoteConnection.GREMLIN_REMOTEGRAPH_DRIVER_GRAPHNAME, serverGraphName);
put("hidden.for.testing.only", graphGetter);
}};
}