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:26 UTC
[09/50] incubator-tinkerpop git commit: Renamed "server" classes to
"remote".
Renamed "server" classes to "remote".
"Remote" is a better way to describe this feature as the traversal does not need to be necessarily submitted to a "server" for processing.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/a10d9f1d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/a10d9f1d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/a10d9f1d
Branch: refs/heads/TINKERPOP-575
Commit: a10d9f1df836fedd4159e88ff54839739d3848a4
Parents: d6e2fb1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Mar 11 09:18:22 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Mar 17 14:05:19 2016 -0400
----------------------------------------------------------------------
.../process/remote/RemoteConnection.java | 34 ++++
.../remote/RemoteConnectionException.java | 41 +++++
.../gremlin/process/remote/RemoteGraph.java | 164 +++++++++++++++++
.../process/remote/ServerConnection.java | 34 ----
.../remote/ServerConnectionException.java | 41 -----
.../gremlin/process/remote/ServerGraph.java | 164 -----------------
.../remote/traversal/step/map/RemoteStep.java | 87 +++++++++
.../traversal/step/map/ServerResultStep.java | 87 ---------
.../traversal/strategy/RemoteStrategy.java | 82 +++++++++
.../traversal/strategy/ServerStrategy.java | 82 ---------
.../driver/remote/DriverRemoteConnection.java | 180 +++++++++++++++++++
.../driver/remote/DriverServerConnection.java | 180 -------------------
.../server/WithServerIntegrationTest.java | 6 +-
13 files changed, 591 insertions(+), 591 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
new file mode 100644
index 0000000..a47ace2
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnection.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.remote;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+
+import java.util.Iterator;
+
+/**
+ * A simple abstraction of a "connection" to a "server" that is capable of processing a {@link Traversal} and
+ * returning an {@link Iterator} of {@link Traverser} results.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface RemoteConnection extends AutoCloseable {
+ public Iterator<Traverser> submit(final Traversal t) throws RemoteConnectionException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnectionException.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnectionException.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnectionException.java
new file mode 100644
index 0000000..3ea9698
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteConnectionException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.remote;
+
+/**
+ * A generalized exception for any errors related to {@link RemoteConnection}.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class RemoteConnectionException extends Exception {
+ public RemoteConnectionException() {
+ }
+
+ public RemoteConnectionException(String message) {
+ super(message);
+ }
+
+ public RemoteConnectionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public RemoteConnectionException(Throwable cause) {
+ super(cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/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
new file mode 100644
index 0000000..d6e0827
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.remote;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
+import org.apache.tinkerpop.gremlin.process.remote.traversal.strategy.RemoteStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Transaction;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
+import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
+
+import java.lang.reflect.Constructor;
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ * A {@code ServerGraph} represents a proxy by which traversals spawned from this graph are expected over a
+ * {@link RemoteConnection}. This is not a full {@link Graph} implementation in the sense that the most of the methods
+ * will throw an {@link UnsupportedOperationException}. This implementation can only be used for spawning remote
+ * traversal instances.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class RemoteGraph implements Graph {
+
+ private final RemoteConnection connection;
+ private final Class<? extends Graph> graphClass;
+
+ public static final String GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS = "gremlin.servergraph.serverConnectionClass";
+ public static final String GREMLIN_SERVERGRAPH_GRAPH_CLASS = "gremlin.servergraph.graphClass";
+
+ private RemoteGraph(final RemoteConnection connection, final Class<? extends Graph> graphClass) {
+ this.connection = connection;
+ this.graphClass = graphClass;TraversalStrategies.GlobalCache.registerStrategies(
+ RemoteGraph.class, TraversalStrategies.GlobalCache.getStrategies(EmptyGraph.class).clone().addStrategies(RemoteStrategy.instance()));
+ }
+
+ /**
+ * Creates a new {@link RemoteGraph} instance using the specified configuration, which allows {@link RemoteGraph}
+ * to be compliant with {@link GraphFactory}. Expects keys for the {@link #GREMLIN_SERVERGRAPH_GRAPH_CLASS} and
+ * {@link #GREMLIN_SERVERGRAPH_SERVER_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_GRAPH_CLASS))
+ throw new IllegalArgumentException("Configuration must contain the '" + GREMLIN_SERVERGRAPH_GRAPH_CLASS +"' key");
+
+ if (!conf.containsKey(GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS))
+ throw new IllegalArgumentException("Configuration must contain the '" + GREMLIN_SERVERGRAPH_SERVER_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 Constructor<? extends RemoteConnection> ctor = clazz.getConstructor(Configuration.class);
+ remoteConnection = ctor.newInstance(conf);
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+
+ final Class<? extends Graph> graphClazz;
+ try {
+ graphClazz = Class.forName(conf.getString(GREMLIN_SERVERGRAPH_GRAPH_CLASS)).asSubclass(Graph.class);
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+
+ return new RemoteGraph(remoteConnection, graphClazz);
+ }
+
+ /**
+ * Creates a new {@link RemoteGraph} instance. {@link RemoteGraph} will attempt to call the
+ * {@link RemoteConnection#close()} method when the {@link #close()} method is called on this class.
+ *
+ * @param connection the {@link RemoteConnection} instance to use
+ * @param graphClass the {@link Graph} class expected to be executed on the other side of the
+ * {@link RemoteConnection}
+ */
+ public static RemoteGraph open(final RemoteConnection connection, final Class<? extends Graph> graphClass) {
+ return new RemoteGraph(connection, graphClass);
+ }
+
+ public RemoteConnection getConnection() {
+ return connection;
+ }
+
+ public Class<? extends Graph> getGraphClass() {
+ return graphClass;
+ }
+
+ /**
+ * Closes the underlying {@link RemoteConnection}.
+ */
+ @Override
+ public void close() throws Exception {
+ connection.close();
+ }
+
+ @Override
+ public Vertex addVertex(final Object... keyValues) {
+ throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
+ }
+
+ @Override
+ public <C extends GraphComputer> C compute(final Class<C> graphComputerClass) throws IllegalArgumentException {
+ throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
+ }
+
+ @Override
+ public GraphComputer compute() throws IllegalArgumentException {
+ throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
+ }
+
+ /**
+ * This method returns an empty {@link Iterator} - it is not meant to be called directly.
+ */
+ @Override
+ public Iterator<Vertex> vertices(final Object... vertexIds) {
+ return Collections.emptyIterator();
+ }
+
+ /**
+ * This method returns an empty {@link Iterator} - it is not meant to be called directly.
+ */
+ @Override
+ public Iterator<Edge> edges(final Object... edgeIds) {
+ return Collections.emptyIterator();
+ }
+
+ @Override
+ public Transaction tx() {
+ throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
+ }
+
+ @Override
+ public Variables variables() {
+ throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
+ }
+
+ @Override
+ public Configuration configuration() {
+ throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerConnection.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerConnection.java
deleted file mode 100644
index 5b63f0e..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerConnection.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.remote;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-
-import java.util.Iterator;
-
-/**
- * A simple abstraction of a "connection" to a "server" that is capable of processing a {@link Traversal} and
- * returning an {@link Iterator} of {@link Traverser} results.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public interface ServerConnection extends AutoCloseable {
- public Iterator<Traverser> submit(final Traversal t) throws ServerConnectionException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerConnectionException.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerConnectionException.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerConnectionException.java
deleted file mode 100644
index d9a8f40..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerConnectionException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.remote;
-
-/**
- * A generalized exception for any errors related to {@link ServerConnection}.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class ServerConnectionException extends Exception {
- public ServerConnectionException() {
- }
-
- public ServerConnectionException(String message) {
- super(message);
- }
-
- public ServerConnectionException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ServerConnectionException(Throwable cause) {
- super(cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerGraph.java
deleted file mode 100644
index 3cde26e..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/ServerGraph.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.remote;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
-import org.apache.tinkerpop.gremlin.process.remote.traversal.strategy.ServerStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Transaction;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
-import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph;
-
-import java.lang.reflect.Constructor;
-import java.util.Collections;
-import java.util.Iterator;
-
-/**
- * A {@code ServerGraph} represents a proxy by which traversals spawned from this graph are expected over a
- * {@link ServerConnection}. This is not a full {@link Graph} implementation in the sense that the most of the methods
- * will throw an {@link UnsupportedOperationException}. This implementation can only be used for spawning remote
- * traversal instances.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class ServerGraph implements Graph {
-
- private final ServerConnection connection;
- private final Class<? extends Graph> graphClass;
-
- public static final String GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS = "gremlin.servergraph.serverConnectionClass";
- public static final String GREMLIN_SERVERGRAPH_GRAPH_CLASS = "gremlin.servergraph.graphClass";
-
- private ServerGraph(final ServerConnection connection, final Class<? extends Graph> graphClass) {
- this.connection = connection;
- this.graphClass = graphClass;TraversalStrategies.GlobalCache.registerStrategies(
- ServerGraph.class, TraversalStrategies.GlobalCache.getStrategies(EmptyGraph.class).clone().addStrategies(ServerStrategy.instance()));
- }
-
- /**
- * Creates a new {@link ServerGraph} instance using the specified configuration, which allows {@link ServerGraph}
- * to be compliant with {@link GraphFactory}. Expects keys for the {@link #GREMLIN_SERVERGRAPH_GRAPH_CLASS} and
- * {@link #GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS} as well as any configuration required by the underlying
- * {@link ServerConnection} which will be instantiated. Note that the {@code Configuration} object is passed down
- * without change to the creation of the {@link ServerConnection} instance.
- */
- public static ServerGraph open(final Configuration conf) {
- if (!conf.containsKey(GREMLIN_SERVERGRAPH_GRAPH_CLASS))
- throw new IllegalArgumentException("Configuration must contain the '" + GREMLIN_SERVERGRAPH_GRAPH_CLASS +"' key");
-
- if (!conf.containsKey(GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS))
- throw new IllegalArgumentException("Configuration must contain the '" + GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS +"' key");
-
- final ServerConnection serverConnection;
- try {
- final Class<? extends ServerConnection> clazz = Class.forName(conf.getString(GREMLIN_SERVERGRAPH_SERVER_CONNECTION_CLASS)).asSubclass(ServerConnection.class);
- final Constructor<? extends ServerConnection> ctor = clazz.getConstructor(Configuration.class);
- serverConnection = ctor.newInstance(conf);
- } catch (Exception ex) {
- throw new IllegalStateException(ex);
- }
-
- final Class<? extends Graph> graphClazz;
- try {
- graphClazz = Class.forName(conf.getString(GREMLIN_SERVERGRAPH_GRAPH_CLASS)).asSubclass(Graph.class);
- } catch (Exception ex) {
- throw new IllegalStateException(ex);
- }
-
- return new ServerGraph(serverConnection, graphClazz);
- }
-
- /**
- * Creates a new {@link ServerGraph} instance. {@link ServerGraph} will attempt to call the
- * {@link ServerConnection#close()} method when the {@link #close()} method is called on this class.
- *
- * @param connection the {@link ServerConnection} instance to use
- * @param graphClass the {@link Graph} class expected to be executed on the other side of the
- * {@link ServerConnection}
- */
- public static ServerGraph open(final ServerConnection connection, final Class<? extends Graph> graphClass) {
- return new ServerGraph(connection, graphClass);
- }
-
- public ServerConnection getConnection() {
- return connection;
- }
-
- public Class<? extends Graph> getGraphClass() {
- return graphClass;
- }
-
- /**
- * Closes the underlying {@link ServerConnection}.
- */
- @Override
- public void close() throws Exception {
- connection.close();
- }
-
- @Override
- public Vertex addVertex(final Object... keyValues) {
- throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
- }
-
- @Override
- public <C extends GraphComputer> C compute(final Class<C> graphComputerClass) throws IllegalArgumentException {
- throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
- }
-
- @Override
- public GraphComputer compute() throws IllegalArgumentException {
- throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
- }
-
- /**
- * This method returns an empty {@link Iterator} - it is not meant to be called directly.
- */
- @Override
- public Iterator<Vertex> vertices(final Object... vertexIds) {
- return Collections.emptyIterator();
- }
-
- /**
- * This method returns an empty {@link Iterator} - it is not meant to be called directly.
- */
- @Override
- public Iterator<Edge> edges(final Object... edgeIds) {
- return Collections.emptyIterator();
- }
-
- @Override
- public Transaction tx() {
- throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
- }
-
- @Override
- public Variables variables() {
- throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
- }
-
- @Override
- public Configuration configuration() {
- throw new UnsupportedOperationException(String.format("ServerGraph is a proxy to %s - this method is not supported", connection));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
new file mode 100644
index 0000000..d8e1792
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/RemoteStep.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.remote.traversal.step.map;
+
+import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteConnectionException;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
+import org.apache.tinkerpop.gremlin.process.traversal.util.PureTraversal;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+/**
+ * Sends a {@link Traversal} to a {@link RemoteConnection} and iterates back the results.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class RemoteStep<S,E> extends AbstractStep<S, E> implements TraversalParent {
+ private transient RemoteConnection remoteConnection;
+ private PureTraversal pureTraversal;
+ private Iterator<Traverser> currentIterator;
+
+ public RemoteStep(final Traversal.Admin<S,E> traversal, final Traversal traversalToRemote,
+ final RemoteConnection remoteConnection) {
+ super(traversal);
+ this.remoteConnection = remoteConnection;
+ pureTraversal = new PureTraversal<>(traversalToRemote.asAdmin());
+ this.integrateChild(pureTraversal.get());
+ }
+
+ @Override
+ public List<Traversal.Admin<S, E>> getGlobalChildren() {
+ return Collections.singletonList(pureTraversal.get());
+ }
+
+ @Override
+ public String toString() {
+ return StringFactory.stepString(this, pureTraversal.get());
+ }
+
+ @Override
+ public void setTraversal(final Traversal.Admin<?, ?> parentTraversal) {
+ super.setTraversal(parentTraversal);
+ this.integrateChild(pureTraversal.get());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Traverser processNextStart() throws NoSuchElementException {
+
+ if (null == currentIterator) {
+ try {
+ final Traversal.Admin temp = pureTraversal.getPure();
+ temp.setStrategies(TraversalStrategies.GlobalCache.getStrategies(((RemoteGraph) traversal.getGraph().get()).getGraphClass()));
+ currentIterator = remoteConnection.submit(temp);
+ } catch (RemoteConnectionException sce) {
+ throw new IllegalStateException(sce);
+ }
+ }
+
+ return this.currentIterator.next();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/ServerResultStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/ServerResultStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/ServerResultStep.java
deleted file mode 100644
index fdb10f6..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/step/map/ServerResultStep.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.remote.traversal.step.map;
-
-import org.apache.tinkerpop.gremlin.process.remote.ServerConnection;
-import org.apache.tinkerpop.gremlin.process.remote.ServerConnectionException;
-import org.apache.tinkerpop.gremlin.process.remote.ServerGraph;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep;
-import org.apache.tinkerpop.gremlin.process.traversal.util.PureTraversal;
-import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- * Sends a {@link Traversal} to a {@link ServerConnection} and iterates back the results.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class ServerResultStep<S,E> extends AbstractStep<S, E> implements TraversalParent {
- private transient ServerConnection serverConnection;
- private PureTraversal pureTraversal;
- private Iterator<Traverser> currentIterator;
-
- public ServerResultStep(final Traversal.Admin<S,E> traversal, final Traversal traversalToRemote,
- final ServerConnection serverConnection) {
- super(traversal);
- this.serverConnection = serverConnection;
- pureTraversal = new PureTraversal<>(traversalToRemote.asAdmin());
- this.integrateChild(pureTraversal.get());
- }
-
- @Override
- public List<Traversal.Admin<S, E>> getGlobalChildren() {
- return Collections.singletonList(pureTraversal.get());
- }
-
- @Override
- public String toString() {
- return StringFactory.stepString(this, pureTraversal.get());
- }
-
- @Override
- public void setTraversal(final Traversal.Admin<?, ?> parentTraversal) {
- super.setTraversal(parentTraversal);
- this.integrateChild(pureTraversal.get());
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected Traverser processNextStart() throws NoSuchElementException {
-
- if (null == currentIterator) {
- try {
- final Traversal.Admin temp = pureTraversal.getPure();
- temp.setStrategies(TraversalStrategies.GlobalCache.getStrategies(((ServerGraph) traversal.getGraph().get()).getGraphClass()));
- currentIterator = serverConnection.submit(temp);
- } catch (ServerConnectionException sce) {
- throw new IllegalStateException(sce);
- }
- }
-
- return this.currentIterator.next();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/RemoteStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/RemoteStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/RemoteStrategy.java
new file mode 100644
index 0000000..297f62f
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/RemoteStrategy.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.remote.traversal.strategy;
+
+import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
+import org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.VertexProgramStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * Reconstructs a {@link Traversal} by appending a {@link RemoteStep} to its end. That step will submit the
+ * {@link Traversal} to a {@link RemoteConnection} instance which will typically send it to a remote server for
+ * execution and return results.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class RemoteStrategy extends AbstractTraversalStrategy<TraversalStrategy.DecorationStrategy>
+ implements TraversalStrategy.DecorationStrategy {
+
+ private static final RemoteStrategy INSTANCE = new RemoteStrategy();
+
+ private RemoteStrategy() {}
+
+ public static RemoteStrategy instance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public Set<Class<? extends DecorationStrategy>> applyPost() {
+ return Collections.singleton(VertexProgramStrategy.class);
+ }
+
+ @Override
+ public void apply(final Traversal.Admin<?, ?> traversal) {
+ if (!(traversal.getParent() instanceof EmptyStep))
+ return;
+
+ if (!traversal.getGraph().isPresent())
+ throw new IllegalStateException("ServerStrategy expects a ServerGraph instance attached to the Traversal");
+
+ if (!(traversal.getGraph().get() instanceof RemoteGraph))
+ throw new IllegalStateException("ServerStrategy expects a ServerGraph instance attached to the Traversal");
+
+ final RemoteGraph remoteGraph = (RemoteGraph) traversal.getGraph().get();
+ if (null == remoteGraph.getConnection())
+ throw new IllegalStateException("ServerStrategy expects ServerGraph instance to have a ServerConnection");
+
+ final Traversal.Admin<?, ?> serverTraversal = new DefaultTraversal<>();
+ TraversalHelper.removeToTraversal(traversal.getStartStep(), EmptyStep.instance(), (Traversal.Admin) serverTraversal);
+ final RemoteStep serverStep = new RemoteStep(traversal, serverTraversal, remoteGraph.getConnection());
+ traversal.addStep(serverStep);
+
+ assert traversal.getStartStep().equals(serverStep);
+ assert traversal.getSteps().size() == 1;
+ assert traversal.getEndStep() == serverStep;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/ServerStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/ServerStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/ServerStrategy.java
deleted file mode 100644
index 051bb93..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/traversal/strategy/ServerStrategy.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.remote.traversal.strategy;
-
-import org.apache.tinkerpop.gremlin.process.remote.ServerConnection;
-import org.apache.tinkerpop.gremlin.process.remote.ServerGraph;
-import org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.ServerResultStep;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.VertexProgramStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * Reconstructs a {@link Traversal} by appending a {@link ServerResultStep} to its end. That step will submit the
- * {@link Traversal} to a {@link ServerConnection} instance which will typically send it to a remote server for
- * execution and return results.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class ServerStrategy extends AbstractTraversalStrategy<TraversalStrategy.DecorationStrategy>
- implements TraversalStrategy.DecorationStrategy {
-
- private static final ServerStrategy INSTANCE = new ServerStrategy();
-
- private ServerStrategy() {}
-
- public static ServerStrategy instance() {
- return INSTANCE;
- }
-
- @Override
- public Set<Class<? extends DecorationStrategy>> applyPost() {
- return Collections.singleton(VertexProgramStrategy.class);
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal) {
- if (!(traversal.getParent() instanceof EmptyStep))
- return;
-
- if (!traversal.getGraph().isPresent())
- throw new IllegalStateException("ServerStrategy expects a ServerGraph instance attached to the Traversal");
-
- if (!(traversal.getGraph().get() instanceof ServerGraph))
- throw new IllegalStateException("ServerStrategy expects a ServerGraph instance attached to the Traversal");
-
- final ServerGraph serverGraph = (ServerGraph) traversal.getGraph().get();
- if (null == serverGraph.getConnection())
- throw new IllegalStateException("ServerStrategy expects ServerGraph instance to have a ServerConnection");
-
- final Traversal.Admin<?, ?> serverTraversal = new DefaultTraversal<>();
- TraversalHelper.removeToTraversal(traversal.getStartStep(), EmptyStep.instance(), (Traversal.Admin) serverTraversal);
- final ServerResultStep serverStep = new ServerResultStep(traversal, serverTraversal, serverGraph.getConnection());
- traversal.addStep(serverStep);
-
- assert traversal.getStartStep().equals(serverStep);
- assert traversal.getSteps().size() == 1;
- assert traversal.getEndStep() == serverStep;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/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
new file mode 100644
index 0000000..b707a29
--- /dev/null
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteConnection.java
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.driver.remote;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.driver.Client;
+import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.apache.tinkerpop.gremlin.driver.Result;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteConnectionException;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
+
+import java.util.Iterator;
+
+/**
+ * A {@link RemoteConnection} implementation for Gremlin Server. Each {@code DriverServerConnection} is bound to one
+ * graph instance hosted in Gremlin Server.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class DriverRemoteConnection implements RemoteConnection {
+
+ private final Client client;
+ private final boolean tryCloseCluster;
+ private final String connectionGraphName;
+
+ 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("clusterConfigurationFile") && !conf.containsKey("clusterConfiguration"))
+ throw new IllegalStateException("A configuration must contain either 'clusterConfigurationFile' and 'clusterConfiguration'");
+
+ connectionGraphName = conf.getString("connectionGraphName", "graph");
+
+ try {
+ final Cluster cluster = conf.containsKey("clusterConfigurationFile") ?
+ Cluster.open(conf.getString("clusterConfigurationFile")) : Cluster.open(conf.subset("clusterConfiguration"));
+ client = cluster.connect(Client.Settings.build().unrollTraversers(false).create()).alias(connectionGraphName);
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+
+ tryCloseCluster = true;
+ }
+
+ private DriverRemoteConnection(final Cluster cluster, final boolean tryCloseCluster, final String connectionGraphName){
+ client = cluster.connect(Client.Settings.build().unrollTraversers(false).create()).alias(connectionGraphName);
+ this.connectionGraphName = connectionGraphName;
+ this.tryCloseCluster = tryCloseCluster;
+ }
+
+ /**
+ * Creates a {@link DriverRemoteConnection} from an existing {@link Cluster} instance. When {@link #close()} is
+ * called, the {@link Cluster} is left open for the caller to close. By default, this method will bind the
+ * {@link RemoteConnection} to a graph on the server named "graph".
+ */
+ public static DriverRemoteConnection using(final Cluster cluster) {
+ return using(cluster, "graph");
+ }
+
+ /**
+ * Creates a {@link DriverRemoteConnection} from an existing {@link Cluster} instance. When {@link #close()} is
+ * called, the {@link Cluster} is left open for the caller to close.
+ */
+ public static DriverRemoteConnection using(final Cluster cluster, final String connectionGraphName) {
+ return new DriverRemoteConnection(cluster, false, connectionGraphName);
+ }
+
+ /**
+ * Creates a {@link DriverRemoteConnection} using a new {@link Cluster} instance created from the supplied
+ * configuration file. When {@link #close()} is called, this new {@link Cluster} is also closed. By default,
+ * this method will bind the {@link RemoteConnection} to a graph on the server named "graph".
+ */
+ public static DriverRemoteConnection using(final String clusterConfFile) {
+ return using(clusterConfFile, "graph");
+ }
+
+ /**
+ * Creates a {@link DriverRemoteConnection} using a new {@link Cluster} instance created from the supplied
+ * configuration file. When {@link #close()} is called, this new {@link Cluster} is also closed.
+ */
+ public static DriverRemoteConnection using(final String clusterConfFile, final String connectionGraphName) {
+ try {
+ return new DriverRemoteConnection(Cluster.open(clusterConfFile), true, connectionGraphName);
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ /**
+ * Creates a {@link DriverRemoteConnection} using an Apache {@code Configuration} object. This method of creation
+ * is typically used by {@link RemoteGraph} when being constructed via {@link GraphFactory}. The
+ * {@code Configuration} object should contain one of two required keys, either: {@code clusterConfigurationFile}
+ * or {@code clusterConfiguration}. The {@code clusterConfigurationFile} key is a pointer to a file location
+ * containing a configuration for a {@link Cluster}. The {@code clusterConfiguration} should contain the actual
+ * contents of a configuration that would be used by a {@link Cluster}. This {@code configuration} may also
+ * contain the optional, but likely necessary, {@code connectionGraphName} which tells the
+ * {@code DriverServerConnection} which graph on the server to bind to.
+ */
+ public static DriverRemoteConnection using(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("clusterConfigurationFile") && !conf.containsKey("clusterConfiguration"))
+ throw new IllegalStateException("A configuration must contain either 'clusterConfigurationFile' and 'clusterConfiguration'");
+
+ final String connectionGraphName = conf.getString("connectionGraphName", "graph");
+ if (conf.containsKey("clusterConfigurationFile"))
+ return using(conf.getString("clusterConfigurationFile"), connectionGraphName);
+ else {
+ return using(Cluster.open(conf.subset("clusterConfiguration")), connectionGraphName);
+ }
+ }
+
+ @Override
+ public Iterator<Traverser> submit(final Traversal t) throws RemoteConnectionException {
+ try {
+ return new TraverserIterator(client.submit(t).iterator());
+ } catch (Exception ex) {
+ throw new RemoteConnectionException(ex);
+ }
+ }
+
+ @Override
+ public void close() throws Exception {
+ try {
+ client.close();
+ } catch (Exception ex) {
+ throw new RemoteConnectionException(ex);
+ } finally {
+ if (tryCloseCluster)
+ client.getCluster().close();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "DriverServerConnection-" + client.getCluster() + " [graph='" + connectionGraphName + "]";
+ }
+
+ static class TraverserIterator implements Iterator<Traverser> {
+
+ private Iterator<Result> inner;
+
+ public TraverserIterator(final Iterator<Result> resultIterator) {
+ inner = resultIterator;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return inner.hasNext();
+ }
+
+ @Override
+ public Traverser next() {
+ final Object o = inner.next().getObject();
+ return (Traverser) o;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverServerConnection.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverServerConnection.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverServerConnection.java
deleted file mode 100644
index 2727a17..0000000
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverServerConnection.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.driver.remote;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.tinkerpop.gremlin.driver.Client;
-import org.apache.tinkerpop.gremlin.driver.Cluster;
-import org.apache.tinkerpop.gremlin.driver.Result;
-import org.apache.tinkerpop.gremlin.process.remote.ServerConnection;
-import org.apache.tinkerpop.gremlin.process.remote.ServerConnectionException;
-import org.apache.tinkerpop.gremlin.process.remote.ServerGraph;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
-
-import java.util.Iterator;
-
-/**
- * A {@link ServerConnection} implementation for Gremlin Server. Each {@code DriverServerConnection} is bound to one
- * graph instance hosted in Gremlin Server.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class DriverServerConnection implements ServerConnection {
-
- private final Client client;
- private final boolean tryCloseCluster;
- private final String connectionGraphName;
-
- public DriverServerConnection(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("clusterConfigurationFile") && !conf.containsKey("clusterConfiguration"))
- throw new IllegalStateException("A configuration must contain either 'clusterConfigurationFile' and 'clusterConfiguration'");
-
- connectionGraphName = conf.getString("connectionGraphName", "graph");
-
- try {
- final Cluster cluster = conf.containsKey("clusterConfigurationFile") ?
- Cluster.open(conf.getString("clusterConfigurationFile")) : Cluster.open(conf.subset("clusterConfiguration"));
- client = cluster.connect(Client.Settings.build().unrollTraversers(false).create()).alias(connectionGraphName);
- } catch (Exception ex) {
- throw new IllegalStateException(ex);
- }
-
- tryCloseCluster = true;
- }
-
- private DriverServerConnection(final Cluster cluster, final boolean tryCloseCluster, final String connectionGraphName){
- client = cluster.connect(Client.Settings.build().unrollTraversers(false).create()).alias(connectionGraphName);
- this.connectionGraphName = connectionGraphName;
- this.tryCloseCluster = tryCloseCluster;
- }
-
- /**
- * Creates a {@link DriverServerConnection} from an existing {@link Cluster} instance. When {@link #close()} is
- * called, the {@link Cluster} is left open for the caller to close. By default, this method will bind the
- * {@link ServerConnection} to a graph on the server named "graph".
- */
- public static DriverServerConnection using(final Cluster cluster) {
- return using(cluster, "graph");
- }
-
- /**
- * Creates a {@link DriverServerConnection} from an existing {@link Cluster} instance. When {@link #close()} is
- * called, the {@link Cluster} is left open for the caller to close.
- */
- public static DriverServerConnection using(final Cluster cluster, final String connectionGraphName) {
- return new DriverServerConnection(cluster, false, connectionGraphName);
- }
-
- /**
- * Creates a {@link DriverServerConnection} using a new {@link Cluster} instance created from the supplied
- * configuration file. When {@link #close()} is called, this new {@link Cluster} is also closed. By default,
- * this method will bind the {@link ServerConnection} to a graph on the server named "graph".
- */
- public static DriverServerConnection using(final String clusterConfFile) {
- return using(clusterConfFile, "graph");
- }
-
- /**
- * Creates a {@link DriverServerConnection} using a new {@link Cluster} instance created from the supplied
- * configuration file. When {@link #close()} is called, this new {@link Cluster} is also closed.
- */
- public static DriverServerConnection using(final String clusterConfFile, final String connectionGraphName) {
- try {
- return new DriverServerConnection(Cluster.open(clusterConfFile), true, connectionGraphName);
- } catch (Exception ex) {
- throw new IllegalStateException(ex);
- }
- }
-
- /**
- * Creates a {@link DriverServerConnection} using an Apache {@code Configuration} object. This method of creation
- * is typically used by {@link ServerGraph} when being constructed via {@link GraphFactory}. The
- * {@code Configuration} object should contain one of two required keys, either: {@code clusterConfigurationFile}
- * or {@code clusterConfiguration}. The {@code clusterConfigurationFile} key is a pointer to a file location
- * containing a configuration for a {@link Cluster}. The {@code clusterConfiguration} should contain the actual
- * contents of a configuration that would be used by a {@link Cluster}. This {@code configuration} may also
- * contain the optional, but likely necessary, {@code connectionGraphName} which tells the
- * {@code DriverServerConnection} which graph on the server to bind to.
- */
- public static DriverServerConnection using(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("clusterConfigurationFile") && !conf.containsKey("clusterConfiguration"))
- throw new IllegalStateException("A configuration must contain either 'clusterConfigurationFile' and 'clusterConfiguration'");
-
- final String connectionGraphName = conf.getString("connectionGraphName", "graph");
- if (conf.containsKey("clusterConfigurationFile"))
- return using(conf.getString("clusterConfigurationFile"), connectionGraphName);
- else {
- return using(Cluster.open(conf.subset("clusterConfiguration")), connectionGraphName);
- }
- }
-
- @Override
- public Iterator<Traverser> submit(final Traversal t) throws ServerConnectionException {
- try {
- return new TraverserIterator(client.submit(t).iterator());
- } catch (Exception ex) {
- throw new ServerConnectionException(ex);
- }
- }
-
- @Override
- public void close() throws Exception {
- try {
- client.close();
- } catch (Exception ex) {
- throw new ServerConnectionException(ex);
- } finally {
- if (tryCloseCluster)
- client.getCluster().close();
- }
- }
-
- @Override
- public String toString() {
- return "DriverServerConnection-" + client.getCluster() + " [graph='" + connectionGraphName + "]";
- }
-
- static class TraverserIterator implements Iterator<Traverser> {
-
- private Iterator<Result> inner;
-
- public TraverserIterator(final Iterator<Result> resultIterator) {
- inner = resultIterator;
- }
-
- @Override
- public boolean hasNext() {
- return inner.hasNext();
- }
-
- @Override
- public Traverser next() {
- final Object o = inner.next().getObject();
- return (Traverser) o;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a10d9f1d/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/WithServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/WithServerIntegrationTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/WithServerIntegrationTest.java
index 2265a8a..40c8f8a 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/WithServerIntegrationTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/WithServerIntegrationTest.java
@@ -19,8 +19,8 @@
package org.apache.tinkerpop.gremlin.server;
import org.apache.tinkerpop.gremlin.driver.Cluster;
-import org.apache.tinkerpop.gremlin.driver.remote.DriverServerConnection;
-import org.apache.tinkerpop.gremlin.process.remote.ServerGraph;
+import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteGraph;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
@@ -41,7 +41,7 @@ public class WithServerIntegrationTest extends AbstractGremlinServerIntegrationT
@Test
public void shouldDoServerGraphReturningVertices() {
final Cluster cluster = Cluster.open();
- final Graph graph = ServerGraph.open(DriverServerConnection.using(cluster), TinkerGraph.class);
+ final Graph graph = RemoteGraph.open(DriverRemoteConnection.using(cluster), TinkerGraph.class);
final GraphTraversalSource g = graph.traversal();
g.V().forEachRemaining(v -> System.out.println("TEST: " + v.toString()));
cluster.close();