spmallette commented on code in PR #3384:
URL: https://github.com/apache/tinkerpop/pull/3384#discussion_r3095147947
##########
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:
ok, it's probably fine for them to coexist as long as they don't introduce
unexpected problems or have some undocumented behavior. so, if one overwrites
the other or something then at least make sure that's clear in the docs. i
wouldn't be sad if the server refused to start and folks were forced into one
config path or the other, but i don't think it's essential.
--
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]