Permalink
Browse files

adding username and password to the props for connecting to cassandra

  • Loading branch information...
sabersd committed Aug 6, 2013
1 parent 5cf7db3 commit 2f75761137b80b0b6b0e319ffc4e31b7125fcdac
@@ -16,7 +16,9 @@
package com.reachlocal.grails.plugins.cassandra.astyanax
+import com.netflix.astyanax.connectionpool.ConnectionPoolConfiguration
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolType
+import com.netflix.astyanax.connectionpool.impl.SimpleAuthenticationCredentials
import com.netflix.astyanax.thrift.ThriftFamilyFactory
import com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl
@@ -64,14 +66,20 @@ class AstyanaxService implements InitializingBean
def port = props.port ?: 9160
def maxConsPerHost = props.maxConsPerHost ?: 10
def connectionPoolName = props.connectionPoolName ?: key
- clusterMap[key] = [
- connectionPoolConfiguration: new ConnectionPoolConfigurationImpl(connectionPoolName)
- .setPort(port)
- .setMaxConnsPerHost(maxConsPerHost)
- .setSeeds(props.seeds),
- contexts: [:],
- defaultKeyspace: props.defaultKeyspace ?: config.astyanax.defaultKeyspace
+ ConnectionPoolConfiguration connectionPoolConfiguration = new ConnectionPoolConfigurationImpl(connectionPoolName)
+ .setPort(port)
+ .setMaxConnsPerHost(maxConsPerHost)
+ .setSeeds(props.seeds)
+
+ if (props.username && props.password) {
+ connectionPoolConfiguration.authenticationCredentials = new SimpleAuthenticationCredentials(props.username, props.password)
+ }
+
+ clusterMap[key] = [
+ connectionPoolConfiguration: connectionPoolConfiguration,
+ contexts: [:],
+ defaultKeyspace: props.defaultKeyspace ?: config.astyanax.defaultKeyspace
]
}
}
@@ -43,4 +43,6 @@ connectionPoolName | no | Name used to identify the connection pool. Defaults t
defaultReadConsistencyLevel | no | Default consistency level used when reading from the cluster. This value can be overwritten on the Query operations.
defaultWriteConsistencyLevel | no | Default consistency level used when reading from the cluster. This value can be overwritten on MutationBatch operation
columnFamilies | no | Two level Map specifying the serializers to be used for the column row and name, whenever a string is specified as the column family rather than a _com.netflix.astyanax.model.ColumnFamily_ object. The key of the outer map is the key space name and the inner map is the column family name.
+userName | no | username for authentication to Cassandra.
+password | no | password for authentication to Cassandra
{table}

0 comments on commit 2f75761

Please sign in to comment.