This is an example project that shows one way to build a RESTful Java web app around Titan, Cassandra, and Elasticsearch.
Cassandra is used in Remote Server Mode. Elasticsearch is used remotely as well.
The "web portion" of the application is built using Spring (with annotations based config), JAX-RS, and Jersey. It is assumed that you are already familiar with these technologies.
This project also shows how Groovy classes can be injected into a Java web app to enable Gremlin Groovy sweetness. (See GroovyGraphOp.groovy.)
The Graph of the Gods example data set is used.
A Servlet Filter is used to show how TitanGraph transactions can be managed with pre/post request Filters.
A Vagrant box is provided that hosts Cassandra and Elasticsearch.
This project is built against Titan 0.5.0. and TinkerPop 2.5.0.
If you prefer to install Cassandra and Elasticsearch manually then skip the first 3 steps but make sure you adjust the titan-cassandra-es.properties file's host values accordingly. You can use the Vagrant file and bootstrap script for installation information.
-
Install Virtual Box (because you need it for Vagrant).
-
Install Vagrant.
-
Vagrant up! This will start a VM that has compatible versions of Cassandra and Elasticsearch running. The host IP is 10.10.10.10. The VM also contains a Titan distribution with a pre-configured titan-cassandra-es.properties file that you can use for local gremlin shell access. (The Titan distro isn't actually used by the web app at all.)
cd titan-web-example/vagrant; vagrant up
-
Load the project in your favorite IDE (or compile and run the following via mvn).
-
Run the classesthatrunthings.PopulateDB class. This will load the "Graph of the Gods" example data set.
-
Run the classesthatrunthings.RunApp class. This will launch the web app in an embedded Jetty container.
-
Visit http://localhost:9091
Try the links. If they work then you're ready to dig in to the code and see what's happening. The TitanWebService class is a great place to start.
http://thinkaurelius.com/blog/
Q&A happens in the Aurelius Google Group or on http://stackoverflow.com. If you have questions then those are the best places to search first.