[[], [V(), propertyMap()]]
java.lang.NullPointerException\n\tat org.apache.tinkerpop.gremlin.structure.io.graphson.TraversalSerializersV2d0$BytecodeJacksonDeserializer.deserialize(TraversalSerializersV2d0.java:263)\n\tat org.apache.tinkerpop.gremlin.structure.io.graphson.TraversalSerializersV2d0$BytecodeJacksonDeserializer.deserialize(TraversalSerializersV2d0.java:250)\n\tat org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypeDeserializer.deserialize(GraphSONTypeDeserializer.java:212)\n\tat org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypeDeserializer.deserializeTypedFromAny(GraphSONTypeDeserializer.java:101)\n\tat org.apache.tinkerpop.shaded.jackson.databind.deser.std.StdDeserializer.deserializeWithType(StdDeserializer.java:120)\n\tat org.apache.tinkerpop.shaded.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:63)\n\tat org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
While I understand aliases, (and I'm familiar with docs you point out) I'm still non the wiser as to why I need them
host: localhost
port: 8182
scriptEvaluationTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {
graph: conf/tinkergraph-empty.properties,
graph2: conf/tinkergraph-empty.properties}
scriptEngines: {
[.... same as default]// an init script that returns a Map allows explicit setting of global bindings.
def globals = [:]
// defines a sample LifeCycleHook that prints some output to the Gremlin Server console.
// note that the name of the key in the "global" map is unimportant.
globals << [hook : [
onStartUp: { ctx ->
ctx.logger.info("Executed once at startup of Gremlin Server.")
// populate graph2 with the "modern" graph
org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory.generateModern(graph2)
},
onShutDown: { ctx ->
ctx.logger.info("Executed once at shutdown of Gremlin Server.")
}
] as LifeCycleHook]
// define two traversal sources in the server
globals << [g1 : graph.traversal()]
globals << [g2 : graph2.traversal()]
gremlin> cluster = Cluster.open()
==>localhost/127.0.0.1:8182
gremlin> client = cluster.connect()
==>org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient@5eb97ced
gremlin> clientg1 = client.alias("g1")
==>org.apache.tinkerpop.gremlin.driver.Client$AliasClusteredClient@57c88764
gremlin> clientg2 = client.alias("g2")
==>org.apache.tinkerpop.gremlin.driver.Client$AliasClusteredClient@43effd89
gremlin> g = EmptyGraph.INSTANCE.traversal()
==>graphtraversalsource[emptygraph[empty], standard]
gremlin> clientg1.submit(g.V().count()).all().get()
==>result{object=0 class=org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser}
gremlin> clientg2.submit(g.V().count()).all().get()
==>result{object=6 class=org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser}
gremlin> cluster = Cluster.open()
==>localhost/127.0.0.1:8182
gremlin> g1 = EmptyGraph.INSTANCE.traversal().withRemote(DriverRemoteConnection.using(cluster, "g1"))
==>graphtraversalsource[emptygraph[empty], standard]
gremlin> g2 = EmptyGraph.INSTANCE.traversal().withRemote(DriverRemoteConnection.using(cluster, "g2"))
==>graphtraversalsource[emptygraph[empty], standard]
gremlin> g1.V().count()
==>0
gremlin> g2.V().count()
==>6the Gremlin Server will use the "alias" argument in the Request Message to determine which traversal source defined in the gremlin server to use
A map with a single key/value pair that refers to a globally bound TraversalSource object to be aliased to different variable names for purposes of the current request. The value represents the name of the global variable and its key represents the new binding name as it will be referenced in the Gremlin query.
globals << [g : graph.traversal()]A message with [bytecode] op code requires the [aliases] argument to be a Map containing one alias assignment named 'g'.
The value represents the name of the global variable
globals << [g : graph.traversal()]
# KEEP TRACK OF CURRENT DEFAULTS
DEFAULT_READER_CLASS = graphsonV3d0.GraphSONReader
DEFAULT_WRITER_CLASS = graphsonV3d0.GraphSONWriter
DEFAULT_VERSION = b"application/vnd.gremlin-v3.0+json"
def __init__(self, reader=None, writer=None, version=None):
if not version:
version = self.DEFAULT_VERSION
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/747aa1f3-b1b5-4ad4-88c0-facc4bd10978%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
If you're using TinkerPop 3.2.5, then you should use GraphSON 2.0. If you're using TinkerPop 3.3.0, then you should use GraphSON 3.0. I believe both Gremlin Servers are preconfigured and ready to go with the correct serializers.Let's take python on 3.3.0:graph = Graph()g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))g.V().toList()It sends the following to the server:!application/vnd.gremlin-v3.0+json{"op": "bytecode", "requestId": {"@type": "g:UUID", "@value": "1ff5ff44-af1a-4e06-be13-5df1f1a11c8c"}, "args": {"gremlin": {"@type": "g:Bytecode", "@value": {"step": [["V"]]}}, "aliases": {"g": "g"}}, "processor": "traversal"}
Robert Dale
If I change scripts/empty-sample.groovy:globals << [server1 : graph.traversal()]Then I have to update python:g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','server1'))Finally, it sends:"aliases": {"g": "server1"}
Robert Dale
On Tue, Nov 7, 2017 at 8:06 AM, Robert Dale <rob...@gmail.com> wrote:
If you're using TinkerPop 3.2.5, then you should use GraphSON 2.0. If you're using TinkerPop 3.3.0, then you should use GraphSON 3.0. I believe both Gremlin Servers are preconfigured and ready to go with the correct serializers.Let's take python on 3.3.0:graph = Graph()g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))g.V().toList()It sends the following to the server:!application/vnd.gremlin-v3.0+json{"op": "bytecode", "requestId": {"@type": "g:UUID", "@value": "1ff5ff44-af1a-4e06-be13-5df1f1a11c8c"}, "args": {"gremlin": {"@type": "g:Bytecode", "@value": {"step": [["V"]]}}, "aliases": {"g": "g"}}, "processor": "traversal"}
Robert Dale
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/4e4a3f55-5bd4-494a-817c-202c0b575e89%40googlegroups.com.
Robert Dale
One anomaly I've noticed is that when the server code borks, it's in GraphSON2 code
Just on the point of serialising requests to GraphSON: is it only necessary for bytecode submissions? Because I don't serialize any of my other request messages through GraphSON, and they all work as expected.
def count1 = aliasedSource1.V().count().next();
def count2 = aliasedSource2.V().count().next();
[count1, count2]gremlin> cluster = Cluster.open()
==>localhost/127.0.0.1:8182
gremlin> client = cluster.connect()
==>org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient@5eb97ced
gremlin> clientWithAliases = client.alias(['aliasedSource1':'g1', 'aliasedSource2':'g2'])
==>org.apache.tinkerpop.gremlin.driver.Client$AliasClusteredClient@57c88764
gremlin> clientWithAliases.submit('def count1 = aliasedSource1.V().count().next(); def count2 = aliasedSource2.V().count().next(); [count1, count2]').all().get()
==>result{object=0 class=java.lang.Long}
==>result{object=6 class=java.lang.Long}
Also, just to confirm, Bytecode should not be serialised as GraphSON 3? Only as GraphSON 2
So what you send in the alias map of a bytecode request should always be ["theNameOfYourTraversalSource":"g"]
janus_1 | java.lang.NullPointerExceptionjanus_1 | at org.apache.tinkerpop.gremlin.structure.io.graphson.TraversalSerializersV2d0$BytecodeJacksonDeserializer.deserialize(TraversalSerializersV2d0.java:262)janus_1 | at org.apache.tinkerpop.gremlin.structure.io.graphson.TraversalSerializersV2d0$BytecodeJacksonDeserializer.deserialize(TraversalSerializersV2d0.java:250)janus_1 | at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypeDeserializer.deserialize(GraphSONTypeDeserializer.java:212)janus_1 | at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypeDeserializer.deserializeTypedFromAny(GraphSONTypeDeserializer.java:101)