Permalink
Browse files

Add ability to configure connectionpooltype.

  • Loading branch information...
1 parent 9637b43 commit 5cc7c19df078b1edb35b8298df43783c0f9ef695 @beckje01 beckje01 committed Jun 6, 2013
View
6 grails-app/services/com/reachlocal/grails/plugins/cassandra/astyanax/AstyanaxService.groovy
@@ -16,7 +16,7 @@
package com.reachlocal.grails.plugins.cassandra.astyanax
-import org.codehaus.groovy.grails.commons.ConfigurationHolder
+import com.netflix.astyanax.connectionpool.impl.ConnectionPoolType
import com.netflix.astyanax.thrift.ThriftFamilyFactory
import com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl
@@ -167,12 +167,16 @@ class AstyanaxService implements InitializingBean
if (!context) {
def props = clusters[cluster]
+ //Default the pool type to the same default astyanax uses Round Robin.
+ ConnectionPoolType connectionPoolType = props.connectionPoolType ?: ConnectionPoolType.ROUND_ROBIN
def connectionPoolMonitor = props.connectionPoolMonitor ?: new CountingConnectionPoolMonitor()
def discoveryType = props.discoveryType ?: NodeDiscoveryType.NONE
def retryCount = props.retryCount ?: 3
def retryPolicy = props.retryPolicy ?: new RetryNTimes(retryCount)
+
def configuration = new AstyanaxConfigurationImpl()
+ .setConnectionPoolType(connectionPoolType)
.setDiscoveryType(discoveryType)
.setRetryPolicy(retryPolicy)
View
2 src/docs/guide/1.2 Configuration Options.gdoc
@@ -10,6 +10,7 @@ astyanax {
port = 9160
maxConsPerHost = 10
retryCount = 3
+ connectionPoolType = com.netflix.astyanax.connectionpool.impl.ConnectionPoolType.ROUND_ROBIN
connectionPoolMonitor = new com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor()
discoveryType = com.netflix.astyanax.connectionpool.NodeDiscoveryType.NONE
retryPolicy = new com.netflix.astyanax.retry.RetryNTimes(3)
@@ -34,6 +35,7 @@ defaultKeyspace | no | Name of the keyspace to use if one is not specified in th
port | no | Port number used for communicating to Cassandra nodes. Defaults to 9160.
maxConsPerHost | no | The maximum number of connections to be created for any one node. Defaults to 10.
retryCount | no | The number of times Astyanax will retry a call before failing. Has not effect if the retryPolicy property is set. Defaults to 3.
+connectionPoolType | no | The connection pool type. Defaults to ROuND_ROBIN. Other values are TOKEN_AWARE, ROUND_ROBIN, and BAG
connectionPoolMonitor | no | The connection pool monitor implementation. Defaults to new com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor
discoveryType | no | The method of discovering new nodes. Defaults to NONE (no discovery). Other values are RING_DESCRIBE, DISCOVERY_SERVICE, and TOKEN_AWARE
retryPolicy | no | The retry policy to use. Defaults to RetryNTimes. Others values include RunOnce, ConstantBackoff, ExponentialBackoff, BoundedExponentialBackoff, and SleepingRetryPolicy

0 comments on commit 5cc7c19

Please sign in to comment.