Running Titan

Install server and console packages

From Titan 0.9.0-M1 Release:

The zip archives are based on the TinkerPop 3.0.0.M6 gremlin-console and gremlin-server zipfiles. A monolithic titan-all TP3 plugin comes preinstalled and activated in the zipfiles.

Download the server and console packages from the following links:

Unzip them to their dedicated directories. From now on, I'm going to refer to them as console for titan-console and server for titan-server.

Set up server and Cassandra as backend storage

All commands are executed within the server directory.

➜  server  pwd
/Users/jacek/dev/apps/titan-0.9.0-M1/server

conf/gremlin-server-cassandra-es.yaml

➜  server  cp conf/gremlin-server{,-cassandra-es}.yaml

Edit conf/gremlin-server-cassandra-es.yaml to be as follows:

host: localhost
port: 8182
threadPoolWorker: 1
gremlinPool: 8
scriptEvaluationTimeout: 30000
serializedResponseTimeout: 30000
channelizer: com.tinkerpop.gremlin.server.channel.WebSocketChannelizer
# Uncomment for JSON support
#channelizer: com.tinkerpop.gremlin.server.channel.HttpChannelizer
graphs: {
  g: conf/titan-cassandra-es.properties
}
plugins:
  - aurelius.titan
scriptEngines: {
  gremlin-groovy: {
    imports: [java.lang.Math],
    staticImports: [java.lang.Math.PI]
  },
  nashorn: {
      imports: [java.lang.Math],
      staticImports: [java.lang.Math.PI]
  }
}
serializers:
  - { className: com.tinkerpop.gremlin.driver.ser.KryoMessageSerializerV1d0 }
  - { className: com.tinkerpop.gremlin.driver.ser.KryoMessageSerializerV1d0, config: { serializeResultToString: true }}
  - { className: com.tinkerpop.gremlin.driver.ser.JsonMessageSerializerGremlinV1d0 }
  - { className: com.tinkerpop.gremlin.driver.ser.JsonMessageSerializerV1d0 }
