Getting Gremlin console to work with Titan database
Posted by ozizka in Ondrej Zizka's Blog on Jun 25, 2015 1:38:00 PMIf you like graph databases, you probably have tried the Gremlin query language.
After some development, you get to a state when you have quite a large database, and need to query it interactively, mainly for the purpose of learning more complex queries and applying them in your app.
On various Gremlin docs sites, you can see code like this:
gremlin> g = TitanFactory.open('../server/conf/titan-cassandra-es.properties') ==>standardtitangraph[cassandra:[127.0.0.1]]
The problem is that Gremlin, as distributed, can't open Titan graph files - it doesn't contain the libs.
So this is what I had to do to make it work.
It's probably not the best way to do it, quite unsystemic, but got me to a working state, so...
1) Copy these into gremlin-groovy-2.5.0/lib:
(I just took the newest I had in my local Maven repo.)
- .m2/repository/com/google/guava/guava/18.0/guava-18.0.jar
- .m2/repository/com/thinkaurelius/titan/titan-berkeleyje/0.5.4/titan-berkeleyje-0.5.4.jar
2) Then the missing classes were appearantly from Titan, so I downloaded Titan 0.5.4 and copied
- titan-0.5.4-hadoop2/lib/je-5.0.73.jar
3) And there were more missing classes, so I just copied everything from titan-0.5.4-hadoop2/lib/
and removed those which seemed to duplicating, only other version:
- commons-io-2.1.jar
- commons-beanutils-core-1.7.0.jar
- concurrentlinkedhashmap-lru-1.3.jar
- guava-15.0.jar
- netty-3.2.7.Final.jar
- stax-api-1.0-2.jar
Then it started working:
$ gremlin \,,,/ (o o) -----oOOo-(_)-oOOo----- gremlin> import com.thinkaurelius.titan.core.TitanFactory ... gremlin> g = TitanFactory.open("target/reportsW2/WebLogicExamples_wldfdemo-wlnav.war-report/graph/TitanConfiguration.properties"); ... -> Few exceptions but finally: ==>titangraph[berkeleyje:/home/ondra/work/Migration/WindupCompar1vs2/target/reportsW2/WebLogicExamples_wldfdemo-wlnav.war-report/graph/titangraph] gremlin> g.has("w:vertextype", "BaseWindupConfiguration") --> com.thinkaurelius.titan.graphdb.database.StandardTitanGraph cannot be cast to com.tinkerpop.blueprints.Element gremlin> g.V.has("w:vertextype", "BaseWindupConfiguration") 19:11:34.155 [main] DEBUG c.t.t.g.transaction.StandardTitanTx - Guava vertex cache size: requested=20000 effective=20000 (min=100) 19:11:34.155 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created dirty vertex map with initial size 32 19:11:34.156 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created vertex cache with max size 20000 19:11:34.160 [main] DEBUG c.t.t.g.b.TitanBlueprintsGraph - Created new thread-bound transaction standardtitantx[null] 19:11:34.174 [main] DEBUG c.t.t.g.transaction.StandardTitanTx - Guava vertex cache size: requested=20000 effective=20000 (min=100) 19:11:34.174 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created dirty vertex map with initial size 32 19:11:34.174 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created vertex cache with max size 20000 19:11:34.208 [main] DEBUG c.t.t.g.transaction.StandardTitanTx - Guava vertex cache size: requested=20000 effective=20000 (min=100) 19:11:34.208 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created dirty vertex map with initial size 32 19:11:34.208 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created vertex cache with max size 20000 19:11:34.214 [main] DEBUG c.t.t.g.d.s.kryo.ThreadLocalKryos - [0x41385767] Returning thread-local Kryo com.esotericsoftware.kryo.Kryo@69ee8449 19:11:34.226 [main] DEBUG c.t.t.g.transaction.StandardTitanTx - Guava vertex cache size: requested=20000 effective=20000 (min=100) 19:11:34.227 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created dirty vertex map with initial size 32 19:11:34.227 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created vertex cache with max size 20000 19:11:34.232 [main] DEBUG c.t.t.g.transaction.StandardTitanTx - Guava vertex cache size: requested=20000 effective=20000 (min=100) 19:11:34.232 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created dirty vertex map with initial size 32 19:11:34.232 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created vertex cache with max size 20000 19:11:34.234 [main] DEBUG c.t.t.g.transaction.StandardTitanTx - Guava vertex cache size: requested=20000 effective=20000 (min=100) 19:11:34.234 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created dirty vertex map with initial size 32 19:11:34.234 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created vertex cache with max size 20000 19:11:34.236 [main] DEBUG c.t.t.g.transaction.StandardTitanTx - Guava vertex cache size: requested=20000 effective=20000 (min=100) 19:11:34.237 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created dirty vertex map with initial size 32 19:11:34.237 [main] DEBUG c.t.t.g.t.v.GuavaVertexCache - Created vertex cache with max size 20000 ==>v[256] gremlin> g.V("w:vertextype", "BaseWindupConfiguration") ==>v[256]
Enjoy
Comments