me.prettyprint.cassandra.connection
Class LeastActiveBalancingPolicy

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

public class LeastActiveBalancingPolicy
extends Object
implements LoadBalancingPolicy

Selects the least active host based on the number of active connections. The list of hosts is shuffled on each pass to account for the case where a number of hosts are at the minimum number of connections (ie. they are not busy).

Author:
zznate
See Also:
Serialized Form

Constructor Summary
LeastActiveBalancingPolicy()
           
 
Method Summary
 HClientPool createConnection(HClientFactory clientFactory, CassandraHost host)
          Creates a connection pool for host.
 HClientPool getPool(Collection<HClientPool> pools, Set<CassandraHost> excludeHosts)
          Retrieves a pool from the collection of pools excluding excludeHosts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LeastActiveBalancingPolicy

public LeastActiveBalancingPolicy()
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)
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
Returns:
a connection pool


Copyright © 2012. All Rights Reserved.