me.prettyprint.cassandra.connection
Class DynamicLoadBalancingPolicy

java.lang.Object
  extended by me.prettyprint.cassandra.connection.DynamicLoadBalancingPolicy
All Implemented Interfaces:
Serializable, LoadBalancingPolicy

public class DynamicLoadBalancingPolicy
extends Object
implements LoadBalancingPolicy

This LB Algorithm has the Phi algo which Dynamic snitch uses, LB is based on the probablity of failure of the node. TODO: Make cassandra code abstracted enough so we can inherit from the same.

Author:
Vijay Parthasarathy
See Also:
Serialized Form

Constructor Summary
DynamicLoadBalancingPolicy()
           
 
Method Summary
 HClientPool createConnection(HClientFactory clientFactory, CassandraHost host, CassandraClientMonitor monitor)
          Creates a connection pool for host.
 double getBadnessThreshold()
           
 HClientPool getPool(Collection<HClientPool> pools, Set<CassandraHost> excludeHosts)
          Retrieves a pool from the collection of pools excluding excludeHosts.
 int getResetInterval()
           
 int getUpdateInterval()
           
 void setBadnessThreshold(double badness)
          This is the percentage of badness which is acceptable...
 void setResetInterval(int resetInterval)
          Set the configured interval for the stats to be reset so that the new stats are allowed and we can get rid of bad nodes value.
 void setUpdateInterval(int updateInterval)
          Set the configured interval for the stats to be recalculated (until this time it is been cached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicLoadBalancingPolicy

public DynamicLoadBalancingPolicy()
Method Detail

getPool

public HClientPool getPool(Collection<HClientPool> pools,
                           Set<CassandraHost> excludeHosts)
Description copied from interface: LoadBalancingPolicy
Retrieves a pool from the collection of pools excluding excludeHosts.

Specified by:
getPool in interface LoadBalancingPolicy
Parameters:
pools - collection of all available pools
excludeHosts - excluded pools
Returns:
a pool based on this load balancing policy

createConnection

public HClientPool createConnection(HClientFactory clientFactory,
                                    CassandraHost host,
                                    CassandraClientMonitor monitor)
Description copied from interface: LoadBalancingPolicy
Creates a connection pool for host.

Specified by:
createConnection in interface LoadBalancingPolicy
Parameters:
clientFactory - an instance of HClientFactory
host - an instance of CassandraHost representing the host this pool will represent
monitor - the monitor exposing JMX methods
Returns:
a connection pool

getUpdateInterval

public int getUpdateInterval()

setUpdateInterval

public void setUpdateInterval(int updateInterval)
Set the configured interval for the stats to be recalculated (until this time it is been cached.

Parameters:
updateInterval - In ms.

getResetInterval

public int getResetInterval()

setResetInterval

public void setResetInterval(int resetInterval)
Set the configured interval for the stats to be reset so that the new stats are allowed and we can get rid of bad nodes value. This is under the assumption that the bad nodes will eventually get better....

Parameters:
resetInterval - in ms

getBadnessThreshold

public double getBadnessThreshold()

setBadnessThreshold

public void setBadnessThreshold(double badness)
This is the percentage of badness which is acceptable... Example: A should be 0.20 (20%) bad than B before B is choosen rathar than A.

Parameters:
badness - in %


Copyright © 2013. All Rights Reserved.