processors:
  - { className: com.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
metrics: {
  consoleReporter: {enabled: true, interval: 180000},
  csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
  jmxReporter: {enabled: true},
  slf4jReporter: {enabled: true, interval: 180000},
  gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
  graphiteReporter: {enabled: false, interval: 180000}}
threadPoolBoss: 1
maxInitialLineLength: 4096
maxHeaderSize: 8192
maxChunkSize: 8192
maxContentLength: 65536
maxAccumulationBufferComponents: 1024
resultIterationBatchSize: 64
writeBufferHighWaterMark: 32768
writeBufferHighWaterMark: 65536
ssl: {
  enabled: false
}

Uncomment the lines commented out after # Uncomment for JSON support to enable JSON support.

conf/titan-cassandra-es.properties

➜  server  cp conf/titan-{berkeleydb,cassandra-es}.properties

Edit conf/titan-cassandra-es.properties to be as follows:

gremlin.graph=com.thinkaurelius.titan.core.TitanFactory
# Other values: cassandrathrift, astyanax (synonym: cassandra), embeddedcassandra, inmemory
storage.backend=cassandra
storage.hostname=127.0.0.1

# Index backend
index.search.backend=elasticsearch
index.search.directory=/tmp/es
index.search.elasticsearch.local-mode=true
index.search.elasticsearch.client-only=false

Starting up Titan

Start Cassandra

In another command window start Cassandra using cassandra -f command.

➜  ~  cassandra -f
...
INFO  17:23:57 Loading settings from file:/usr/local/etc/cassandra/cassandra.yaml
...
INFO  17:23:57 JVM vendor/version: Java HotSpot(TM) 64-Bit Server VM/1.8.0_25
...
INFO  17:23:59 Cassandra version: 2.1.2
INFO  17:23:59 Thrift API version: 19.39.0
INFO  17:23:59 CQL supported versions: 2.0.0,3.2.0 (default: 3.2.0)
...
INFO  17:23:59 Node localhost/127.0.0.1 state jump to normal
INFO  17:23:59 Netty using Java NIO event loop
INFO  17:23:59 Using Netty Version: [netty-buffer=netty-buffer-4.0.23.Final.208198c, netty-codec=netty-codec-4.0.23.Final.208198c, netty-codec-http=netty-codec-http-4.0.23.Final.208198c, netty-codec-socks=netty-codec-socks-4.0.23.Final.208198c, netty-common=netty-common-4.0.23.Final.208198c, netty-handler=netty-handler-4.0.23.Final.208198c, netty-transport=netty-transport-4.0.23.Final.208198c, netty-transport-rxtx=netty-transport-rxtx-4.0.23.Final.208198c, netty-transport-sctp=netty-transport-sctp-4.0.23.Final.208198c, netty-transport-udt=netty-transport-udt-4.0.23.Final.208198c]
INFO  17:23:59 Starting listening for CQL clients on localhost/127.0.0.1:9042...
INFO  17:24:00 Binding thrift service to localhost/127.0.0.1:9160
INFO  17:24:00 Listening for thrift clients...
...

Start Elasticsearch

In another command window start Elasticsearch using elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml command.

➜  ~  elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml
[2014-12-26 00:08:36,747][INFO ][node                     ] [Monsoon] version[1.4.2], pid[22875], build[927caff/2014-12-16T14:11:12Z]
[2014-12-26 00:08:36,747][INFO ][node                     ] [Monsoon] initializing ...
[2014-12-26 00:08:36,751][INFO ][plugins                  ] [Monsoon] loaded [], sites []
[2014-12-26 00:08:38,479][INFO ][node                     ] [Monsoon] initialized
[2014-12-26 00:08:38,479][INFO ][node                     ] [Monsoon] starting ...
[2014-12-26 00:08:38,573][INFO ][transport                ] [Monsoon] bound_address {inet[/127.0.0.1:9300]}, publish_address {inet[/127.0.0.1:9300]}
[2014-12-26 00:08:38,590][INFO ][discovery                ] [Monsoon] elasticsearch_jacek/Nis3_WWqTs6hlqU5p57kyA
[2014-12-26 00:08:42,363][INFO ][cluster.service          ] [Monsoon] new_master [Monsoon][Nis3_WWqTs6hlqU5p57kyA][japila.local][inet[/127.0.0.1:9300]], reason: zen-disco-join (elected_as_master)
[2014-12-26 00:08:42,380][INFO ][http                     ] [Monsoon] bound_address {inet[/127.0.0.1:9200]}, publish_address {inet[/127.0.0.1:9200]}
[2014-12-26 00:08:42,380][INFO ][node                     ] [Monsoon] started
[2014-12-26 00:08:42,642][INFO ][gateway                  ] [Monsoon] recovered [1] indices into cluster_state

Start Titan server

With Cassandra and Elasticsearch up and running, you are now well prepared for starting Titan up itself.

Go to server directory and run ./bin/gremlin-server.sh conf/gremlin-server-cassandra-es.yaml.

Don't worry about the stacktrace.

➜  server  ./bin/gremlin-server.sh conf/gremlin-server-cassandra-es.yaml
[INFO] GremlinServer -
         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----

[INFO] GremlinServer - Configuring Gremlin Server from conf/gremlin-server-cassandra-es.yaml
[INFO] MetricManager - Configured Metrics ConsoleReporter configured with report interval=180000ms
[INFO] MetricManager - Configured Metrics CsvReporter configured with report interval=180000ms to fileName=/tmp/gremlin-server-metrics.csv
[INFO] MetricManager - Configured Metrics JmxReporter configured with domain= and agentId=
[INFO] MetricManager - Configured Metrics Slf4jReporter configured with interval=180000ms and loggerName=com.tinkerpop.gremlin.server.Settings$Slf4jReporterMetrics
[INFO] ConnectionPoolMBeanManager - Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,name=ClusterTitanConnectionPool,ServiceType=connectionpool
[INFO] CountingConnectionPoolMonitor - AddHost: 127.0.0.1
[INFO] ConnectionPoolMBeanManager - Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,name=KeyspaceTitanConnectionPool,ServiceType=connectionpool
[INFO] CountingConnectionPoolMonitor - AddHost: 127.0.0.1
[INFO] ReflectiveConfigOptionLoader - Loaded and initialized config classes: 11 OK out of 12 attempts in Duration[46 ms]
[INFO] Reflections - Reflections took 366 ms to scan 1 urls, producing 0 keys and 0 values
[INFO] BasicConfiguration - Ignored configuration entry for gremlin.graph since it does not map to an option
java.lang.IllegalArgumentException: Unknown configuration element in namespace [root]: gremlin
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:120)
    at com.thinkaurelius.titan.diskstorage.configuration.ConfigElement.parse(ConfigElement.java:170)
    at com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration.getAll(BasicConfiguration.java:80)
    at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.<init>(GraphDatabaseConfiguration.java:1303)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:91)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:57)
    at com.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:80)
    at com.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:96)
    at com.tinkerpop.gremlin.server.Graphs.lambda$new$10(Graphs.java:29)
    at com.tinkerpop.gremlin.server.Graphs$$Lambda$8/1477657879.accept(Unknown Source)
    at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:663)
    at com.tinkerpop.gremlin.server.Graphs.<init>(Graphs.java:27)
    at com.tinkerpop.gremlin.server.GremlinServer.initializeGremlinExecutor(GremlinServer.java:121)
    at com.tinkerpop.gremlin.server.GremlinServer.run(GremlinServer.java:74)
    at com.tinkerpop.gremlin.server.GremlinServer.main(GremlinServer.java:176)
