Skip to content

Starting with AstyanaxContext

opuneet edited this page Oct 9, 2013 · 3 revisions

Using TOKEN_AWARE connection pool with a RING_DESCRIBE on seed hosts

AstyanaxContext<Keyspace> ctx = 
           new AstyanaxContext.Builder()
           .forKeyspace(YOUR KEYSPACE NAME)
           .withConnectionPoolConfiguration(
               new ConnectionPoolConfigurationImpl("myCPConfig")
                   .setSeeds(YOUR SEED HOST)
                   .setPort(YOUR CONN PORT))
           .withAstyanaxConfiguration(
               new AstyanaxConfigurationImpl()
                   .setConnectionPoolType(ConnectionPoolType.TOKEN_AWARE)
                   .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
           .buildKeyspace(ThriftFamilyFactory.getInstance());

Keyspace ks = ctx.getClient();

ctx.start();
Clone this wiki locally