com.netflix.astyanax.connectionpool.impl
Class HostConnectionPoolPartition<CL>

java.lang.Object
  extended by com.netflix.astyanax.connectionpool.impl.HostConnectionPoolPartition<CL>
Type Parameters:
CL -
Direct Known Subclasses:
TokenHostConnectionPoolPartition

public class HostConnectionPoolPartition<CL>
extends java.lang.Object

Collection of hosts that are grouped by a certain criteria (such as token or rack) The class maintains the list of active pools for the given criteria (such as a token range in a ring) Any changes to the pools in this partition causes the active set to be revised and sorted according to the latency score strategy provided.

Note that an instance of this class is maintained / referenced for each token range partition by the TokenPartitionedTopology instance

See Also:
TokenPartitionedTopology} for details on how this class is referenced.

Field Summary
protected  java.util.concurrent.atomic.AtomicReference<java.util.List<HostConnectionPool<CL>>> activePools
           
protected  org.cliffc.high_scale_lib.NonBlockingHashSet<HostConnectionPool<CL>> pools
           
protected  java.util.concurrent.atomic.AtomicBoolean prioritize
           
protected  LatencyScoreStrategy strategy
           
 
Constructor Summary
HostConnectionPoolPartition(LatencyScoreStrategy strategy)
           
 
Method Summary
 boolean addPool(HostConnectionPool<CL> pool)
          Add a new pool to the partition.
 java.util.List<HostConnectionPool<CL>> getPools()
           
 boolean hasPool(HostConnectionPool<CL> pool)
          Returns true if a pool is contained in this partition
 boolean isSorted()
          If true the the hosts are sorted by order of priority where the first host gives the best performance
 void refresh()
          Refresh the partition
 boolean removePool(HostConnectionPool<CL> pool)
           
 boolean setPools(java.util.Collection<HostConnectionPool<CL>> newPools)
          Sets all pools for this partition.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

prioritize

protected final java.util.concurrent.atomic.AtomicBoolean prioritize

pools

protected final org.cliffc.high_scale_lib.NonBlockingHashSet<HostConnectionPool<CL>> pools

activePools

protected final java.util.concurrent.atomic.AtomicReference<java.util.List<HostConnectionPool<CL>>> activePools

strategy

protected final LatencyScoreStrategy strategy
Constructor Detail

HostConnectionPoolPartition

public HostConnectionPoolPartition(LatencyScoreStrategy strategy)
Method Detail

setPools

public boolean setPools(java.util.Collection<HostConnectionPool<CL>> newPools)
Sets all pools for this partition. Removes old partitions and adds new one.

Parameters:
newPools -

addPool

public boolean addPool(HostConnectionPool<CL> pool)
Add a new pool to the partition. Checks to see if the pool already existed. If so then there is no need to refresh the pool.

Parameters:
pool -
Returns:
True if anything changed

removePool

public boolean removePool(HostConnectionPool<CL> pool)

getPools

public java.util.List<HostConnectionPool<CL>> getPools()
Returns:
Return the list of active hosts. Active hosts are those deemed by the latency score strategy to be alive and responsive.

isSorted

public boolean isSorted()
If true the the hosts are sorted by order of priority where the first host gives the best performance


hasPool

public boolean hasPool(HostConnectionPool<CL> pool)
Returns true if a pool is contained in this partition

Parameters:
pool -

refresh

public void refresh()
Refresh the partition


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object