com.netflix.astyanax.connectionpool
Interface ConnectionPool<CL>

Type Parameters:
CL -
All Known Implementing Classes:
AbstractHostPartitionConnectionPool, BagOfConnectionsConnectionPoolImpl, RoundRobinConnectionPoolImpl, TestConnectionPool, TokenAwareConnectionPoolImpl

public interface ConnectionPool<CL>

Base interface for a pool of connections. A concrete connection pool will track hosts in a cluster.


Method Summary
 boolean addHost(Host host, boolean refresh)
          Add a host to the connection pool.
<R> OperationResult<R>
executeWithFailover(Operation<CL,R> op, RetryPolicy retry)
          Execute an operation with failover within the context of the connection pool.
 java.util.List<HostConnectionPool<CL>> getActivePools()
           
 HostConnectionPool<CL> getHostPool(Host host)
           
 Partitioner getPartitioner()
           
 java.util.List<HostConnectionPool<CL>> getPools()
           
 Topology<CL> getTopology()
           
 boolean hasHost(Host host)
           
 boolean isHostUp(Host host)
           
 boolean removeHost(Host host, boolean refresh)
          Remove a host from the connection pool.
 void setHosts(java.util.Collection<Host> hosts)
          Set the complete set of hosts in the ring
 void shutdown()
          Shut down the connection pool and terminate all existing connections
 void start()
          Setup the connection pool and start any maintenance threads
 

Method Detail

addHost

boolean addHost(Host host,
                boolean refresh)
Add a host to the connection pool.

Parameters:
host -
Throws:
ConnectionException

removeHost

boolean removeHost(Host host,
                   boolean refresh)
Remove a host from the connection pool. Any pending connections will be allowed to complete

Parameters:
host -

isHostUp

boolean isHostUp(Host host)
Parameters:
host -
Returns:
Return true if the host is up

hasHost

boolean hasHost(Host host)
Parameters:
host -
Returns:
Return true if host is contained within the connection pool

getActivePools

java.util.List<HostConnectionPool<CL>> getActivePools()
Returns:
Return list of active hosts on which connections can be created

getPools

java.util.List<HostConnectionPool<CL>> getPools()
Returns:
Get all pools

setHosts

void setHosts(java.util.Collection<Host> hosts)
Set the complete set of hosts in the ring

Parameters:
hosts -

getHostPool

HostConnectionPool<CL> getHostPool(Host host)
Parameters:
host -
Returns:
Return an immutable connection pool for this host

executeWithFailover

<R> OperationResult<R> executeWithFailover(Operation<CL,R> op,
                                           RetryPolicy retry)
                                       throws ConnectionException,
                                              OperationException
Execute an operation with failover within the context of the connection pool. The operation will only fail over for connection pool errors and not application errors.

Type Parameters:
R -
Parameters:
op -
token -
Throws:
ConnectionException
OperationException

shutdown

void shutdown()
Shut down the connection pool and terminate all existing connections


start

void start()
Setup the connection pool and start any maintenance threads


getTopology

Topology<CL> getTopology()
Returns:
Return the internal topology which represents the partitioning of data across hosts in the pool

getPartitioner

Partitioner getPartitioner()
Returns:
Return the partitioner used by this pool.