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

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

public interface ConnectionPool<CL>

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

Author:
elandau

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.
 List<HostConnectionPool<CL>> getActivePools()
          Return list of active hosts on which connections can be created
 HostConnectionPool<CL> getHostPool(Host host)
          Return an immutable connection pool for this host
 boolean hasHost(Host host)
          Return true if host is contained within the connection pool
 boolean isHostUp(Host host)
          Return true if the host is up
 boolean removeHost(Host host, boolean refresh)
          Remove a host from the connection pool.
 void setHosts(Map<BigInteger,List<Host>> ring)
          Sets the complete set of hosts keyed by token.
 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)
Return true if the host is up

Parameters:
host -
Returns:

hasHost

boolean hasHost(Host host)
Return true if host is contained within the connection pool

Parameters:
host -
Returns:

getActivePools

List<HostConnectionPool<CL>> getActivePools()
Return list of active hosts on which connections can be created

Returns:

setHosts

void setHosts(Map<BigInteger,List<Host>> ring)
Sets the complete set of hosts keyed by token.

Parameters:
ring -

getHostPool

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

Parameters:
host -
Returns:

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 -
Returns:
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



Copyright © 2012. All Rights Reserved.