[TinkerPop3] Gremlin Server REST API

2,118 views
Skip to first unread message

Stephen Mallette

unread,
Nov 5, 2014, 8:06:36 AM11/5/14
to gremli...@googlegroups.com
We've been saying for some time now that Gremlin Server would not have a REST API as it typically doesn't represent the right pattern for graph access and remote Gremlin processing.  I think that still holds true for many use cases, however, the composability of Netty channel pipelines and the abstractions built into Gremlin Server made the code base for creating a simple REST API akin to Rexster's Gremlin Extension (https://github.com/tinkerpop/rexster/wiki/Gremlin-Extension) fairly straightforward.  

The soon to be released M5 of TinkerPop3 will include this feature in Gremlin Server which basically allows it to be configured to expose a single REST endpoint which processes Gremlin scripts (and bindings) such that you can do:


This feature should help those trying to transition from Rexster (assuming you were using the REST Gremlin Extension) and provide support for tools like Bulbs which relied on that extension for most of its operations.

You can read more about this feature here:


Enjoy!

Stephen

Jean-Baptiste Musso

unread,
Nov 5, 2014, 9:12:48 AM11/5/14
to gremli...@googlegroups.com
This is very cool, thanks Stephen! This will definitely make the transition easier, as well as allow support of older browsers for JavaScript clients.

Just a thought regarding the risk of OutOfMemoryError mentioned in the documentation, would it be possible to have Gremlin Server i) start writing the HTTP response just as it starts iterating through the first result, and then ii) end/finalize the response after the last iteration? This would somehow mimic WebSocket's streaming mode, lower the memory usage, and allow the client to start parsing the JSON result just as it is being streamed from Gremlin Server. Unsure if this is overcomplicated given the current architecture.

Cheers,

Jean-Baptiste

Stephen Mallette

unread,
Nov 5, 2014, 9:27:39 AM11/5/14
to gremli...@googlegroups.com
I had something similar to that idea in the Faunus Rexster Extension.  As I recall, as it iterated it serialized, directly to stream one object at a time.  I guess that could be done with Gremlin Server though you would then have a different model from Rexster's Gremlin Extension (i was trying to mimic that).  We would probably have to write a different serialization method and some special handlers for the channel pipeline for that to all work.  So, I guess the short answer is that it is likely possible, but requires more code when we already have a WebSocket approach that handles that scenario.  Perhaps we can solve all of this stuff with an HTTP2 channelizer at some point in the future.


--
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-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/31914c04-234b-4b3e-9c47-04d1a55a92c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Javid Ahammed

unread,
Oct 19, 2015, 6:29:15 AM10/19/15
to Gremlin-users
I have started the gremlin server with HTTP HttpChannelizer and I am able to run http://localhost:8182?gremlin=1+1 and it's giving the results,but when I try http://localhost:8182?gremlin=g.V() it's giving {"message": "Error encountered evaluating script: script=g.V()"}.Do we have any document on the Gremlin ReST APIs ?

Regards
Javid

Jason Plurad

unread,
Oct 19, 2015, 7:17:26 AM10/19/15
to Gremlin-users
The TinkerPop3 documentation on the Gremlin Server configured with REST are located here http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#_connecting_via_rest

If you're getting an error on g.V(), most likely your gremlin-server.yaml isn't configured with a global binding for the GraphTraversalSource g. Check out how conf/gremlin-server-rest-modern.yaml does it with a initialization script, scripts/generate-modern.groovy. You can find some discussion about the initialization script here http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#connecting-via-console

If you're using Titan, you should check out the configuration there to ensure that you're leveraging Titan's mappers for serialization. Here is an example from Titan. You can find discussion about the serialization configuration here http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#_serialization_2

Javid Ahammed

unread,
Oct 19, 2015, 9:06:09 AM10/19/15
to Gremlin-users
Thanks a lot Mr.Jason

I had gone throgh the same documentation you had suggested,I think I missed the script part.Nw I checked the script directory,Couldn't find the generate-modern.groovy file .
I added it from the link you have given.I commented the following part as I am loading a graph throgh "graphs: {  graph: conf/titan-cassandra.properties}|

/*globals << [hook : [
  onStartUp: { ctx ->
    ctx.logger.info("Loading 'modern' graph data.")
    TinkerFactory.generateClassic(graph)
  }*/

After running " bin/gremlin-server.sh conf/gremlin-server/gremlin-server-rest-modern.yaml " I am able to get the list of strings by " g.V().values('name') " ,But When I run g.V() ,it's giving serialization exception https://gist.github.com/JavidGit/ad46400f005b7a7db5a2


Regards
Javid

Javid Ahammed

unread,
Oct 19, 2015, 9:43:16 AM10/19/15
to Gremlin-users
Wow! 

It's all working fine now

I didn't read abt the Serialization you had mentioned,Sorry.

Will try to put up a step by step tutorial to make the Gremlin ReST to work with the titan-1.0.0-hadoop1 

Regards
Javid
Reply all
Reply to author
Forward
0 new messages