inolen / titan-node

Wrapper around gremlin-node to provide out of the box support for Titan graph database
23 stars 13 forks source link

Can't find "cassandra" even though I installed it and it works on my titan gremlin #9

Closed garrettg123 closed 7 years ago

garrettg123 commented 10 years ago

I installed Cassandra and Titan prior to titan-node. Running

conf = new BaseConfiguration()
conf.setProperty("storage.directory", "/tmp/titan")
conf.setProperty("storage.backend", "cassandra")
conf.setProperty("storage.hostname", "127.0.0.1")
conf.setProperty("storage.port", 9160)
g = TitanFactory.open(conf)

worked in my gremlin.sh. Now my config file has the same settings:

storage.directory = "/tmp/titan"
storage.backend = "cassandra"
storage.hostname = "127.0.0.1"
storage.port = 9160

but it's not recognizing Cassandra when I run:

Titan = require('titan-node')
gremlin = new Titan.Gremlin()
TitanFactory = gremlin.java.import('com.thinkaurelius.titan.core.TitanFactory')
graph = TitanFactory.openSync('titan.config')
g = gremlin.wrap(graph)

Here's the error:

$ node app.js

Error: Error running static method
java.lang.IllegalArgumentException: Could not find implementation class: "cassandra"
    at com.thinkaurelius.titan.diskstorage.Backend.instantiate(Backend.java:338)
    at com.thinkaurelius.titan.diskstorage.Backend.getImplementationClass(Backend.java:358)
    at com.thinkaurelius.titan.diskstorage.Backend.getStorageManager(Backend.java:302)
    at com.thinkaurelius.titan.diskstorage.Backend.<init>(Backend.java:115)
    at com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.getBackend(GraphDatabaseConfiguration.java:1108)
    at com.thinkaurelius.titan.graphdb.database.StandardTitanGraph.<init>(StandardTitanGraph.java:75)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:40)
    at com.thinkaurelius.titan.core.TitanFactory.open(TitanFactory.java:29)
    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 Object.<anonymous> (/Users/gsquare567/Sites/pumpup/server/app.js:29:24)
    at Object.<anonymous> (/Users/gsquare567/Sites/pumpup/server/app.js:41:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

Install

Also, this may be very useful for people starting up and I'll gladly help with the documentation of this repo to get people started very quickly, but for debugging purposes here is exactly how I installed everything:

brew install maven

sudo npm install restify

sudo npm install titan-node

Cassandra

mkdir ~/tempcd ~/temp
cd ~/temp
wget http://mirror.its.dal.ca/apache/cassandra/2.0.8/apache-cassandra-2.0.8-bin.tar.gz
tar -xvzf apache-cassandra-1.2.16-bin.tar.gz
tar -xvzf apache-cassandra-2.0.8-bin.tar.gz
mv apache-cassandra-2.0.8 ~/cassandra
sudo mkdir /var/lib/cassandra
sudo mkdir /var/log/cassandra
sudo chown -R $USER:$GROUP /var/lib/cassandra
sudo chown -R $USER:$GROUP /var/log/cassandra
export CASSANDRA_HOME=~/cassandra
export PATH=$PATH:$CASSANDRA_HOME/bin
sudo sh ~/cassandra/bin/cassandra

Titan

wget http://s3.thinkaurelius.com/downloads/titan/titan-cassandra-0.4.4.zip
unzip titan-cassandra-0.4.4.zip
mv titan-cassandra-0.4.4 ~/titan
export TITAN_HOME=~/titan
export PATH=$PATH:$TITAN_HOME/bin

Test

sudo sh ~/titan/bin/gremlin.sh
conf = new BaseConfiguration()
conf.setProperty("storage.directory", "/tmp/titan")
conf.setProperty("storage.backend", "cassandra")
conf.setProperty("storage.hostname", "127.0.0.1")
conf.setProperty("storage.port", 9160)
g = TitanFactory.open(conf)

So how can I get it to recognize Cassandra?

htaox commented 10 years ago

titan-node works with titan 0.4.1 which requires cassandra 1.2 according to titan docs looks like you installed cassandra 2 (not sure why titan-cassandra 0.4.4 would work)

dalaro commented 10 years ago

What happens if you change storage.backend to com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager (or to com.thinkaurelius.titan.diskstorage.cassandra.thrift.CassandraThriftStoreManager, effect should be roughly the same)?

Without having run the test yet, I'm having trouble imagining how this would happen unless the static initializer for com.thinkaurelius.titan.diskstorage.Backend.REGISTERED_STORAGE_MANAGERS somehow didn't execute. I could be missing something though.