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/04 14:56:34 UTC

[1/3] incubator-tinkerpop git commit: Make the GraphManager instance injectable into ServerGremlinExecutor

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/tp31 f83f58c27 -> d54b658f0


Make the GraphManager instance injectable into ServerGremlinExecutor

This refers to a discussion from the gremlin-users mailing list:
https://groups.google.com/forum/#!topic/gremlin-users/xYzCAQExvvM

It is currently not possible to use a standard way to inject a
fully configured graph. The way presented in this gist is only
a hack and should not be takes as the default way.
https://gist.github.com/xenji/e469abde2e0b80aadc4e

Adding a new constructor parameter is, from my point of view,
the most flexible and compatible change to enable the injection
without breaking old code.

I've run the whole test suite of the server before pushing without
failures.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/164b88ae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/164b88ae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/164b88ae

Branch: refs/heads/tp31
Commit: 164b88ae1c139a2541c28b21795836318ed82246
Parents: 8a2d797
Author: Mario Mueller <ma...@trivago.com>
Authored: Mon Feb 29 21:16:14 2016 +0100
Committer: Mario Mueller <ma...@trivago.com>
Committed: Thu Mar 3 07:31:59 2016 +0100

----------------------------------------------------------------------
 .../server/util/ServerGremlinExecutor.java      | 26 +++++++++++++-------
 1 file changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/164b88ae/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 3fa568c..b5d9f46 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
@@ -70,7 +70,14 @@ public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
     public ServerGremlinExecutor(final Settings settings, final Class<T> scheduleExecutorServiceClass) {
         this(settings, null, null, scheduleExecutorServiceClass);
     }
-
+    public ServerGremlinExecutor(final Settings settings, final ExecutorService gremlinExecutorService,
+                                 final T scheduledExecutorService, final Class<T> scheduleExecutorServiceClass) {
+        this(settings,
+             gremlinExecutorService,
+             scheduledExecutorService,
+             scheduleExecutorServiceClass,
+             new GraphManager(settings));
+    }
     /**
      * Create a new object from {@link Settings} where thread pools are externally assigned. Note that if the
      * {@code scheduleExecutorServiceClass} is set to {@code null} it will be created via
@@ -78,7 +85,8 @@ public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
      * instances are supplied, the {@link Settings#gremlinPool} value will be ignored for the pool size.
      */
     public ServerGremlinExecutor(final Settings settings, final ExecutorService gremlinExecutorService,
-                                 final T scheduledExecutorService, final Class<T> scheduleExecutorServiceClass) {
+                                 final T scheduledExecutorService, final Class<T> scheduleExecutorServiceClass,
+                                 final GraphManager graphManager) {
         this.settings = settings;
 
         if (null == gremlinExecutorService) {
@@ -97,17 +105,17 @@ public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
         }
 
         // initialize graphs from configuration
-        graphManager = new GraphManager(settings);
+        this.graphManager = graphManager;
 
         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) -> graphManager.rollbackAll())
-                .beforeEval(b -> graphManager.rollbackAll())
-                .afterTimeout(b -> graphManager.rollbackAll())
+                .afterFailure((b, e) -> this.graphManager.rollbackAll())
+                .beforeEval(b -> this.graphManager.rollbackAll())
+                .afterTimeout(b -> this.graphManager.rollbackAll())
                 .enabledPlugins(new HashSet<>(settings.plugins))
-                .globalBindings(graphManager.getAsBindings())
+                .globalBindings(this.graphManager.getAsBindings())
                 .executorService(this.gremlinExecutorService)
                 .scheduledExecutorService(this.scheduledExecutorService);
 
@@ -126,14 +134,14 @@ public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
         // re-apply those references back
         gremlinExecutor.getGlobalBindings().entrySet().stream()
                 .filter(kv -> kv.getValue() instanceof Graph)
-                .forEach(kv -> graphManager.getGraphs().put(kv.getKey(), (Graph) kv.getValue()));
+                .forEach(kv -> this.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());
-                    graphManager.getTraversalSources().put(kv.getKey(), (TraversalSource) kv.getValue());
+                    this.graphManager.getTraversalSources().put(kv.getKey(), (TraversalSource) kv.getValue());
                 });
 
         // determine if the initialization scripts introduced LifeCycleHook objects - if so we need to gather them


[2/3] incubator-tinkerpop git commit: Merge branch 'make-graphmanager-injectable-tp31' of https://github.com/xenji/incubator-tinkerpop into tp31

Posted by sp...@apache.org.
Merge branch 'make-graphmanager-injectable-tp31' of https://github.com/xenji/incubator-tinkerpop into tp31


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/b9729a54
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/b9729a54
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/b9729a54

Branch: refs/heads/tp31
Commit: b9729a542d55999111de248953dbf80458998604
Parents: f83f58c 164b88a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Mar 4 08:54:34 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Mar 4 08:54:34 2016 -0500

----------------------------------------------------------------------
 .../server/util/ServerGremlinExecutor.java      | 26 +++++++++++++-------
 1 file changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------



[3/3] incubator-tinkerpop git commit: Add javadoc to ServerGremlinExecutor.

Posted by sp...@apache.org.
Add javadoc to ServerGremlinExecutor.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/d54b658f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/d54b658f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/d54b658f

Branch: refs/heads/tp31
Commit: d54b658f08d9cc91478f11310666e7271b7e194b
Parents: b9729a5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Mar 4 08:56:17 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Mar 4 08:56:17 2016 -0500

----------------------------------------------------------------------
 .../gremlin/server/util/ServerGremlinExecutor.java          | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d54b658f/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 b5d9f46..c8870ed 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
@@ -70,6 +70,14 @@ public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
     public ServerGremlinExecutor(final Settings settings, final Class<T> scheduleExecutorServiceClass) {
         this(settings, null, null, scheduleExecutorServiceClass);
     }
+
+    /**
+     * Create a new object from {@link Settings} where thread pools are externally assigned. Note that if the
+     * {@code scheduleExecutorServiceClass} is set to {@code null} it will be created via
+     * {@link Executors#newScheduledThreadPool(int, ThreadFactory)}.  If either of the {@link ExecutorService}
+     * instances are supplied, the {@link Settings#gremlinPool} value will be ignored for the pool size. The
+     * {@link GraphManager} will be constructed from the {@link Settings}.
+     */
     public ServerGremlinExecutor(final Settings settings, final ExecutorService gremlinExecutorService,
                                  final T scheduledExecutorService, final Class<T> scheduleExecutorServiceClass) {
         this(settings,
@@ -104,7 +112,6 @@ public class ServerGremlinExecutor<T extends ScheduledExecutorService> {
             this.scheduledExecutorService = scheduledExecutorService;
         }
 
-        // initialize graphs from configuration
         this.graphManager = graphManager;
 
         logger.info("Initialized Gremlin thread pool.  Threads in pool named with pattern gremlin-*");