use of com.netflix.astyanax.AstyanaxContext in project zuul by Netflix.
the class CassandraHelper method getZuulCassKeyspace.
/**
* @return the Keyspace for the Zuul Cassandra cluster which stores filters
* @throws Exception
*/
public Keyspace getZuulCassKeyspace() throws Exception {
if (zuulCassKeyspace != null)
return zuulCassKeyspace;
try {
setAstynaxConfiguration(ConfigurationManager.getConfigInstance());
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder().forKeyspace(DynamicPropertyFactory.getInstance().getStringProperty(ZUUL_CASSANDRA_KEYSPACE, "zuul_scripts").get()).withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)).withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("cass_connection_pool").setPort(DynamicPropertyFactory.getInstance().getIntProperty(ZUUL_CASSANDRA_PORT, 7102).get()).setMaxConnsPerHost(DynamicPropertyFactory.getInstance().getIntProperty(ZUUL_CASSANDRA_MAXCONNECTIONSPERHOST, 1).get()).setSeeds(DynamicPropertyFactory.getInstance().getStringProperty(ZUUL_CASSANDRA_HOST, "").get() + ":" + DynamicPropertyFactory.getInstance().getIntProperty(ZUUL_CASSANDRA_PORT, 7102).get())).withConnectionPoolMonitor(new CountingConnectionPoolMonitor()).buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
zuulCassKeyspace = context.getClient();
return zuulCassKeyspace;
} catch (Exception e) {
LOG.error("Exception occurred when initializing Cassandra keyspace: " + e);
throw e;
}
}
Aggregations