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 embeds Rexster’s HTTP/REST Server and RexPro Server, a light-weight component of the Rexster Server which can efficiently handle hundreds of database connections. Titan Server bundles all the features and benefits of Rexster with Titan.

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.

Running Titan Server with a non-embedded backend (e.g. separate Cassandra cluster) removes the benefits that Titan Server bestows, as it then simply acts as host for Rexster processes only. While this configuration is possible, it is not recommended.

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 HTTP/REST and RexPro server. Titan Server can be configured with either one running or both. Refer to the Rexster configuration documentation for more information. This first argument is optional and can be omitted, in which case default configurations are used for both HTTP/REST and RexPro. To configure Titan Server to use one one server or the other, simply omit the appropriate section from the configuration file. 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.

Note – When running Titan Server on Windows, the example titan-server-cassandra.properties file expects a the path to a cassandra.yaml file to be a full URL as in: file:///c:/titan-cassandra-0.3.0/config/cassandra.yaml.

Connecting to Titan Server Via RexPro

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

RexsterClient client = RexsterClientFactory.open("localhost", "graph");
List<Map<String,Object>> result;
result = client.execute("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.execute("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 RexsterClient.execute() 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. RexsterClient provides additional execute() 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.

Connecting to Titan Server Via HTTP/REST

Titan Server will expose the same REST API as Rexster.

curl http://localhost:8182/graphs
{
    "version": "x.y.z",
    "name": "Rexster: A Graph Server",
    "graphs": [
        "graph"
    ],
    "queryTime": 0.217059,
    "upTime": "0[d]:00[h]:00[m]:05[s]"
}

It is also possible to deploy Rexster Extensions in Titan Server. Create an extension and put it in Titan Server’s path (i.e. the lib directory). Since Titan Server only exposes a single graph, it assumes that all extensions should be automatically deployed and be made available, therefore no specific configuration is required to expose the extension. If the extension requires specific configuration for its operations, simple add the configuration to an <extensions> element within the root of the Rexster configuration file.

Note – Titan Server does not support Dog House. It is always configured to be disabled.

Connecting to Titan via 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

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.