Titan Server is a light-weight server that manages remote connections to Titan and thereby allows applications to execute Gremlin queries against a Titan graph cluster. Titan Server builds on RexPro, a light-weight component of the Rexster Server which can efficiently handle hundreds of database connections.

Start Titan Server

To start the Titan Server, execute the titan.sh script in the bin folder of the Titan distribution (use .bat for Windows).

$ ./bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties

The script expects two arguments:

  1. A configuration file for the RexPro server. Refer to the RexPro section of the Rexster configuration documentation for more information on how to configure the RexPro connection manager of Titan Server. This first argument is optional and can be omitted, in which case default configurations are used for RexPro. Note that there is a sample Rexster configuration file in config/titan-server-rexster.xml.
  2. A configuration file for the Titan graph database. Refer to the Graph Configuration documentation for more information, but note that there is a sample configuration for embedded Cassandra in config/titan-server-cassandra.properties. This file points to the sample config/cassandra.yaml. Note that this file places data in /temp and therefore may be erased on reboot. Please edit these files as necessary when running Titan Server.

Once the server has been started, it can be terminated by pressing CTRL+C or sending the corresponding kill signal to the process.

Note – Rexster expects a graph name when connecting. While this is a configurable option in Rexster it is not so in Titan Server. The name of the graph will always be “graph” and must be referenced as such. This name may not be overridden.

Connecting to Titan Server

The client application can now connect to the Titan Server on the configured hostname and port to issue Gremlin queries using RexsterTitanClient.

RexsterTitanClient client = new RexsterTitanClient("127.0.0.1");
List<Map<String,Object>> result;
result = client.query("g.V('name','saturn').in('father').map");
// result.toString(): [{name="jupiter", type="god"}]

Map<String,Object> params = new HashMap<String,Object>();
params.put("name","saturn");
result = client.query("g.V('name',name).in('father').map",params);
client.close();

First above, a connection to the Titan Server is established. Gremlin queries are issued as strings using the RexsterTitanClient.query() methods. Each query is executed in its own transaction. Explicit transaction handling is not necessary. The result set is a list of query answers, where each query answer is represented as a map of key-value pairs. RexsterTitanClient provides additional query() methods where the signature of each query answer can be specified as a template. The second query is semantically identical to the first, but in this case we are passing in the name as a variable binding for the corresponding variable used in the query. Once all queries have been issued, the connection is closed.

Rexster Console

RexsterTitanClient is used to connect to Titan Server from within an application. Outside of an application, use the Rexster Console to connect to a Titan Server and issue Gremlin queries. Rexster Console provides access to a remote Gremlin REPL that is included in the Titan distribution. Download Rexster Console from the Rexster project

Start Rexster Console from the command line. The following assumes that Titan Server is running locally on the default port. To configure an alternative hostname or port, refer to the Rexster Console documentation

./bin/rexster-console.sh

Once the console has loaded, issue Gremlin queries against the Titan Server. There will be only one graph configured for the rexster context object and it is called “graph”. Note, that Rexster Console does not manage transactions as RexsterTitanClient does.

        (l_(l
(_______( 0 0
(        (-Y-) <woof>
l l-----l l
l l,,   l l,,
opening session with Rexster [localhost:8185]--> ready
?h for help

rexster[groovy]> g = rexster.getGraph("graph")
==>titangraph[cassandrathrift:127.0.0.1]
rexster[groovy]> g.V('name','saturn').name
==>saturn

Titan Embedding

Titan Server is most useful when Titan runs embedded with the storage backend of choice. Under such a deployment scenario, Titan, Rexster, and the storage backend run in the same JVM. This makes calls between the components very efficient and leads to the best performing setup. Refer to the documentation of the respective storage backends for information on how to run Titan embedded.

Next Steps

  • Read the Storage Backend Overview for more information on choosing and configuring a storage backend for Titan.
  • Titan Server builds on RexPro, a component of the Rexster Server. Learn about the full Rexster Graph Server that exposes any Titan graph as a REST endpoint.