[INFO] BasicConfiguration - Ignored configuration entry for gremlin.graph since it does not map to an option
java.lang.IllegalArgumentException: Unknown configuration element in namespace [root]: gremlin
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:120)
    at com.thinkaurelius.titan.diskstorage.configuration.ConfigElement.parse(ConfigElement.java:170)
    at com.thinkaurelius.titan.diskstorage.configuration.BasicConfiguration.getAll(BasicConfiguration.java:80)
    at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.<init>(GraphDatabaseConfiguration.java:1316)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:91)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:57)
    at com.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:80)
    at com.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:96)
    at com.tinkerpop.gremlin.server.Graphs.lambda$new$10(Graphs.java:29)
    at com.tinkerpop.gremlin.server.Graphs$$Lambda$8/1477657879.accept(Unknown Source)
    at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:663)
    at com.tinkerpop.gremlin.server.Graphs.<init>(Graphs.java:27)
    at com.tinkerpop.gremlin.server.GremlinServer.initializeGremlinExecutor(GremlinServer.java:121)
    at com.tinkerpop.gremlin.server.GremlinServer.run(GremlinServer.java:74)
    at com.tinkerpop.gremlin.server.GremlinServer.main(GremlinServer.java:176)
[INFO] GraphDatabaseConfiguration - Set cluster.partition=false from store features
[INFO] GraphDatabaseConfiguration - Set default timestamp provider MICRO
[INFO] GraphDatabaseConfiguration - Generated unique-instance-id=c0a8010c70122-japila-local1
[INFO] ConnectionPoolMBeanManager - Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,name=ClusterTitanConnectionPool,ServiceType=connectionpool
[INFO] CountingConnectionPoolMonitor - AddHost: 127.0.0.1
[INFO] ConnectionPoolMBeanManager - Registering mbean: com.netflix.MonitoredResources:type=ASTYANAX,name=KeyspaceTitanConnectionPool,ServiceType=connectionpool
[INFO] CountingConnectionPoolMonitor - AddHost: 127.0.0.1
[INFO] Backend - Configuring index [search]
[INFO] Log4jESLogger - [Rick Jones] version[1.2.1], pid[70122], build[6c95b75/2014-06-03T15:02:52Z]
[INFO] Log4jESLogger - [Rick Jones] initializing ...
[INFO] Log4jESLogger - [Rick Jones] loaded [], sites []
[INFO] Log4jESLogger - [Rick Jones] initialized
[INFO] Log4jESLogger - [Rick Jones] starting ...
[INFO] Log4jESLogger - [Rick Jones] bound_address {local[1]}, publish_address {local[1]}
[INFO] Log4jESLogger - [Rick Jones] new_master [Rick Jones][53Gf7egnRSKOy0KrH-oKHg][japila.local][local[1]]{local=true}, reason: local-disco-initial_connect(master)
[INFO] Log4jESLogger - [Rick Jones] elasticsearch/53Gf7egnRSKOy0KrH-oKHg
[INFO] Log4jESLogger - [Rick Jones] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.1.12:9200]}
[INFO] Log4jESLogger - [Rick Jones] recovered [1] indices into cluster_state
[INFO] Log4jESLogger - [Rick Jones] started
[INFO] Backend - Initiated backend operations thread pool of size 16
[INFO] KCVSLog$MessagePuller - Loaded unidentified ReadMarker start time Timepoint[1420306390001000 μs] into com[email protected]707865bd
[INFO] Graphs - Graph [g] was successfully configured via [conf/titan-cassandra-es.properties].
[INFO] GremlinServer - Initialized Gremlin thread pool.  Threads in pool named with pattern gremlin-*
[INFO] ScriptEngines - Loaded nashorn ScriptEngine
[INFO] ScriptEngines - Loaded gremlin-groovy ScriptEngine
[INFO] GremlinServer - Initialized GremlinExecutor and configured ScriptEngines.
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+kryo with com.tinkerpop.gremlin.driver.ser.KryoMessageSerializerV1d0
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+kryo-stringd with com.tinkerpop.gremlin.driver.ser.KryoMessageSerializerV1d0
[INFO] AbstractChannelizer - Configured application/vnd.gremlin-v1.0+json with com.tinkerpop.gremlin.driver.ser.JsonMessageSerializerGremlinV1d0
[INFO] AbstractChannelizer - Configured application/json with com.tinkerpop.gremlin.driver.ser.JsonMessageSerializerV1d0
[INFO] GremlinServer - Gremlin Server configured with worker thread pool of 1 and boss thread pool of 1
[INFO] GremlinServer - Channel started at port 8182.

