org.scale7.cassandra.pelops.pool
Class CommonsBackedPool

java.lang.Object
  extended by org.scale7.cassandra.pelops.pool.ThriftPoolBase
      extended by org.scale7.cassandra.pelops.pool.CommonsBackedPool
All Implemented Interfaces:
CommonsBackedPoolMBean, IThriftPool

public class CommonsBackedPool
extends ThriftPoolBase
implements CommonsBackedPoolMBean


Nested Class Summary
static interface CommonsBackedPool.IConnectionValidator
          Interface used to define how a connection is validated while idle.
static interface CommonsBackedPool.INodeSelectionStrategy
          Interface used to define how nodes should be selected.
static interface CommonsBackedPool.INodeSuspensionState
          Interface used to define a pooled nodes suspension status.
static interface CommonsBackedPool.INodeSuspensionStrategy
          Interface used to define how nodes should be suspended for behaving badly.
static class CommonsBackedPool.Policy
           
 class CommonsBackedPool.PooledConnection
           
static class CommonsBackedPool.RunningStatistics
           
 
Nested classes/interfaces inherited from interface org.scale7.cassandra.pelops.pool.IThriftPool
IThriftPool.IPooledConnection
 
Field Summary
 
Fields inherited from interface org.scale7.cassandra.pelops.pool.CommonsBackedPoolMBean
JMX_MBEAN_OBJ_NAME
 
Constructor Summary
CommonsBackedPool(Cluster cluster, String keyspace)
          Create a new instance with reasonable defaults.
CommonsBackedPool(Cluster cluster, String keyspace, CommonsBackedPool.Policy policy, OperandPolicy operandPolicy)
          Create a new instance with reasonable defaults.
CommonsBackedPool(Cluster cluster, String keyspace, CommonsBackedPool.Policy policy, OperandPolicy operandPolicy, CommonsBackedPool.INodeSelectionStrategy nodeSelectionStrategy, CommonsBackedPool.INodeSuspensionStrategy nodeSuspensionStrategy, CommonsBackedPool.IConnectionValidator connectionValidator)
          Create a new instance of the pool.
 
Method Summary
protected  void configureBackingPool()
           
 Cluster getCluster()
           
 IThriftPool.IPooledConnection getConnection()
          Get a connection from the pool.
 IThriftPool.IPooledConnection getConnectionExcept(String notNodeHint)
          Get a connection from the pool trying to avoid the node specified by the notNode param.
 int getConnectionsActive()
           
 int getConnectionsBorrowedTotal()
           
 int getConnectionsCorrupted()
           
 int getConnectionsCreated()
           
 int getConnectionsDestroyed()
           
 int getConnectionsReleasedTotal()
           
 CommonsBackedPool.IConnectionValidator getConnectionValidator()
           
 String getKeyspace()
          The keyspace this connection operates on.
 int getMaxActivePerNode()
           
 int getMaxIdlePerNode()
           
 int getMaxTotal()
           
 int getMaxWaitForConnection()
           
 int getMinIdlePerNode()
           
 int getNodesActive()
           
 CommonsBackedPool.INodeSelectionStrategy getNodeSelectionStrategy()
           
 int getNodesSuspended()
           
 CommonsBackedPool.INodeSuspensionStrategy getNodeSuspensionStrategy()
           
 OperandPolicy getOperandPolicy()
          Get the current policy in force, which controls the general behavior of pelops.
 CommonsBackedPool.Policy getPolicy()
           
 org.scale7.cassandra.pelops.pool.PooledNode getPooledNode(String nodeAddress)
          Returns the pooled node instance for the nodeAddress.
 CommonsBackedPool.RunningStatistics getStatistics()
           
 boolean isTestConnectionsWhileIdle()
           
protected  void releaseConnection(CommonsBackedPool.PooledConnection connection)
           
protected  void reportConnectionBorrowed(String nodeAddress)
           
protected  void reportConnectionCorrupted(String nodeAddress)
           
protected  void reportConnectionCreated(String nodeAddress)
           
protected  void reportConnectionDestroyed(String nodeAddress)
           
protected  void reportConnectionReleased(String nodeAddress)
           
 void runMaintenanceTasks()
           
 void setMaxActivePerNode(int maxActivePerNode)
           
 void setMaxIdlePerNode(int maxIdlePerNode)
           
 void setMaxTotal(int maxTotal)
           
 void setMaxWaitForConnection(int maxWaitForConnection)
           
 void setMinIdlePerNode(int minIdlePerNode)
           
 void setTestConnectionsWhileIdle(boolean testConnectionsWhileIdle)
           
 void shutdown()
          Shuts down the pool.
 
