All,
I am trying to use the new astyanax over java driver to connect to
cassandra version 1.2.12,
Following settings are turned on in cassandra.yaml:
start_rpc: true
native_transport_port: 9042
start_native_transport: true
*Code to connect:*
final Supplier<List<Host>> hostSupplier = new Supplier<List<Host>>() {
@Override
public List<Host> get()
{
List<Host> hosts = new ArrayList<>();
for(String hostPort :
StringUtil.getSetFromDelimitedString(seedHosts, ","))
{
String[] pair = hostPort.split(":");
Host host = new Host(pair[0],
Integer.valueOf(pair[1]).intValue());
host.setRack("rack1");
hosts.add(host);
}
return hosts;
}
};
// get keyspace
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
.forCluster(clusterName)
.forKeyspace(keyspace)
.withHostSupplier(hostSupplier)
.withAstyanaxConfiguration(
new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.DISCOVERY_SERVICE)
.setDiscoveryDelayInSeconds(60000).setCqlVersion("3.0.0").setTargetCassandraVersion("1.2.12")
)
.withConnectionPoolConfiguration(
new *JavaDriverConfigBuilder*().withPort(9042)
.build())
.buildKeyspace(CqlFamilyFactory.getInstance());
context.start();
*Exception in Cassandra Server logs:*
WARN [New I/O server boss #1 ([id: 0x6815d6c5, /0.0.0.0:9042])] 2014-10-06
11:11:37,826 Slf4JLogger.java (line 82) Failed to accept a connection.
java.lang.NoSuchMethodError:
org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder.<init>(IIIIIZ)V
at
org.apache.cassandra.transport.Frame$Decoder.<init>(Frame.java:147)
at
org.apache.cassandra.transport.Server$PipelineFactory.getPipeline(Server.java:232)
at
org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink$Boss.registerAcceptedChannel(NioServerSocketPipelineSink.java:276)
at
org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink$Boss.run(NioServerSocketPipelineSink.java:246)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
I also tried using the Java Driver 2.1.1, but I see the
NoHostAvailableException, and I feel the underlying reason is the same as
during connecting with astyanax java driver.