public abstract class

AbstractHostPartitionConnectionPool

extends Object
implements ConnectionPool<CL> SimpleHostConnectionPool.Listener<CL>
java.lang.Object
   ↳ com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool<CL>
Known Direct Subclasses

Class Overview

Base for all connection pools that keep a separate pool of connections for each host.

Summary

Fields
protected final ConnectionPoolConfiguration config
protected final ConnectionFactory<CL> factory
protected final hosts
protected final ConnectionPoolMonitor monitor
protected final Topology<CL> topology
Public Constructors
AbstractHostPartitionConnectionPool(ConnectionPoolConfiguration config, ConnectionFactory<CL> factory, ConnectionPoolMonitor monitor)
Public Methods
final 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
void onHostDown(HostConnectionPool<CL> pool)
void onHostUp(HostConnectionPool<CL> pool)
boolean removeHost(Host host, boolean refresh)
Remove a host from the connection pool.
synchronized void setHosts(Map<BigIntegerList<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
Protected Methods
abstract <R> ExecuteWithFailover<CL, R> newExecuteWithFailover(Operation<CL, R> op)
Return a new failover context.
HostConnectionPool<CL> newHostConnectionPool(Host host, ConnectionFactory<CL> factory, ConnectionPoolConfiguration config)
void rebuildPartitions()
Called every time a host is added, removed or is marked as down
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.netflix.astyanax.connectionpool.ConnectionPool
From interface com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.Listener

Fields

protected final ConnectionPoolConfiguration config

protected final ConnectionFactory<CL> factory

protected final hosts

protected final ConnectionPoolMonitor monitor

protected final Topology<CL> topology

Public Constructors

public AbstractHostPartitionConnectionPool (ConnectionPoolConfiguration config, ConnectionFactory<CL> factory, ConnectionPoolMonitor monitor)

Public Methods

public final boolean addHost (Host host, boolean refresh)

Add a host to the connection pool.

public OperationResult<R> executeWithFailover (Operation<CL, R> op, RetryPolicy retry)

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.@return

public List<HostConnectionPool<CL>> getActivePools ()

Return list of active hosts on which connections can be created

public HostConnectionPool<CL> getHostPool (Host host)

Return an immutable connection pool for this host

public boolean hasHost (Host host)

Return true if host is contained within the connection pool

public boolean isHostUp (Host host)

Return true if the host is up

public void onHostDown (HostConnectionPool<CL> pool)

public void onHostUp (HostConnectionPool<CL> pool)

public boolean removeHost (Host host, boolean refresh)

Remove a host from the connection pool. Any pending connections will be allowed to complete

public synchronized void setHosts (Map<BigIntegerList<Host>> ring)

Sets the complete set of hosts keyed by token.

public void shutdown ()

Shut down the connection pool and terminate all existing connections

public void start ()

Setup the connection pool and start any maintenance threads

Protected Methods

protected abstract ExecuteWithFailover<CL, R> newExecuteWithFailover (Operation<CL, R> op)

Return a new failover context. The context captures the connection pool state and implements the necessary failover logic.@return

protected HostConnectionPool<CL> newHostConnectionPool (Host host, ConnectionFactory<CL> factory, ConnectionPoolConfiguration config)

protected void rebuildPartitions ()

Called every time a host is added, removed or is marked as down