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 2015/06/17 20:26:31 UTC
incubator-tinkerpop git commit: Renamed Graphs to GraphManager in
Gremlin Server.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master 550af6729 -> 5407aa2bc
Renamed Graphs to GraphManager in Gremlin Server.
Graphs wasn't a great name as it held more than just Graph instances. It also came to hold TraversalSource instances.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/5407aa2b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/5407aa2b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/5407aa2b
Branch: refs/heads/master
Commit: 5407aa2bcfeaba7d6b66db71763e0b211f68ccbc
Parents: 550af67
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jun 17 14:25:48 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Jun 17 14:25:48 2015 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../gremlin/server/AbstractChannelizer.java | 10 +-
.../tinkerpop/gremlin/server/Context.java | 12 +-
.../tinkerpop/gremlin/server/GraphManager.java | 113 +++++++++++++++++++
.../apache/tinkerpop/gremlin/server/Graphs.java | 112 ------------------
.../tinkerpop/gremlin/server/GremlinServer.java | 2 +-
.../gremlin/server/channel/HttpChannelizer.java | 2 +-
.../handler/HttpGremlinEndpointHandler.java | 12 +-
.../server/handler/OpExecutorHandler.java | 10 +-
.../server/handler/OpSelectorHandler.java | 10 +-
.../gremlin/server/op/session/Session.java | 12 +-
.../server/op/standard/StandardOpProcessor.java | 4 +-
.../server/util/ServerGremlinExecutor.java | 24 ++--
.../gremlin/server/GraphManagerTest.java | 62 ++++++++++
.../tinkerpop/gremlin/server/GraphsTest.java | 63 -----------
15 files changed, 225 insertions(+), 224 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 787ee2d..fddfdfe 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,6 +25,7 @@ image::http://www.tinkerpop.com/docs/current/images/gremlin-hindu.png[width=225]
TinkerPop 3.0.0.GA (NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Renamed `Graphs` in Gremlin Server to `GraphManager`.
* Arrow keys for cycling through command history now work in Gremlin Console when being used on Windows.
* Added `Path.getSingle(pop,label)` and `Path.getList(label)` as default helpers in `Path`.
* Added `Pop.first` and `Pop.last` as enums for getting single items from a collection.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
index dc7585c..6ccedcc 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/AbstractChannelizer.java
@@ -62,7 +62,7 @@ public abstract class AbstractChannelizer extends ChannelInitializer<SocketChann
protected Settings settings;
protected GremlinExecutor gremlinExecutor;
protected Optional<SslContext> sslContext;
- protected Graphs graphs;
+ protected GraphManager graphManager;
protected ExecutorService gremlinExecutorService;
protected ScheduledExecutorService scheduledExecutorService;
@@ -95,7 +95,7 @@ public abstract class AbstractChannelizer extends ChannelInitializer<SocketChann
public void init(final ServerGremlinExecutor<EventLoopGroup> serverGremlinExecutor) {
this.settings = serverGremlinExecutor.getSettings();
this.gremlinExecutor = serverGremlinExecutor.getGremlinExecutor();
- this.graphs = serverGremlinExecutor.getGraphs();
+ this.graphManager = serverGremlinExecutor.getGraphManager();
this.gremlinExecutorService = serverGremlinExecutor.getGremlinExecutorService();
this.scheduledExecutorService = serverGremlinExecutor.getScheduledExecutorService();
@@ -109,8 +109,8 @@ public abstract class AbstractChannelizer extends ChannelInitializer<SocketChann
if (sslContext.isPresent()) logger.info("SSL enabled");
// these handlers don't share any state and can thus be initialized once per pipeline
- this.opSelectorHandler = new OpSelectorHandler(settings, graphs, gremlinExecutor, scheduledExecutorService);
- this.opExecutorHandler = new OpExecutorHandler(settings, graphs, gremlinExecutor, scheduledExecutorService);
+ this.opSelectorHandler = new OpSelectorHandler(settings, graphManager, gremlinExecutor, scheduledExecutorService);
+ this.opExecutorHandler = new OpExecutorHandler(settings, graphManager, gremlinExecutor, scheduledExecutorService);
this.iteratorHandler = new IteratorHandler(settings);
}
@@ -143,7 +143,7 @@ public abstract class AbstractChannelizer extends ChannelInitializer<SocketChann
final MessageSerializer serializer = (MessageSerializer) clazz.newInstance();
if (config.config != null)
- serializer.configure(config.config, graphs.getGraphs());
+ serializer.configure(config.config, graphManager.getGraphs());
return Optional.ofNullable(serializer);
} catch (ClassNotFoundException cnfe) {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Context.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Context.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Context.java
index 575c2c5..7a353b7 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Context.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Context.java
@@ -29,21 +29,21 @@ import java.util.concurrent.ScheduledExecutorService;
*
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
-public class Context {
+public final class Context {
private final RequestMessage requestMessage;
private final ChannelHandlerContext channelHandlerContext;
private final Settings settings;
- private final Graphs graphs;
+ private final GraphManager graphManager;
private final GremlinExecutor gremlinExecutor;
private final ScheduledExecutorService scheduledExecutorService;
public Context(final RequestMessage requestMessage, final ChannelHandlerContext ctx,
- final Settings settings, final Graphs graphs,
+ final Settings settings, final GraphManager graphManager,
final GremlinExecutor gremlinExecutor, final ScheduledExecutorService scheduledExecutorService) {
this.requestMessage = requestMessage;
this.channelHandlerContext = ctx;
this.settings = settings;
- this.graphs = graphs;
+ this.graphManager = graphManager;
this.gremlinExecutor = gremlinExecutor;
this.scheduledExecutorService = scheduledExecutorService;
}
@@ -77,8 +77,8 @@ public class Context {
/**
* Gets the set of {@link org.apache.tinkerpop.gremlin.structure.Graph} objects configured in Gremlin Server.
*/
- public Graphs getGraphs() {
- return graphs;
+ public GraphManager getGraphManager() {
+ return graphManager;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java
new file mode 100644
index 0000000..aceac78
--- /dev/null
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java
@@ -0,0 +1,113 @@
+/*
+ * 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.server;
+
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.script.Bindings;
+import javax.script.SimpleBindings;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Holder for {@link Graph} and {@link TraversalSource} instances configured for the server to be passed to script
+ * engine bindings. The {@link Graph} instances are read from the {@link Settings} for Gremlin Server as defined in
+ * the configuration file. The {@link TraversalSource} instances are rebound to the {@code GraphManager} once
+ * initialization scripts construct them.
+ */
+public final class GraphManager {
+ private static final Logger logger = LoggerFactory.getLogger(GremlinServer.class);
+
+ private final Map<String, Graph> graphs = new ConcurrentHashMap<>();
+ private final Map<String, TraversalSource> traversalSources = new ConcurrentHashMap<>();
+
+ /**
+ * Create a new instance using the {@link Settings} from Gremlin Server.
+ */
+ public GraphManager(final Settings settings) {
+ settings.graphs.entrySet().forEach(e -> {
+ try {
+ final Graph newGraph = GraphFactory.open(e.getValue());
+ graphs.put(e.getKey(), newGraph);
+ logger.info("Graph [{}] was successfully configured via [{}].", e.getKey(), e.getValue());
+ } catch (RuntimeException re) {
+ logger.warn(String.format("Graph [%s] configured at [%s] could not be instantiated and will not be available in Gremlin Server. GraphFactory message: %s",
+ e.getKey(), e.getValue(), re.getMessage()), re);
+ if (re.getCause() != null) logger.debug("GraphFactory exception", re.getCause());
+ }
+ });
+ }
+
+ /**
+ * Get a list of the {@link Graph} instances and their binding names as defined in the Gremlin Server
+ * configuration file.
+ *
+ * @return a {@link Map} where the key is the name of the {@link Graph} and the value is the {@link Graph} itself
+ */
+ public Map<String, Graph> getGraphs() {
+ return graphs;
+ }
+
+ /**
+ * Get a list of the {@link TraversalSource} instances and their binding names as defined by Gremlin Server
+ * initialization scripts.
+ *
+ * @return a {@link Map} where the key is the name of the {@link TraversalSource} and the value is the
+ * {@link TraversalSource} itself
+ */
+ public Map<String, TraversalSource> getTraversalSources() {
+ return traversalSources;
+ }
+
+ /**
+ * Get the {@link Graph} and {@link TraversalSource} list as a set of bindings.
+ */
+ public Bindings getAsBindings() {
+ final Bindings bindings = new SimpleBindings();
+ graphs.forEach(bindings::put);
+ traversalSources.forEach(bindings::put);
+ return bindings;
+ }
+
+ /**
+ * Rollback transactions across all {@link Graph} objects.
+ */
+ public void rollbackAll() {
+ graphs.entrySet().forEach(e -> {
+ final Graph g = e.getValue();
+ if (g.features().graph().supportsTransactions())
+ g.tx().rollback();
+ });
+ }
+
+ /**
+ * Commit transactions across all {@link Graph} objects.
+ */
+ public void commitAll() {
+ graphs.entrySet().forEach(e -> {
+ final Graph g = e.getValue();
+ if (g.features().graph().supportsTransactions())
+ g.tx().commit();
+ });
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Graphs.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Graphs.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Graphs.java
deleted file mode 100644
index defe204..0000000
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/Graphs.java
+++ /dev/null
@@ -1,112 +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.server;
-
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.script.Bindings;
-import javax.script.SimpleBindings;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * {@link Graph} instances configured for the server to be passed to script engine bindings. The
- * {@link Graph} instances are read from the {@link Settings} for Gremlin Server as defined in the configuration
- * file. Also holds any {@link TraversalSource} objects as constructed in the server.
- */
-public class Graphs {
- private static final Logger logger = LoggerFactory.getLogger(GremlinServer.class);
-
- private final Map<String, Graph> graphs = new ConcurrentHashMap<>();
- private final Map<String, TraversalSource> traversalSources = new ConcurrentHashMap<>();
-
- /**
- * Create a new instance using the {@link Settings} from Gremlin Server.
- */
- public Graphs(final Settings settings) {
- settings.graphs.entrySet().forEach(e -> {
- try {
- final Graph newGraph = GraphFactory.open(e.getValue());
- graphs.put(e.getKey(), newGraph);
- logger.info("Graph [{}] was successfully configured via [{}].", e.getKey(), e.getValue());
- } catch (RuntimeException re) {
- logger.warn(String.format("Graph [%s] configured at [%s] could not be instantiated and will not be available in Gremlin Server. GraphFactory message: %s",
- e.getKey(), e.getValue(), re.getMessage()), re);
- if (re.getCause() != null) logger.debug("GraphFactory exception", re.getCause());
- }
- });
- }
-
- /**
- * Get a list of the {@link Graph} instances and their binding names as defined in the Gremlin Server
- * configuration file.
- *
- * @return a {@link Map} where the key is the name of the {@link Graph} and the value is the {@link Graph} itself
- */
- public Map<String, Graph> getGraphs() {
- return graphs;
- }
-
- /**
- * Get a list of the {@link TraversalSource} instances and their binding names as defined by Gremlin Server
- * initialization scripts.
- *
- * @return a {@link Map} where the key is the name of the {@link TraversalSource} and the value is the
- * {@link TraversalSource} itself
- */
- public Map<String, TraversalSource> getTraversalSources() {
- return traversalSources;
- }
-
- /**
- * Get the {@link Graph} and {@link TraversalSource} list as a set of bindings.
- */
- public Bindings getAsBindings() {
- final Bindings bindings = new SimpleBindings();
- graphs.forEach(bindings::put);
- traversalSources.forEach(bindings::put);
- return bindings;
- }
-
- /**
- * Rollback transactions across all {@link Graph} objects.
- */
- public void rollbackAll() {
- graphs.entrySet().forEach(e -> {
- final Graph g = e.getValue();
- if (g.features().graph().supportsTransactions())
- g.tx().rollback();
- });
- }
-
- /**
- * Commit transactions across all {@link Graph} objects.
- */
- public void commitAll() {
- graphs.entrySet().forEach(e -> {
- final Graph g = e.getValue();
- if (g.features().graph().supportsTransactions())
- g.tx().commit();
- });
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
index f34ccc8..2eff2be 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GremlinServer.java
@@ -245,7 +245,7 @@ public class GremlinServer {
logger.warn("Timeout waiting for bossy/worker thread pools to shutdown - continuing with shutdown process.");
}
- serverGremlinExecutor.getGraphs().getGraphs().forEach((k, v) -> {
+ serverGremlinExecutor.getGraphManager().getGraphs().forEach((k, v) -> {
logger.debug("Closing Graph instance [{}]", k);
try {
v.close();
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/HttpChannelizer.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/HttpChannelizer.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/HttpChannelizer.java
index d584a64..28df014 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/HttpChannelizer.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/channel/HttpChannelizer.java
@@ -43,7 +43,7 @@ public class HttpChannelizer extends AbstractChannelizer {
@Override
public void init(final ServerGremlinExecutor<EventLoopGroup> serverGremlinExecutor) {
super.init(serverGremlinExecutor);
- httpGremlinEndpointHandler = new HttpGremlinEndpointHandler(serializers, gremlinExecutor, graphs);
+ httpGremlinEndpointHandler = new HttpGremlinEndpointHandler(serializers, gremlinExecutor, graphManager);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
index 393159b..c53f09c 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpGremlinEndpointHandler.java
@@ -31,7 +31,7 @@ import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
import org.apache.tinkerpop.gremlin.driver.ser.MessageTextSerializer;
import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
-import org.apache.tinkerpop.gremlin.server.Graphs;
+import org.apache.tinkerpop.gremlin.server.GraphManager;
import org.apache.tinkerpop.gremlin.server.GremlinServer;
import org.apache.tinkerpop.gremlin.server.util.MetricManager;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -108,14 +108,14 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter {
private static final ObjectMapper mapper = new ObjectMapper();
private final GremlinExecutor gremlinExecutor;
- private final Graphs graphs;
+ private final GraphManager graphManager;
public HttpGremlinEndpointHandler(final Map<String, MessageSerializer> serializers,
final GremlinExecutor gremlinExecutor,
- final Graphs graphs) {
+ final GraphManager graphManager) {
this.serializers = serializers;
this.gremlinExecutor = gremlinExecutor;
- this.graphs = graphs;
+ this.graphManager = graphManager;
}
@Override
@@ -251,14 +251,14 @@ public class HttpGremlinEndpointHandler extends ChannelInboundHandlerAdapter {
if (!rebindingMap.isEmpty()) {
for (Map.Entry<String, String> kv : rebindingMap.entrySet()) {
boolean found = false;
- final Map<String, Graph> graphs = this.graphs.getGraphs();
+ final Map<String, Graph> graphs = this.graphManager.getGraphs();
if (graphs.containsKey(kv.getValue())) {
bindings.put(kv.getKey(), graphs.get(kv.getValue()));
found = true;
}
if (!found) {
- final Map<String, TraversalSource> traversalSources = this.graphs.getTraversalSources();
+ final Map<String, TraversalSource> traversalSources = this.graphManager.getTraversalSources();
if (traversalSources.containsKey(kv.getValue())) {
bindings.put(kv.getKey(), traversalSources.get(kv.getValue()));
found = true;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpExecutorHandler.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpExecutorHandler.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpExecutorHandler.java
index 9b206bd..f624c21 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpExecutorHandler.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpExecutorHandler.java
@@ -21,7 +21,7 @@ package org.apache.tinkerpop.gremlin.server.handler;
import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor;
import org.apache.tinkerpop.gremlin.server.Context;
-import org.apache.tinkerpop.gremlin.server.Graphs;
+import org.apache.tinkerpop.gremlin.server.GraphManager;
import org.apache.tinkerpop.gremlin.server.Settings;
import org.apache.tinkerpop.gremlin.server.op.OpProcessorException;
import org.apache.tinkerpop.gremlin.util.function.ThrowingConsumer;
@@ -43,14 +43,14 @@ public class OpExecutorHandler extends SimpleChannelInboundHandler<Pair<RequestM
private static final Logger logger = LoggerFactory.getLogger(OpExecutorHandler.class);
private final Settings settings;
- private final Graphs graphs;
+ private final GraphManager graphManager;
private final ScheduledExecutorService scheduledExecutorService;
private final GremlinExecutor gremlinExecutor;
- public OpExecutorHandler(final Settings settings, final Graphs graphs, final GremlinExecutor gremlinExecutor,
+ public OpExecutorHandler(final Settings settings, final GraphManager graphManager, final GremlinExecutor gremlinExecutor,
final ScheduledExecutorService scheduledExecutorService) {
this.settings = settings;
- this.graphs = graphs;
+ this.graphManager = graphManager;
this.gremlinExecutor = gremlinExecutor;
this.scheduledExecutorService = scheduledExecutorService;
}
@@ -60,7 +60,7 @@ public class OpExecutorHandler extends SimpleChannelInboundHandler<Pair<RequestM
final RequestMessage msg = objects.getValue0();
final ThrowingConsumer<Context> op = objects.getValue1();
final Context gremlinServerContext = new Context(msg, ctx,
- settings, graphs, gremlinExecutor, scheduledExecutorService);
+ settings, graphManager, gremlinExecutor, scheduledExecutorService);
try {
op.accept(gremlinServerContext);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpSelectorHandler.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpSelectorHandler.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpSelectorHandler.java
index 98d56bb..6ef65e2 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpSelectorHandler.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/OpSelectorHandler.java
@@ -24,7 +24,7 @@ import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor;
import org.apache.tinkerpop.gremlin.server.Context;
-import org.apache.tinkerpop.gremlin.server.Graphs;
+import org.apache.tinkerpop.gremlin.server.GraphManager;
import org.apache.tinkerpop.gremlin.server.GremlinServer;
import org.apache.tinkerpop.gremlin.server.OpProcessor;
import org.apache.tinkerpop.gremlin.server.Settings;
@@ -53,15 +53,15 @@ public class OpSelectorHandler extends MessageToMessageDecoder<RequestMessage> {
static final Meter errorMeter = MetricManager.INSTANCE.getMeter(name(GremlinServer.class, "errors"));
private final Settings settings;
- private final Graphs graphs;
+ private final GraphManager graphManager;
private final GremlinExecutor gremlinExecutor;
private final ScheduledExecutorService scheduledExecutorService;
- public OpSelectorHandler(final Settings settings, final Graphs graphs, final GremlinExecutor gremlinExecutor,
+ public OpSelectorHandler(final Settings settings, final GraphManager graphManager, final GremlinExecutor gremlinExecutor,
final ScheduledExecutorService scheduledExecutorService) {
this.settings = settings;
- this.graphs = graphs;
+ this.graphManager = graphManager;
this.gremlinExecutor = gremlinExecutor;
this.scheduledExecutorService = scheduledExecutorService;
}
@@ -70,7 +70,7 @@ public class OpSelectorHandler extends MessageToMessageDecoder<RequestMessage> {
protected void decode(final ChannelHandlerContext ctx, final RequestMessage msg,
final List<Object> objects) throws Exception {
final Context gremlinServerContext = new Context(msg, ctx, settings,
- graphs, gremlinExecutor, this.scheduledExecutorService);
+ graphManager, gremlinExecutor, this.scheduledExecutorService);
try {
// choose a processor to do the work based on the request message.
final Optional<OpProcessor> processor = OpLoader.getProcessor(msg.getProcessor());
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java
index d91c312..7c5bc54 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/session/Session.java
@@ -21,7 +21,7 @@ package org.apache.tinkerpop.gremlin.server.op.session;
import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
import org.apache.tinkerpop.gremlin.server.Context;
-import org.apache.tinkerpop.gremlin.server.Graphs;
+import org.apache.tinkerpop.gremlin.server.GraphManager;
import org.apache.tinkerpop.gremlin.server.Settings;
import org.apache.tinkerpop.gremlin.server.util.LifeCycleHook;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -46,7 +46,7 @@ public class Session {
private static final Logger logger = LoggerFactory.getLogger(Session.class);
private final Bindings bindings;
private final Settings settings;
- private final Graphs graphs;
+ private final GraphManager graphManager;
private final String session;
private final ScheduledExecutorService scheduledExecutorService;
private final long configuredSessionTimeout;
@@ -73,7 +73,7 @@ public class Session {
this.session = session;
this.bindings = new SimpleBindings();
this.settings = context.getSettings();
- this.graphs = context.getGraphs();
+ this.graphManager = context.getGraphManager();
this.scheduledExecutorService = context.getScheduledExecutorService();
this.sessions = sessions;
@@ -105,7 +105,7 @@ public class Session {
if (killFuture != null) killFuture.cancel(false);
kill.set(this.scheduledExecutorService.schedule(() -> {
// when the session is killed open transaction should be rolled back
- graphs.getGraphs().values().forEach(g -> {
+ graphManager.getGraphs().values().forEach(g -> {
if (g.features().graph().supportsTransactions()) {
// have to execute the rollback in the executor because the transaction is associated with
// that thread of execution from this session
@@ -125,7 +125,7 @@ public class Session {
final GremlinExecutor.Builder gremlinExecutorBuilder = GremlinExecutor.build()
.scriptEvaluationTimeout(settings.scriptEvaluationTimeout)
.afterTimeout(b -> {
- graphs.rollbackAll();
+ graphManager.rollbackAll();
this.bindings.clear();
this.bindings.putAll(b);
})
@@ -134,7 +134,7 @@ public class Session {
this.bindings.putAll(b);
})
.enabledPlugins(new HashSet<>(settings.plugins))
- .globalBindings(graphs.getAsBindings())
+ .globalBindings(graphManager.getAsBindings())
.promoteBindings(kv -> kv.getValue() instanceof Graph
|| kv.getValue() instanceof TraversalSource)
.executorService(executor)
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
index 03e9677..0078179 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/standard/StandardOpProcessor.java
@@ -70,14 +70,14 @@ public class StandardOpProcessor extends AbstractEvalOpProcessor {
final Map<String, String> rebinds = (Map<String, String>) msg.getArgs().get(Tokens.ARGS_REBINDINGS);
for (Map.Entry<String,String> kv : rebinds.entrySet()) {
boolean found = false;
- final Map<String, Graph> graphs = context.getGraphs().getGraphs();
+ final Map<String, Graph> graphs = context.getGraphManager().getGraphs();
if (graphs.containsKey(kv.getValue())) {
bindings.put(kv.getKey(), graphs.get(kv.getValue()));
found = true;
}
if (!found) {
- final Map<String, TraversalSource> traversalSources = context.getGraphs().getTraversalSources();
+ final Map<String, TraversalSource> traversalSources = context.getGraphManager().getTraversalSources();
if (traversalSources.containsKey(kv.getValue())) {
bindings.put(kv.getKey(), traversalSources.get(kv.getValue()));
found = true;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java
index 43cef89..62ceac8 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java
@@ -20,7 +20,7 @@ package org.apache.tinkerpop.gremlin.server.util;
import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
-import org.apache.tinkerpop.gremlin.server.Graphs;
+import org.apache.tinkerpop.gremlin.server.GraphManager;
import org.apache.tinkerpop.gremlin.server.GremlinServer;
import org.apache.tinkerpop.gremlin.server.Settings;
import org.apache.tinkerpop.gremlin.structure.Graph;
@@ -48,7 +48,7 @@ import java.util.stream.Collectors;
public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
private static final Logger logger = LoggerFactory.getLogger(ServerGremlinExecutor.class);
- private final Graphs graphs;
+ private final GraphManager graphManager;
private final Settings settings;
private final List<LifeCycleHook> hooks;
@@ -91,18 +91,18 @@ public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
}
// initialize graphs from configuration
- graphs = new Graphs(settings);
+ graphManager = new GraphManager(settings);
logger.info("Initialized Gremlin thread pool. Threads in pool named with pattern gremlin-*");
final GremlinExecutor.Builder gremlinExecutorBuilder = GremlinExecutor.build()
.scriptEvaluationTimeout(settings.scriptEvaluationTimeout)
- .afterFailure((b, e) -> graphs.rollbackAll())
- .afterSuccess(b -> graphs.commitAll())
- .beforeEval(b -> graphs.rollbackAll())
- .afterTimeout(b -> graphs.rollbackAll())
+ .afterFailure((b, e) -> graphManager.rollbackAll())
+ .afterSuccess(b -> graphManager.commitAll())
+ .beforeEval(b -> graphManager.rollbackAll())
+ .afterTimeout(b -> graphManager.rollbackAll())
.enabledPlugins(new HashSet<>(settings.plugins))
- .globalBindings(graphs.getAsBindings())
+ .globalBindings(graphManager.getAsBindings())
.promoteBindings(kv -> kv.getValue() instanceof Graph
|| kv.getValue() instanceof TraversalSource
|| kv.getValue() instanceof LifeCycleHook)
@@ -123,14 +123,14 @@ public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
// re-apply those references back
gremlinExecutor.getGlobalBindings().entrySet().stream()
.filter(kv -> kv.getValue() instanceof Graph)
- .forEach(kv -> graphs.getGraphs().put(kv.getKey(), (Graph) kv.getValue()));
+ .forEach(kv -> graphManager.getGraphs().put(kv.getKey(), (Graph) kv.getValue()));
// script engine init may have constructed the TraversalSource bindings - store them in Graphs object
gremlinExecutor.getGlobalBindings().entrySet().stream()
.filter(kv -> kv.getValue() instanceof TraversalSource)
.forEach(kv -> {
logger.info("A {} is now bound to [{}] with {}", kv.getValue().getClass().getSimpleName(), kv.getKey(), kv.getValue());
- graphs.getTraversalSources().put(kv.getKey(), (TraversalSource) kv.getValue());
+ graphManager.getTraversalSources().put(kv.getKey(), (TraversalSource) kv.getValue());
});
// determine if the initialization scripts introduced LifeCycleHook objects - if so we need to gather them
@@ -153,8 +153,8 @@ public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
return gremlinExecutorService;
}
- public Graphs getGraphs() {
- return graphs;
+ public GraphManager getGraphManager() {
+ return graphManager;
}
public Settings getSettings() {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GraphManagerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GraphManagerTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GraphManagerTest.java
new file mode 100644
index 0000000..7287f90
--- /dev/null
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GraphManagerTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.server;
+
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.Test;
+
+import javax.script.Bindings;
+import java.util.Map;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GraphManagerTest {
+
+ @Test
+ public void shouldReturnGraphs() {
+ final Settings settings = Settings.read(GraphManagerTest.class.getResourceAsStream("gremlin-server-integration.yaml"));
+ final GraphManager graphManager = new GraphManager(settings);
+ final Map<String, Graph> m = graphManager.getGraphs();
+
+ assertNotNull(m);
+ assertEquals(1, m.size());
+ assertThat(m.containsKey("graph"), is(true));
+ assertThat(m.get("graph"), instanceOf(TinkerGraph.class));
+ }
+
+ @Test
+ public void shouldGetAsBindings() {
+ final Settings settings = Settings.read(GraphManagerTest.class.getResourceAsStream("gremlin-server-integration.yaml"));
+ final GraphManager graphManager = new GraphManager(settings);
+ final Bindings bindings = graphManager.getAsBindings();
+
+ assertNotNull(bindings);
+ assertEquals(1, bindings.size());
+ assertThat(bindings.get("graph"), instanceOf(TinkerGraph.class));
+ assertThat(bindings.containsKey("graph"), is(true));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5407aa2b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GraphsTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GraphsTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GraphsTest.java
deleted file mode 100644
index 1760be1..0000000
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GraphsTest.java
+++ /dev/null
@@ -1,63 +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.server;
-
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.Test;
-
-import javax.script.Bindings;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class GraphsTest {
-
- @Test
- public void shouldReturnGraphs() {
- final Settings settings = Settings.read(GraphsTest.class.getResourceAsStream("gremlin-server-integration.yaml"));
- final Graphs graphs = new Graphs(settings);
- final Map<String, Graph> m = graphs.getGraphs();
-
- assertNotNull(m);
- assertEquals(1, m.size());
- assertThat(m.containsKey("graph"), is(true));
- assertThat(m.get("graph"), instanceOf(TinkerGraph.class));
- }
-
- @Test
- public void shouldGetAsBindings() {
- final Settings settings = Settings.read(GraphsTest.class.getResourceAsStream("gremlin-server-integration.yaml"));
- final Graphs graphs = new Graphs(settings);
- final Bindings bindings = graphs.getAsBindings();
-
- assertNotNull(bindings);
- assertEquals(1, bindings.size());
- assertThat(bindings.get("graph"), instanceOf(TinkerGraph.class));
- assertThat(bindings.containsKey("graph"), is(true));
- }
-}