org.scale7.cassandra.pelops.pool
Class CommonsBackedPool.Policy

java.lang.Object
  extended by org.scale7.cassandra.pelops.pool.CommonsBackedPool.Policy
Enclosing class:
CommonsBackedPool

public static class CommonsBackedPool.Policy
extends Object


Constructor Summary
CommonsBackedPool.Policy()
           
 
Method Summary
 int getMaxActivePerNode()
           
 int getMaxIdlePerNode()
           
 int getMaxTotal()
           
 int getMaxWaitForConnection()
           
 int getMinIdlePerNode()
           
 int getTimeBetweenScheduledMaintenanceTaskRunsMillis()
           
 boolean isTestConnectionsWhileIdle()
           
 void setMaxActivePerNode(int maxActivePerNode)
          Sets the cap on the number of object instances managed by the pool per node.
 void setMaxIdlePerNode(int maxIdlePerNode)
          Sets the cap on the number of "idle" instances in the pool.
 void setMaxTotal(int maxTotal)
          Sets the cap on the total number of instances from all nodes combined.
 void setMaxWaitForConnection(int maxWaitForConnection)
          Sets the maximum amount of time (in milliseconds) the CommonsBackedPool.getConnection() method should wait before throwing an exception when the pool is exhausted.
 void setMinIdlePerNode(int minIdlePerNode)
          Sets the minimum number of idle objects to maintain in each of the nodes.
 void setTestConnectionsWhileIdle(boolean testConnectionsWhileIdle)
          When true, connections will be validated by scheduled tasks thread (if enabled).
 void setTimeBetweenScheduledMaintenanceTaskRunsMillis(int timeBetweenScheduledMaintenanceTaskRunsMillis)
          Sets the number of milliseconds to sleep between runs of the idle object tasks thread.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommonsBackedPool.Policy

public CommonsBackedPool.Policy()
Method Detail

getMaxActivePerNode

public int getMaxActivePerNode()
See Also:
setMaxActivePerNode(int)

setMaxActivePerNode

public void setMaxActivePerNode(int maxActivePerNode)
Sets the cap on the number of object instances managed by the pool per node.

Parameters:
maxActivePerNode - The cap on the number of object instances per node. Use a negative value for no limit.

getMaxIdlePerNode

public int getMaxIdlePerNode()
See Also:
setMaxActivePerNode(int)

setMaxIdlePerNode

public void setMaxIdlePerNode(int maxIdlePerNode)
Sets the cap on the number of "idle" instances in the pool. If maxIdle is set too low on heavily loaded systems it is possible you will see objects being destroyed and almost immediately new objects being created. This is a result of the active threads momentarily returning objects faster than they are requesting them them, causing the number of idle objects to rise above maxIdle. The best value for maxIdle for heavily loaded system will vary but the default is a good starting point.

Parameters:
maxIdlePerNode -

getMaxTotal

public int getMaxTotal()
See Also:
setMaxTotal(int)

setMaxTotal

public void setMaxTotal(int maxTotal)
Sets the cap on the total number of instances from all nodes combined. When maxTotal is set to a positive value and CommonsBackedPool.getConnection() is invoked when at the limit with no idle instances available, an attempt is made to create room by clearing the oldest 15% of the elements from the keyed pools.

Parameters:
maxTotal - The cap on the number of object instances per node. Use a negative value for no limit.

getMinIdlePerNode

public int getMinIdlePerNode()
See Also:
setMinIdlePerNode(int)

setMinIdlePerNode

public void setMinIdlePerNode(int minIdlePerNode)
Sets the minimum number of idle objects to maintain in each of the nodes.

Parameters:
minIdlePerNode - The minimum size of the each nodes pool

getMaxWaitForConnection

public int getMaxWaitForConnection()
See Also:
setMaxWaitForConnection(int)

setMaxWaitForConnection

public void setMaxWaitForConnection(int maxWaitForConnection)
Sets the maximum amount of time (in milliseconds) the CommonsBackedPool.getConnection() method should wait before throwing an exception when the pool is exhausted. When less than or equal to 0, the CommonsBackedPool.getConnection() method may block indefinitely.

Parameters:
maxWaitForConnection - the maximum number of milliseconds CommonsBackedPool.getConnection() will block or negative for indefinitely.

getTimeBetweenScheduledMaintenanceTaskRunsMillis

public int getTimeBetweenScheduledMaintenanceTaskRunsMillis()
See Also:
setTimeBetweenScheduledMaintenanceTaskRunsMillis(int)

setTimeBetweenScheduledMaintenanceTaskRunsMillis

public void setTimeBetweenScheduledMaintenanceTaskRunsMillis(int timeBetweenScheduledMaintenanceTaskRunsMillis)
Sets the number of milliseconds to sleep between runs of the idle object tasks thread. When non-positive, no idle object evictor thread will be run.

Parameters:
timeBetweenScheduledMaintenanceTaskRunsMillis - milliseconds to sleep between evictor runs.

isTestConnectionsWhileIdle

public boolean isTestConnectionsWhileIdle()
See Also:
setTestConnectionsWhileIdle(boolean)

setTestConnectionsWhileIdle

public void setTestConnectionsWhileIdle(boolean testConnectionsWhileIdle)
When true, connections will be validated by scheduled tasks thread (if enabled). If an connection fails to validate, it will be dropped from the pool.

Parameters:
testConnectionsWhileIdle - true if enabled, otherwise false

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.