I am having a series of nonsensical issues that are driving me nuts. There are a couple of things I am trying to accomplish:
I am trying to set up my gremlin server to "load" a certain json
file that is in graphson
format, and getting really weird issues there that I will go into details about.
I am trying to run a simple ajax call to query that data, but - not only am I not able to get the data I want (which might make sense since gremlin refuses to load it), I seem to be getting some data that I have no idea where it comes from.
I am trying to figure out how to test the gremlin server on my terminal, but I cannot run a query because ./gremlin-server.sh status
returns Server not running
even though it is 100% running and my ajax call can see that.
To start up, I am running Gremlin v.3.4.3 and that can be found here. The command I use to run gremlin is
bin/gremlin-server.sh data/gremlin-server-rest-modern.yaml
Te yaml file comes with the Gremlin Server downloads, the contents of which are:
#...license stuff...
host: localhost
port: 8182
scriptEvaluationTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer
graphs: {
graph: conf/tinkergraph-empty.properties}
scriptEngines: {
gremlin-groovy: {
plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]},
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/generate-modern.groovy]}}}}
serializers:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0] }} # application/json
metrics: {
slf4jReporter: {enabled: true, interval: 180000}}
strictTransactionManagement: false
maxInitialLineLength: 4096
maxHeaderSize: 8192
maxChunkSize: 8192
maxContentLength: 65536
maxAccumulationBufferComponents: 1024
resultIterationBatchSize: 64
Now, as I understand it, the important thing to note is the component graph
that leads to a properties
file. The properties file I am loading is tinkergraph-empty.properties
, the contents of which are:
gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
gremlin.tinkergraph.vertexIdManager=LONG
The file name, tinkergraph-empty
, alludes to something important: the gremlin server will not load a graph. Cool - when I start the gremlin server, it loads up normally with results that I can expect:
[INFO] GremlinServer - Configuring Gremlin Server from ./conf/gremlin-server-rest-modern.yaml
[INFO] MetricManager - Configured Metrics Slf4jReporter configured with interval=180000ms and loggerName=org.apache.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics
[INFO] DefaultGraphManager - Graph [graph] was successfully configured via [conf/tinkergraph-empty.properties].
[INFO] ServerGremlinExecutor - Initialized Gremlin thread pool. Threads in pool named with pattern gremlin-*
[INFO] ServerGremlinExecutor - Initialized GremlinExecutor and preparing GremlinScriptEngines instances.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/Users/<user>/apache-tinkerpop-gremlin-server-3.4.3/lib/groovy-2.5.7-indy.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] ServerGremlinExecutor - Initialized gremlin-groovy GremlinScriptEngine and registered metrics
[INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
[INFO] OpLoader - Adding the standard OpProcessor.
[INFO] OpLoader - Adding the session OpProcessor.
[INFO] OpLoader - Adding the traversal OpProcessor.
[INFO] TraversalOpProcessor - Initialized cache for TraversalOpProcessor with size 1000 and expiration time of 600000 ms
[INFO] GremlinServer - Executing start up LifeCycleHook
[INFO] Logger$info - Loading 'modern' graph data.
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v3.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0
[INFO] AbstractChannelizer - Configured application/json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0
[INFO] GremlinServer$1 - Gremlin Server configured with worker thread pool of 1, gremlin pool of 8 and boss thread pool of 1.
[INFO] GremlinServer$1 - Channel started at port 8182.
This line, specifically, is promising: [INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
The graph it "loads" (I am assuming it must initialize a graph) has zero vertices and edges.
When I run my ajax call, which as I promised, I will get into later, I successfully POST to the server. It's up and running. All is well.
However...
When I change the tinkerpop-empty.properties
folder to load a graph, things get really weird. I am going to change it as such:
gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
gremlin.tinkergraph.vertexIdManager=LONG
gremlin.tinkergraph.graphLocation=data/tinkerpop-crew.json
gremlin.tinkergraph.graphFormat=graphson
I now loaded up a data folder called tinkerpop-crew.json
and added a graphFormat: graphson
. This should be correct. json file can be found here, and the properties file follows the format of this file.
Now, when I run this, I get a much different result:
[INFO] GremlinServer - Configuring Gremlin Server from ./conf/gremlin-server-rest-modern.yaml
[INFO] MetricManager - Configured Metrics Slf4jReporter configured with interval=180000ms and loggerName=org.apache.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics
[INFO] DefaultGraphManager - Graph [graph] was successfully configured via [conf/tinkergraph-empty.properties].
[INFO] ServerGremlinExecutor - Initialized Gremlin thread pool. Threads in pool named with pattern gremlin-*
[INFO] ServerGremlinExecutor - Initialized GremlinExecutor and preparing GremlinScriptEngines instances.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/Users/xbbn1xn/apache-tinkerpop-gremlin-server-3.4.3/lib/groovy-2.5.7-indy.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] ServerGremlinExecutor - Initialized gremlin-groovy GremlinScriptEngine and registered metrics
[INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:6 edges:14], standard]
[INFO] OpLoader - Adding the standard OpProcessor.
[INFO] OpLoader - Adding the session OpProcessor.
[INFO] OpLoader - Adding the traversal OpProcessor.
[INFO] TraversalOpProcessor - Initialized cache for TraversalOpProcessor with size 1000 and expiration time of 600000 ms
[INFO] GremlinServer - Executing start up LifeCycleHook
[INFO] Logger$info - Loading 'modern' graph data.
[ERROR] GremlinServer - Gremlin Server Error
java.lang.IllegalArgumentException: Vertex with id already exists: 1
at org.apache.tinkerpop.gremlin.structure.Graph$Exceptions.vertexWithIdAlreadyExists(Graph.java:1196)
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph.addVertex(TinkerGraph.java:167)
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory.generateModern(TinkerFactory.java:90)
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory$generateModern.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
at Script1$_run_closure1.doCall(Script1.groovy:28)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
at groovy.lang.Closure.call(Closure.java:405)
at org.codehaus.groovy.runtime.ConvertedMap.invokeCustom(ConvertedMap.java:54)
at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:122)
at com.sun.proxy.$Proxy15.onStartUp(Unknown Source)
at org.apache.tinkerpop.gremlin.server.GremlinServer.lambda$start$1(GremlinServer.java:154)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.apache.tinkerpop.gremlin.server.GremlinServer.start(GremlinServer.java:151)
at org.apache.tinkerpop.gremlin.server.GremlinServer.main(GremlinServer.java:346)
[ERROR] GremlinServer - Gremlin Server was unable to start and will now begin shutdown: Vertex with id already exists: 1
[INFO] GremlinServer - Shutting down OpProcessor[]
[INFO] GremlinServer - Shutting down OpProcessor[session]
[INFO] GremlinServer - Shutting down OpProcessor[traversal]
[INFO] GremlinServer - Shutting down thread pools.
[INFO] GremlinServer - Executing shutdown LifeCycleHook
[INFO] GremlinServer - Closed Graph instance [graph]
[INFO] GremlinServer - Gremlin Server - shutdown complete
Huh? Vertex already exists? That's impossible. I have never even run this file, why would there even be any memory of it? As far as gremlin should be concerned, I have never even loaded a graph. Maybe it initiates a graph though and forgets to delete it from memory or something, right?
Well, let's make our own file and initialize just one Vertex and of some weird prime number and no edges. Let's call it tinkerpop-crew2.json
:
{"id":{"@type":"g:Int64","@value":47284629},"label":"person"}
.
Might not be prime. Whatever. Okay, awesome, that worked!
[INFO] GremlinServer - Configuring Gremlin Server from ./conf/gremlin-server-rest-modern.yaml
[INFO] MetricManager - Configured Metrics Slf4jReporter configured with interval=180000ms and loggerName=org.apache.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics
[INFO] DefaultGraphManager - Graph [graph] was successfully configured via [conf/tinkergraph-empty.properties].
[INFO] ServerGremlinExecutor - Initialized Gremlin thread pool. Threads in pool named with pattern gremlin-*
[INFO] ServerGremlinExecutor - Initialized GremlinExecutor and preparing GremlinScriptEngines instances.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/Users/xbbn1xn/apache-tinkerpop-gremlin-server-3.4.3/lib/groovy-2.5.7-indy.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] ServerGremlinExecutor - Initialized gremlin-groovy GremlinScriptEngine and registered metrics
[INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:1 edges:0], standard]
[INFO] OpLoader - Adding the standard OpProcessor.
[INFO] OpLoader - Adding the session OpProcessor.
[INFO] OpLoader - Adding the traversal OpProcessor.
[INFO] TraversalOpProcessor - Initialized cache for TraversalOpProcessor with size 1000 and expiration time of 600000 ms
[INFO] GremlinServer - Executing start up LifeCycleHook
[INFO] Logger$info - Loading 'modern' graph data.
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v3.0+json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0
[INFO] AbstractChannelizer - Configured application/json with org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0
[INFO] GremlinServer$1 - Gremlin Server configured with worker thread pool of 1, gremlin pool of 8 and boss thread pool of 1.
[INFO] GremlinServer$1 - Channel started at port 8182.
Pay attention here: [INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:1 edges:0], standard]
. One vertice.
What happens when we th server configured to use this file again?
[INFO] GremlinServer - Configuring Gremlin Server from ./conf/gremlin-server-rest-modern.yaml
[INFO] MetricManager - Configured Metrics Slf4jReporter configured with interval=180000ms and loggerName=org.apache.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics
[INFO] DefaultGraphManager - Graph [graph] was successfully configured via [conf/tinkergraph-empty.properties].
[INFO] ServerGremlinExecutor - Initialized Gremlin thread pool. Threads in pool named with pattern gremlin-*
[INFO] ServerGremlinExecutor - Initialized GremlinExecutor and preparing GremlinScriptEngines instances.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/Users/xbbn1xn/apache-tinkerpop-gremlin-server-3.4.3/lib/groovy-2.5.7-indy.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] ServerGremlinExecutor - Initialized gremlin-groovy GremlinScriptEngine and registered metrics
[INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:7 edges:6], standard]
[INFO] OpLoader - Adding the standard OpProcessor.
[INFO] OpLoader - Adding the session OpProcessor.
[INFO] OpLoader - Adding the traversal OpProcessor.
[INFO] TraversalOpProcessor - Initialized cache for TraversalOpProcessor with size 1000 and expiration time of 600000 ms
[INFO] GremlinServer - Executing start up LifeCycleHook
[INFO] Logger$info - Loading 'modern' graph data.
[ERROR] GremlinServer - Gremlin Server Error
java.lang.IllegalArgumentException: Vertex with id already exists: 1
at org.apache.tinkerpop.gremlin.structure.Graph$Exceptions.vertexWithIdAlreadyExists(Graph.java:1196)
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph.addVertex(TinkerGraph.java:167)
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory.generateModern(TinkerFactory.java:90)
at org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory$generateModern.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:127)
at Script1$_run_closure1.doCall(Script1.groovy:28)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
at groovy.lang.Closure.call(Closure.java:405)
at org.codehaus.groovy.runtime.ConvertedMap.invokeCustom(ConvertedMap.java:54)
at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:122)
at com.sun.proxy.$Proxy15.onStartUp(Unknown Source)
at org.apache.tinkerpop.gremlin.server.GremlinServer.lambda$start$1(GremlinServer.java:154)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.apache.tinkerpop.gremlin.server.GremlinServer.start(GremlinServer.java:151)
at org.apache.tinkerpop.gremlin.server.GremlinServer.main(GremlinServer.java:346)
[ERROR] GremlinServer - Gremlin Server was unable to start and will now begin shutdown: Vertex with id already exists: 1
[INFO] GremlinServer - Shutting down OpProcessor[]
[INFO] GremlinServer - Shutting down OpProcessor[session]
[INFO] GremlinServer - Shutting down OpProcessor[traversal]
[INFO] GremlinServer - Shutting down thread pools.
[INFO] GremlinServer - Executing shutdown LifeCycleHook
[INFO] GremlinServer - Closed Graph instance [graph]
[INFO] GremlinServer - Gremlin Server - shutdown complete
Same error as before. What the hell is going on here? There are also two things that catch my eye:
ERROR] GremlinServer - Gremlin Server Error
java.lang.IllegalArgumentException: Vertex with id already exists: 1
. Is it saying that only one vertex exists, or the vertex with ID '1' exists? Because none of my vertices have an ID of one. That is, until...
You notice that this is not even loading my file! [INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:7 edges:6], standard]
. My file does not have 7 vertices and 6 edges. It has 1 vertex and 0 edges. This actually looks suspiciously like it's loading the original tinkerpop-crew.json
file, or something similar, even though when we originally loaded it, the INFO message said: [INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:6 edges:14], standard]
.
Okay, so I have no idea what is going on here.
I have a really, really simple query that I run and post using an AJAX call:
$.ajax({
type: "POST",
accept: "application/json",
url: url // http://localhost:8182,
timeout: timeout // I have it set to 3500,
data: JSON.stringify({"gremlin" : q}),
success: function(data, textStatus, jqXHR){
var retrvData = data.result.data;
console.log(retrvData)
}
Okay, so a couple of important things. The q
variable is a query that I send to the Gremlin server to return some data, and it looks like this:
q = 'nodes = g.V().limit(15).toList();edges = g.V(nodes).aggregate('node').outE().as('edge').inV().where(within('node')).select('edge').toList();[nodes,edges]'
This query should essentially return a list of nodes and edges. Now, there are three cases I want to go over:
The first case is using the unaltered tinkerpop-empty.properties file. Remember, when I loaded that, I got output that said:
[INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
That means there should be no information in the tinkergraph. I should receive an empty list. However, when I run my call, I get this:
value: Array(2)
0: Array(7)
0: {id: 1, label: "person", type: "vertex"}
1: {id: 2, label: "person", type: "vertex"}
2: {id: 3, label: "software", type: "vertex"}
3: {id: 47284629, label: "person", type: "vertex"}
4: {id: 4, label: "person", type: "vertex"}
5: {id: 5, label: "software", type: "vertex"}
6: {id: 6, label: "person", type: "vertex"}
length: 7
__proto__: Array(0)
1: Array(6)
0: {id: 9, label: "created", inVLabel: "software", outVLabel: "person", inV: 3, …}
1: {id: 7, label: "knows", inVLabel: "person", outVLabel: "person", inV: 2, …}
2: {id: 8, label: "knows", inVLabel: "person", outVLabel: "person", inV: 4, …}
3: {id: 10, label: "created", inVLabel: "software", outVLabel: "person", inV: 5, …}
4: {id: 11, label: "created", inVLabel: "software", outVLabel: "person", inV: 3, …}
5: {id: 12, label: "created", inVLabel: "software", outVLabel: "person", inV: 3, …}
length: 6
This is the output in the developer console (from console.log(retrvData)). There are all kinds of data. And look, the length of the nodes is 7, and the edges is 6. Sound familiar? Why is gremlin loading this data? Why is it sending it to my ajax query?
Okay, whatever. Let's run the next properties
file. Remember, we are using tinkerpop-crew.json
now with the graphFormat set to graphson.
I get the same error that I got before, of course, which is java.lang.IllegalArgumentException: Vertex with id already exists: 1
. My server also shuts down:
[ERROR] GremlinServer - Gremlin Server was unable to start and will now begin shutdown: Vertex with id already exists: 1
[INFO] GremlinServer - Shutting down OpProcessor[]
[INFO] GremlinServer - Shutting down OpProcessor[session]
[INFO] GremlinServer - Shutting down OpProcessor[traversal]
[INFO] GremlinServer - Shutting down thread pools.
[INFO] GremlinServer - Executing shutdown LifeCycleHook
[INFO] GremlinServer - Closed Graph instance [graph]
[INFO] GremlinServer - Gremlin Server - shutdown complete
Let's go to my AJAX query and see what we get.
Nothing, of course. My gremlin server crashed. It seems like it could be loading the correct file, since the INFO log says A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:6 edges:14], standard]
. I haven't verified that this is correct... it's not that easy.
The first time we ran tinkerpop-crew2.json
, things went well. We changed the ID to some weird number and didn't get an exception thrown. Also, the graph seemed to load the correct stuff. Let's run it again now, and change the ID to 4724729456382
.
Okay, wow, I am typing this as I go, and look what I just found:
{"id":{"@type":"g:Int64","@value":1},"label":"person","outE":{"created":[{"id":{"@type":"g:Int32","@value":9},"inV":{"@type":"g:Int64","@value":3},"properties":{"weight":{"@type":"g:Double","@value":0.4}}}],"knows":[{"id":{"@type":"g:Int32","@value":7},"inV":{"@type":"g:Int64","@value":2},"properties":{"weight":{"@type":"g:Double","@value":0.5}}},{"id":{"@type":"g:Int32","@value":8},"inV":{"@type":"g:Int64","@value":4},"properties":{"weight":{"@type":"g:Double","@value":1.0}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],"age":[{"id":{"@type":"g:Int64","@value":2},"value":{"@type":"g:Int32","@value":29}}]}}
{"id":{"@type":"g:Int64","@value":2},"label":"person","inE":{"knows":[{"id":{"@type":"g:Int32","@value":7},"outV":{"@type":"g:Int64","@value":1},"properties":{"weight":{"@type":"g:Double","@value":0.5}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":3},"value":"vadas"}],"age":[{"id":{"@type":"g:Int64","@value":4},"value":{"@type":"g:Int32","@value":27}}]}}
{"id":{"@type":"g:Int64","@value":3},"label":"software","inE":{"created":[{"id":{"@type":"g:Int32","@value":9},"outV":{"@type":"g:Int64","@value":1},"properties":{"weight":{"@type":"g:Double","@value":0.4}}},{"id":{"@type":"g:Int32","@value":11},"outV":{"@type":"g:Int64","@value":4},"properties":{"weight":{"@type":"g:Double","@value":0.4}}},{"id":{"@type":"g:Int32","@value":12},"outV":{"@type":"g:Int64","@value":6},"properties":{"weight":{"@type":"g:Double","@value":0.2}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":5},"value":"lop"}],"lang":[{"id":{"@type":"g:Int64","@value":6},"value":"java"}]}}
{"id":{"@type":"g:Int64","@value":4},"label":"person","inE":{"knows":[{"id":{"@type":"g:Int32","@value":8},"outV":{"@type":"g:Int64","@value":1},"properties":{"weight":{"@type":"g:Double","@value":1.0}}}]},"outE":{"created":[{"id":{"@type":"g:Int32","@value":10},"inV":{"@type":"g:Int64","@value":5},"properties":{"weight":{"@type":"g:Double","@value":1.0}}},{"id":{"@type":"g:Int32","@value":11},"inV":{"@type":"g:Int64","@value":3},"properties":{"weight":{"@type":"g:Double","@value":0.4}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":7},"value":"josh"}],"age":[{"id":{"@type":"g:Int64","@value":8},"value":{"@type":"g:Int32","@value":32}}]}}
{"id":{"@type":"g:Int64","@value":5},"label":"software","inE":{"created":[{"id":{"@type":"g:Int32","@value":10},"outV":{"@type":"g:Int64","@value":4},"properties":{"weight":{"@type":"g:Double","@value":1.0}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":9},"value":"ripple"}],"lang":[{"id":{"@type":"g:Int64","@value":10},"value":"java"}]}}
{"id":{"@type":"g:Int64","@value":6},"label":"person","outE":{"created":[{"id":{"@type":"g:Int32","@value":12},"inV":{"@type":"g:Int64","@value":3},"properties":{"weight":{"@type":"g:Double","@value":0.2}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":11},"value":"peter"}],"age":[{"id":{"@type":"g:Int64","@value":12},"value":{"@type":"g:Int32","@value":35}}]}}
{"id":{"@type":"g:Int64","@value":47284629},"label":"person"}
This is now the contents of my tinkerpop-crew2.json
! What is going on here? Why did the gremlin-server dump information to that file? If you see the last line, it has what was the original content of the file:
{"id":{"@type":"g:Int64","@value":47284629},"label":"person"}
Okay, really, @tinkerpop, what the hell?
I guess it now makes sense why when I ran the file the second time, it threw that error again and said that the vertex with id 1 was already existing!
Hilariously, I digress! Let us delete the unoriginal portion of that file and just run it with:
{"id":{"@type":"g:Int64","@value":47284629},"label":"person"}
Okay, that ran fine with the correct INFO that I should be expecting: [INFO] ServerGremlinExecutor - A GraphTraversalSource is now bound to [g] with graphtraversalsource[tinkergraph[vertices:1 edges:0], standard]
.
Now, let's run that AJAX call...
Gahh!! Same thing!!
value: Array(2)
0: Array(7)
0: {id: 1, label: "person", type: "vertex"}
1: {id: 2, label: "person", type: "vertex"}
2: {id: 3, label: "software", type: "vertex"}
3: {id: 47284629, label: "person", type: "vertex"}
4: {id: 4, label: "person", type: "vertex"}
5: {id: 5, label: "software", type: "vertex"}
6: {id: 6, label: "person", type: "vertex"}
length: 7
__proto__: Array(0)
1: Array(6)
0: {id: 9, label: "created", inVLabel: "software", outVLabel: "person", inV: 3, …}
1: {id: 7, label: "knows", inVLabel: "person", outVLabel: "person", inV: 2, …}
2: {id: 8, label: "knows", inVLabel: "person", outVLabel: "person", inV: 4, …}
3: {id: 10, label: "created", inVLabel: "software", outVLabel: "person", inV: 5, …}
4: {id: 11, label: "created", inVLabel: "software", outVLabel: "person", inV: 3, …}
5: {id: 12, label: "created", inVLabel: "software", outVLabel: "person", inV: 3, …}
length: 6
Notice how the nodes list is of length 7 and the edges is of lenth 6! Assuming it was loading something, for example, and appending my file, it should be node length 8 and edge length 7! What's going on here?
The solution was to go into scripts/generate-modern.groovy
and comment out these lines:
globals << [hook : [
onStartUp: { ctx ->
ctx.logger.info("Loading 'modern' graph data.")
org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory.generateModern(graph)
}
] as LifeCycleHook]
I think things start to go wrong for you here:
When I change the tinkerpop-empty.properties folder to load a graph, things get really weird. I am going to change it as such:
gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph gremlin.tinkergraph.vertexIdManager=LONG gremlin.tinkergraph.graphLocation=data/tinkerpop-crew.json gremlin.tinkergraph.graphFormat=graphson
You get the error that you do because you're missing the fact that the Gremlin Server initialization script is running - this line in your yaml:
https://github.com/apache/tinkerpop/blob/3.4.3/gremlin-server/conf/gremlin-server-rest-modern.yaml
so that is trying to load the "modern" graph into a graph that you're trying to specify as the "crew" graph (or the other way around, i can't remember which loads first but I think I got that right). The solution is to either:
scripts/generate-modern.groovy
and keep your properties file as is ORscripts/generate-modern.groovy
init script to just load the "crew" data and leave the properties file unchanged to have an empty graph.You have a long list of other odds/ends that looked weird, but I wonder how much of it stems from missing the init file and what it's doing to you "behind your back". Does this knowledge help solve all of your issues? If not, let me know what is still amiss and I can try to help resolve it.