[titan-gremlin] Making it super easy to link to Cassandra and ES containers

This commit is contained in:
Geoff Bourne 2015-02-15 06:05:08 +00:00
parent b7f5088b13
commit 6c58660a73
3 changed files with 79 additions and 5 deletions

View File

@ -2,12 +2,13 @@ FROM itzg/ubuntu-openjdk-7
MAINTAINER itzg
RUN apt-get install -y wget unzip
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y wget unzip
ENV TITAN_VERSION 0.5.4
RUN wget -q -O /tmp/titan.zip http://s3.thinkaurelius.com/downloads/titan/titan-0.5.0-hadoop2.zip
RUN unzip /tmp/titan.zip -d /opt && rm /tmp/titan.zip
RUN wget -q -O /tmp/titan.zip http://s3.thinkaurelius.com/downloads/titan/titan-$TITAN_VERSION-hadoop2.zip
RUN unzip -q /tmp/titan.zip -d /opt && rm /tmp/titan.zip
ENV TITAN_HOME /opt/titan-0.5.0-hadoop2
ENV TITAN_HOME /opt/titan-$TITAN_VERSION-hadoop2
WORKDIR $TITAN_HOME
VOLUME ["/conf","/data"]

View File

@ -1,5 +1,7 @@
Runs the Gremlin console from the Titan Graph Database "all" distribution.
# Basic Usage
To start the Gremlin console with the default configuration files available:
docker run -it itzg/titan-gremlin
@ -12,3 +14,34 @@ attach a host directory to the container's `/conf` such as
After running once your host directory will be populated with the distribution-default
configuration files. Modify those or add to them and they will available during
the next use of gremlin.
# Connecting to Cassandra and Elasticsearch Containers
First start containers for Cassandra and Elasticsearch, where the `--name` you choose
can be arbitrary or left off to use a generated name.
_Note: Cassandra's Thrift port is exposed to allow for external usage, such as Titan Browser._
docker run -d --name cass -p 9160:9160 spotify/cassandra
docker run -d --name es itzg/elasticsearch
Now start Gremlin linking the containers to the respective aliases
* `--link <container>:cass`
* `--link <container>:es`
such as
docker run -it --rm --link cass:cass --link es:es itzg/titan-gremlin
and with that you can follow the
[Graph of the Gods example](http://s3.thinkaurelius.com/docs/titan/current/getting-started.html), such as
gremlin> GraphOfTheGodsFactory.load(g)
gremlin> saturn = g.V.has('name','saturn').next()
==>v[256]
gremlin> saturn.map()
==>name=saturn
==>age=10000
gremlin> saturn.in('father').in('father').name
==>hercules

View File

@ -1,7 +1,47 @@
#!/bin/bash
args=
if [ $(ls /conf|wc -l) = 0 ]; then
cp -r $TITAN_HOME/conf/* /conf
fi
$TITAN_HOME/bin/gremlin.sh
rm -f /tmp/titan.properties
if [ -n "$CASS_PORT_9160_TCP_ADDR" ]; then
shortcut=/tmp/titan.properties
cat >> /tmp/titan.properties <<END
storage.backend=cassandra
storage.hostname=$CASS_PORT_9160_TCP_ADDR
END
fi
if [ -n "$ES_CLUSTER" -o -n "$ES_PORT_9300_TCP_PORT" ]; then
shortcut=/tmp/titan.properties
cat >> /tmp/titan.properties <<END
index.search.backend=elasticsearch
index.search.elasticsearch.client-only=true
END
if [ -n "$ES_CLUSTER" ]; then
cat >> /tmp/titan.properties <<END
index.search.elasticsearch.ext.cluster.name=$ES_CLUSTER
END
fi
if [ -n "$ES_PORT_9300_TCP_PORT" ]; then
cat >> /tmp/titan.properties <<END
index.search.hostname=$ES_PORT_9300_TCP_ADDR
END
fi
fi
if [ -n "$shortcut" ]; then
cat > /tmp/init.groovy <<END
g = TitanFactory.open('$shortcut')
println 'The graph \'g\' was opened using $shortcut'
END
args="$args /tmp/init.groovy"
fi
exec $TITAN_HOME/bin/gremlin.sh $args