I am using hector to insert values in cassandra DB. I the Eclipse helios IDE and Cassandra version 1.1.2 with following jars imported in my classpath.
- apache-cassandra-1.1.2.jar
- hector-core-0.7.0.29.jar
- libthrift-0.8.0.jar
- slf4j-api-1.6.6.jar
I am not getting what is wrong here, either compatibility problem or something mess-up with code.
I tried using different version of jars, but no luck. Following is the code snippet.
Please help.
int count = 0;
StringSerializer ss = StringSerializer.get();
String cf = "TESTING";
CassandraHostConfigurator conf = new CassandraHostConfigurator("10.100.10.177:8160");
System.out.println("host configured..");
conf.setCassandraThriftSocketTimeout(40000);
conf.setExhaustedPolicy(ExhaustedPolicy.WHEN_EXHAUSTED_BLOCK);
conf.setRetryDownedHostsDelayInSeconds(5);
conf.setRetryDownedHostsQueueSize(128);
conf.setRetryDownedHosts(true);
conf.setLoadBalancingPolicy(new LeastActiveBalancingPolicy());
String key = Long.toString(System.currentTimeMillis());
Cluster cluster = HFactory.getOrCreateCluster("Test Cluster", conf);
Keyspace keyspace = HFactory.createKeyspace("Testing", cluster);
Mutator<String> mutator = HFactory.createMutator(keyspace, StringSerializer.get());
while (!"q".equals(new Scanner(System.in).next().toString())) {
try {
mutator.insert(key, cf, HFactory.createColumn("column_" + count, "v_" + count, ss, ss));
mutator.execute();
count++;
} catch (Exception e) {
e.printStackTrace();
}
}
Here is the exception I get when I insert a single value without a loop.
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.cassandra.thrift.Column.<init>(Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;J)V
at me.prettyprint.cassandra.model.HColumnImpl.<init>(HColumnImpl.java:36)
at me.prettyprint.hector.api.factory.HFactory.createColumn(HFactory.java:477)
at me.prettyprint.hector.api.factory.HFactory.createStringColumn(HFactory.java:488)
at ExampleDaoV2.main(ExampleDaoV2.java:66)