Congratulations! Titan server is up and running! You can connect to it using Gremlin Console which is the topic of the following section.

Using Gremlin Console

Go to console directory and execute ./bin/gremlin.sh shell script.

➜  console  ./bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
INFO  com.tinkerpop.gremlin.hadoop.structure.HadoopGraph  - HADOOP_GREMLIN_LIBS is set to: /Users/jacek/dev/apps/titan-0.9.0-M1/titan-console-0.9.0-M1/bin/../ext/hadoop-gremlin:/Users/jacek/dev/apps/titan-0.9.0-M1/titan-console-0.9.0-M1/bin/../ext/titan-all
plugin activated: tinkerpop.hadoop
plugin activated: aurelius.titan
plugin activated: tinkerpop.tinkergraph
gremlin>

Check the versions of the software used right from the Gremlin shell:

gremlin> Gremlin.version
==>3.0.0.M6
gremlin> Titan.version()
==>0.9.0-M1

Open connection to Titan and execute queries:

gremlin> g = TitanFactory.open('../server/conf/titan-cassandra-es.properties')
==>standardtitangraph[cassandra:[127.0.0.1]]
gremlin> g.V().count()
WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [()]. For better performance, use indexes
==>0

You may also connect to Titan remotely as a TinkerPop3 server using :remote and :> commands.

gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Connected - localhost/127.0.0.1:8182
gremlin> :> g.V().count()
==>0
gremlin> :> g.addVertex().property("name", "jacek")
// there might be a stacktrace showing up here...
// Pretend nothing had happened :-)
gremlin> :> g.V().count()
==>1
gremlin> :> g.V().values('name').count()
==>1
gremlin> :> g.V().values('name')
==>jacek

It helps when you don't care what implementation you're talking to provided it's a TinkerPop3 server implementation.

FIXME (The following snippet doesn't seem to work)

You can also execute a script using :> @ command:

gremlin> script = """
gremlin>          matthias = g.addVertex('name','matthias')
gremlin>          matthias.addEdge('co-creator',g.V().has('name','marko').next())
gremlin>          """
==>
         matthias = g.addVertex('name','matthias')
         matthias.addEdge('co-creator',g.V().has('name','marko').next())
gremlin> :> @script
==>e[14][12-co-creator->1]

Read Connecting via Console.

Close the remote connection to Titan with :remote close.

gremlin> :remote close
==>Removed - Gremlin Server - [localhost/127.0.0.1:8182]

results matching ""

    No results matching ""