spmallette commented on code in PR #3384:
URL: https://github.com/apache/tinkerpop/pull/3384#discussion_r3086067008
##########
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/ServerGremlinExecutor.java:
##########
@@ -186,20 +189,108 @@ public ServerGremlinExecutor(final Settings settings,
final ExecutorService grem
.forEach(kv -> this.graphManager.putGraph(kv.getKey(), (Graph)
kv.getValue()));
// script engine init may have constructed the TraversalSource
bindings - store them in Graphs object
-
gremlinExecutor.getScriptEngineManager().getBindings().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());
- this.graphManager.putTraversalSource(kv.getKey(),
(TraversalSource) kv.getValue());
- });
+ final boolean hasScriptTraversalSources =
gremlinExecutor.getScriptEngineManager().getBindings().entrySet().stream()
+ .anyMatch(kv -> kv.getValue() instanceof TraversalSource);
+ if (hasScriptTraversalSources) {
+ logger.warn("TraversalSource instances were created via script
engine initialization scripts. " +
+ "This approach is deprecated - use the
'traversalSources' YAML configuration instead.");
+
gremlinExecutor.getScriptEngineManager().getBindings().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());
+ this.graphManager.putTraversalSource(kv.getKey(),
(TraversalSource) kv.getValue());
+ });
+ }
// determine if the initialization scripts introduced LifeCycleHook
objects - if so we need to gather them
// up for execution
- hooks =
gremlinExecutor.getScriptEngineManager().getBindings().entrySet().stream()
+ final boolean hasScriptHooks =
gremlinExecutor.getScriptEngineManager().getBindings().entrySet().stream()
+ .anyMatch(kv -> kv.getValue() instanceof LifeCycleHook);
+ if (hasScriptHooks) {
+ logger.warn("LifeCycleHook instances were created via script
engine initialization scripts. " +
+ "This approach is deprecated - use the
'lifecycleHooks' YAML configuration instead.");
+ }
+ final List<LifeCycleHook> scriptHooks =
gremlinExecutor.getScriptEngineManager().getBindings().entrySet().stream()
.filter(kv -> kv.getValue() instanceof LifeCycleHook)
.map(kv -> (LifeCycleHook) kv.getValue())
.collect(Collectors.toList());
+ // process declarative traversalSources from YAML config - track which
graphs have explicit entries
Review Comment:
Are we allowing both script and declarative configurations to live in the
same yaml? If so, is that a sharp edge that might mess someone up?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]