Skip to content

Commit

Permalink
Set up all graphs for server
Browse files Browse the repository at this point in the history
  • Loading branch information
ryn5 committed Apr 25, 2024
1 parent 802ed4f commit 2127805
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
64 changes: 64 additions & 0 deletions gremlin-server/conf/gremlin-server-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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.

host: 0.0.0.0
port: 45940
evaluationTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer
graphs: {
graph: conf/tinkergraph-service.properties,
immutable: conf/tinkergraph-service.properties,
classic: conf/tinkergraph-service.properties,
modern: conf/tinkergraph-service.properties,
crew: conf/tinkergraph-service.properties,
grateful: conf/tinkergraph-service.properties,
sink: conf/tinkergraph-service.properties,
tx: conf/tinkertransactiongraph-service.properties
}
scriptEngines: {
gremlin-lang : {},
gremlin-groovy: {
plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyCompilerGremlinPlugin: {expectedCompilationTime: 30000},
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]},
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-all.groovy]}}}}
serializers:
- { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4 }
- { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4, config: { serializeResultToString: true }}
- { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1, config: { serializeResultToString: true }}
- { className: org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV4, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3] }}
- { className: org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV3, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3] }}
- { className: org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV2, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2] }}
- { className: org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV1, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1] }}
#processors:
# - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
# - { className: org.apache.tinkerpop.gremlin.server.op.standard.StandardOpProcessor, config: {}}
metrics: {
slf4jReporter: {enabled: true, interval: 180000}}
gremlinPool: 8
strictTransactionManagement: false
idleConnectionTimeout: 0
keepAliveInterval: 0
maxInitialLineLength: 4096
maxHeaderSize: 8192
maxChunkSize: 8192
maxContentLength: 10485760
maxAccumulationBufferComponents: 1024
resultIterationBatchSize: 64
writeBufferLowWaterMark: 32768
writeBufferHighWaterMark: 65536
72 changes: 72 additions & 0 deletions gremlin-server/scripts/generate-all.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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.
*/

// An example of an initialization script that can be configured to run in Gremlin Server.
// Functions defined here will go into global cache and will not be removed from there
// unless there is a reset of the ScriptEngine.
def addItUp(x, y) { x + y }

// an init script that returns a Map allows explicit setting of global bindings.
def globals = [:]

// Generates the modern graph into an "empty" TinkerGraph via LifeCycleHook.
// Note that the name of the key in the "global" map is unimportant.
globals << [hook : [
onStartUp: { ctx ->
// a wild bit of trickery here. the process tests use an INTEGER id manager when LoadGraphWith is used. this
// closure provides a way to to manually override the various id managers for TinkerGraph - the graph on which
// all of these remote tests are executed - so that the tests will pass nicely. an alternative might have been
// to have a special test TinkerGraph config for setting up the id manager properly, but based on how we do
// things now, that test config would have been mixed in with release artifacts and there would have been ugly
// exclusions to make packaging work properly.
allowSetOfIdManager = { graph, idManagerFieldName, idManager ->
java.lang.reflect.Field idManagerField = graph.class.getSuperclass().getDeclaredField(idManagerFieldName)
idManagerField.setAccessible(true)
idManagerField.set(graph, idManager)
}

[classic, modern, crew, sink, grateful].each{
allowSetOfIdManager(it, "vertexIdManager", TinkerGraph.DefaultIdManager.INTEGER)
allowSetOfIdManager(it, "edgeIdManager", TinkerGraph.DefaultIdManager.INTEGER)
allowSetOfIdManager(it, "vertexPropertyIdManager", TinkerGraph.DefaultIdManager.LONG)
}
TinkerFactory.generateClassic(classic)
TinkerFactory.generateModern(modern)
TinkerFactory.generateTheCrew(crew)
TinkerFactory.generateGratefulDead(grateful)
TinkerFactory.generateKitchenSink(sink)
}
] as LifeCycleHook]

// add default TraversalSource instances for each graph instance
globals << [gclassic : traversal().withEmbedded(classic)]
globals << [gmodern : traversal().withEmbedded(modern)]
globals << [g : traversal().withEmbedded(graph)]
globals << [gcrew : traversal().withEmbedded(crew)]
globals << [ggraph : traversal().withEmbedded(graph)]
globals << [ggrateful : traversal().withEmbedded(grateful)]
globals << [gsink : traversal().withEmbedded(sink)]
globals << [gtx : traversal().withEmbedded(tx)]

// dynamically detect existence of gimmutable as it is only used in gremlin-go testing suite
def dynamicGimmutable = context.getBindings(javax.script.ScriptContext.GLOBAL_SCOPE)["immutable"]
if (dynamicGimmutable != null)
globals << [gimmutable : traversal().withEmbedded(dynamicGimmutable)]

globals

0 comments on commit 2127805

Please sign in to comment.