Netflix/astyanax — Issue #13: Programmatic Way to Dynamically Create Keyspaces
Author: echinthaka
Created: 2012-02-22 02:05:33+00:00
State: open

I'm writing an integration test to check the Astyanax adapter functionality. Part of that is to create the keyspace, dynamically using code, and delete it later. I wrote the following code but seems like its not working. Can someone please help me to find the issue or provide alternate code to achieve the same functionality?

Here is what I tried to do.
AstyanaxContext clusterContext = new AstyanaxContext.Builder()
.forCluster(clusterName)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.NONE))
.withConnectionPoolConfiguration(
new ConnectionPoolConfigurationImpl("MyConnectionPool").setPort(Integer.parseInt(ports))
.setMaxConnsPerHost(1).setSeeds("127.0.0.1:9160"))
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildCluster(ThriftFamilyFactory.getInstance());

ThriftKeyspaceDefinitionImpl def = new ThriftKeyspaceDefinitionImpl();
def.setName(keyspace);
clusterContext.getEntity().addKeyspace(def);

And this is the exception I'm getting.
com.netflix.astyanax.connectionpool.exceptions.NoAvailableHostsException: NoAvailableHostsException: [host=None(0.0.0.0):0, latency=0(0), attempts=0] No hosts to borrow from
at com.netflix.astyanax.connectionpool.impl.RoundRobinExecuteWithFailover.(RoundRobinExecuteWithFailover.java:30)
at com.netflix.astyanax.connectionpool.impl.RoundRobinConnectionPoolImpl.newExecuteWithFailover(RoundRobinConnectionPoolImpl.java:49)
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:222)
at com.netflix.astyanax.thrift.ThriftClusterImpl.addKeyspace(ThriftClusterImpl.java:229)