Search in sources :

Example 1 with AstyanaxContext

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;
    }
}
Also used : Keyspace(com.netflix.astyanax.Keyspace) ConnectionPoolConfigurationImpl(com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl) AstyanaxContext(com.netflix.astyanax.AstyanaxContext) AstyanaxConfigurationImpl(com.netflix.astyanax.impl.AstyanaxConfigurationImpl) CountingConnectionPoolMonitor(com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor)

Aggregations

AstyanaxContext (com.netflix.astyanax.AstyanaxContext)1 Keyspace (com.netflix.astyanax.Keyspace)1 ConnectionPoolConfigurationImpl (com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl)1 CountingConnectionPoolMonitor (com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor)1 AstyanaxConfigurationImpl (com.netflix.astyanax.impl.AstyanaxConfigurationImpl)1