tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [31/50] incubator-tinkerpop git commit: Pulled out embedded strings to tokens and did some renaming of config options.
Date Fri, 18 Mar 2016 13:31:19 GMT
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/10a74122
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/10a74122
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/10a74122

Branch: refs/heads/master
Commit: 10a74122131b8361a16dc7d2341c5eb0942e8a00
Parents: b2a8106
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Thu Mar 17 08:23:25 2016 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Thu Mar 17 17:01:35 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/10a74122/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/10a74122/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/10a74122/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);
         }};
     }


Mime
View raw message