Methods inherited from class org.scale7.cassandra.pelops.pool.ThriftPoolBase
createMutator, createMutator, createMutator, createMutator, createMutator, createRowDeletor, createRowDeletor, createSelector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonsBackedPool

public CommonsBackedPool(Cluster cluster,
                         String keyspace)
Create a new instance with reasonable defaults.

Parameters:
cluster - the cluster this pool is pooling connections to
keyspace - the keyspace this pool is for
See Also:
CommonsBackedPool(org.scale7.cassandra.pelops.Cluster, String, org.scale7.cassandra.pelops.pool.CommonsBackedPool.Policy,org.scale7.cassandra.pelops.OperandPolicy, org.scale7.cassandra.pelops.pool.CommonsBackedPool.INodeSelectionStrategy, org.scale7.cassandra.pelops.pool.CommonsBackedPool.INodeSuspensionStrategy, org.scale7.cassandra.pelops.pool.CommonsBackedPool.IConnectionValidator)

CommonsBackedPool

public CommonsBackedPool(Cluster cluster,
                         String keyspace,
                         CommonsBackedPool.Policy policy,
                         OperandPolicy operandPolicy)
Create a new instance with reasonable defaults.

Parameters:
cluster - the cluster this pool is pooling connections to
keyspace - the keyspace this pool is for
policy - the pool config
operandPolicy - the operand config
See Also:
CommonsBackedPool(org.scale7.cassandra.pelops.Cluster, String, org.scale7.cassandra.pelops.pool.CommonsBackedPool.Policy,org.scale7.cassandra.pelops.OperandPolicy, org.scale7.cassandra.pelops.pool.CommonsBackedPool.INodeSelectionStrategy, org.scale7.cassandra.pelops.pool.CommonsBackedPool.INodeSuspensionStrategy, org.scale7.cassandra.pelops.pool.CommonsBackedPool.IConnectionValidator)

CommonsBackedPool

public CommonsBackedPool(Cluster cluster,
                         String keyspace,
                         CommonsBackedPool.Policy policy,
                         OperandPolicy operandPolicy,
                         CommonsBackedPool.INodeSelectionStrategy nodeSelectionStrategy,
                         CommonsBackedPool.INodeSuspensionStrategy nodeSuspensionStrategy,
                         CommonsBackedPool.IConnectionValidator connectionValidator)
Create a new instance of the pool.

Parameters:
cluster - the cluster this pool is pooling connections to
keyspace - the keyspace this pool is for
policy - the pool config
operandPolicy - the operand config
nodeSelectionStrategy - the node selection strategy (if null then LeastLoadedNodeSelectionStrategy is used)
nodeSuspensionStrategy - the node suspend strategy (if null then NoOpNodeSuspensionStrategy is used)
connectionValidator - validator used to validate idle connections (if null then DescribeVersionConnectionValidator is used)
Method Detail

runMaintenanceTasks

public void runMaintenanceTasks()
Specified by:
runMaintenanceTasks in interface CommonsBackedPoolMBean

shutdown

public void shutdown()
Description copied from interface: IThriftPool
Shuts down the pool.

Calling this method after the pool has been shutdown should have no affect.

Specified by:
shutdown in interface IThriftPool

getConnection

public IThriftPool.IPooledConnection getConnection()
                                            throws NoConnectionsAvailableException
Description copied from interface: IThriftPool
Get a connection from the pool.

Specified by:
getConnection in interface IThriftPool
Returns:
the connection
Throws:
NoConnectionsAvailableException

getConnectionExcept

public IThriftPool.IPooledConnection getConnectionExcept(String notNodeHint)
                                                  throws NoConnectionsAvailableException
Description copied from interface: IThriftPool
Get a connection from the pool trying to avoid the node specified by the notNode param.

Specified by:
getConnectionExcept in interface IThriftPool
Parameters:
notNodeHint - the node to avoid if possible
Returns:
the connection
Throws:
NoConnectionsAvailableException

getPooledNode

public org.scale7.cassandra.pelops.pool.PooledNode getPooledNode(String nodeAddress)
Returns the pooled node instance for the nodeAddress.

Parameters:
nodeAddress - the node address
Returns:
the pooled node instance or null if the nodeAddress doesn't match a pooled node

configureBackingPool

protected void configureBackingPool()

releaseConnection

protected void releaseConnection(CommonsBackedPool.PooledConnection connection)

reportConnectionCreated

protected void reportConnectionCreated(String nodeAddress)

reportConnectionDestroyed

protected void reportConnectionDestroyed(String nodeAddress)

reportConnectionCorrupted

protected void reportConnectionCorrupted(String nodeAddress)

reportConnectionBorrowed

protected void reportConnectionBorrowed(String nodeAddress)

reportConnectionReleased

protected void reportConnectionReleased(String nodeAddress)

getOperandPolicy

public OperandPolicy getOperandPolicy()
Description copied from interface: IThriftPool
Get the current policy in force, which controls the general behavior of pelops.

Specified by:
getOperandPolicy in interface IThriftPool
Returns:
the current policy

getKeyspace

public String getKeyspace()
Description copied from interface: IThriftPool
The keyspace this connection operates on.

Specified by:
getKeyspace in interface IThriftPool
Returns:
the keyspace

getPolicy

public CommonsBackedPool.Policy getPolicy()

getCluster

public Cluster getCluster()

getNodeSelectionStrategy

public CommonsBackedPool.INodeSelectionStrategy getNodeSelectionStrategy()

getNodeSuspensionStrategy

public CommonsBackedPool.INodeSuspensionStrategy getNodeSuspensionStrategy()

getConnectionValidator

public CommonsBackedPool.IConnectionValidator getConnectionValidator()

getStatistics

public CommonsBackedPool.RunningStatistics getStatistics()

getConnectionsCreated

public int getConnectionsCreated()
Specified by:
getConnectionsCreated in interface CommonsBackedPoolMBean

getConnectionsDestroyed

public int getConnectionsDestroyed()
Specified by:
getConnectionsDestroyed in interface CommonsBackedPoolMBean

getConnectionsCorrupted

public int getConnectionsCorrupted()
Specified by:
getConnectionsCorrupted in interface CommonsBackedPoolMBean

getConnectionsActive

public int getConnectionsActive()
Specified by:
getConnectionsActive in interface CommonsBackedPoolMBean

getNodesActive

public int getNodesActive()
Specified by:
getNodesActive in interface CommonsBackedPoolMBean

getNodesSuspended

public int getNodesSuspended()
Specified by:
getNodesSuspended in interface CommonsBackedPoolMBean

getConnectionsBorrowedTotal

public int getConnectionsBorrowedTotal()
Specified by:
getConnectionsBorrowedTotal in interface CommonsBackedPoolMBean

getConnectionsReleasedTotal

public int getConnectionsReleasedTotal()
Specified by:
getConnectionsReleasedTotal in interface CommonsBackedPoolMBean

getMaxActivePerNode

public int getMaxActivePerNode()
Specified by:
getMaxActivePerNode in interface CommonsBackedPoolMBean

setMaxActivePerNode

public void setMaxActivePerNode(int maxActivePerNode)
Specified by:
setMaxActivePerNode in interface CommonsBackedPoolMBean

getMaxIdlePerNode

public int getMaxIdlePerNode()
Specified by:
getMaxIdlePerNode in interface CommonsBackedPoolMBean

setMaxIdlePerNode

public void setMaxIdlePerNode(int maxIdlePerNode)
Specified by:
setMaxIdlePerNode in interface CommonsBackedPoolMBean

getMaxTotal

public int getMaxTotal()
Specified by:
getMaxTotal in interface CommonsBackedPoolMBean

setMaxTotal

public void setMaxTotal(int maxTotal)
Specified by:
setMaxTotal in interface CommonsBackedPoolMBean

getMinIdlePerNode

public int getMinIdlePerNode()
Specified by:
getMinIdlePerNode in interface CommonsBackedPoolMBean

setMinIdlePerNode

public void setMinIdlePerNode(int minIdlePerNode)
Specified by:
setMinIdlePerNode in interface CommonsBackedPoolMBean

getMaxWaitForConnection

public int getMaxWaitForConnection()
Specified by:
getMaxWaitForConnection in interface CommonsBackedPoolMBean

setMaxWaitForConnection

public void setMaxWaitForConnection(int maxWaitForConnection)
Specified by:
setMaxWaitForConnection in interface CommonsBackedPoolMBean

isTestConnectionsWhileIdle

public boolean isTestConnectionsWhileIdle()
Specified by:
isTestConnectionsWhileIdle in interface CommonsBackedPoolMBean

setTestConnectionsWhileIdle

public void setTestConnectionsWhileIdle(boolean testConnectionsWhileIdle)
Specified by:
setTestConnectionsWhileIdle in interface CommonsBackedPoolMBean


Copyright © 2011. All Rights Reserved.