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

Type Parameters:
CL -
All Known Implementing Classes:
SimpleHostConnectionPool

public interface HostConnectionPool<CL>

Pool of connections for a single host

Author:
elandau

Method Summary
 void addLatencySample(long lastLatency, long now)
          Add a single latency sample after an operation on a connection belonging to this pool
 Connection<CL> borrowConnection(int timeout)
          Borrow a connection from the host.
 boolean closeConnection(Connection<CL> connection)
          Close this connection and update internal state
 int getActiveConnectionCount()
          Get number of open connections including any that are currently borrowed and those that are currently idel
 int getBlockedThreadCount()
          Get number of threads blocked waiting for a free connection
 int getBusyConnectionCount()
          Get number of currently borrowed connections
 Host getHost()
          Get the host to which this pool is associated
 int getIdleConnectionCount()
          Return the number of idle active connections.
 double getMeanLatency()
          Get the average latency as calculated by the scoring strategy
 int getPendingConnectionCount()
          Get the number of pending connection open attempts
 double getScore()
          Return implementation specific score to be used by weighted pool selection algorithms
 int growConnections(int numConnections)
          Create numConnections new connections and add them to the
 boolean isShutdown()
          Determine if pool is shut down.
 void markAsDown(ConnectionException reason)
          Shut down the host so no more connections may be created when borrowConnections is called and connections will be terminated when returnConnection is called.
 Connection<CL> openConnection()
          This open is different from borrowConnection in that it actually creates a new connection without waiting for one that may be idle.
 boolean returnConnection(Connection<CL> connection)
          Return a connection to the host's pool.
 void shutdown()
          Completely shut down this connection pool as part of a client shutdown
 

Method Detail

borrowConnection

Connection<CL> borrowConnection(int timeout)
                                throws ConnectionException
Borrow a connection from the host. May create a new connection if one is not available.

Parameters:
timeout -
Returns:
Throws:
ConnectionException

openConnection

Connection<CL> openConnection()
                              throws ConnectionException
This open is different from borrowConnection in that it actually creates a new connection without waiting for one that may be idle. openConnection is still subject to all other connection pool limitations.

Returns:
Throws:
ConnectionException

returnConnection

boolean returnConnection(Connection<CL> connection)
Return a connection to the host's pool. May close the connection if the pool is down or the last exception on the connection is determined to be fatal.

Parameters:
connection -
Returns:
True if connection was closed

closeConnection

boolean closeConnection(Connection<CL> connection)
Close this connection and update internal state

Parameters:
connection -
Returns:

markAsDown

void markAsDown(ConnectionException reason)
Shut down the host so no more connections may be created when borrowConnections is called and connections will be terminated when returnConnection is called.


shutdown

void shutdown()
Completely shut down this connection pool as part of a client shutdown


growConnections

int growConnections(int numConnections)
                    throws ConnectionException,
                           InterruptedException
Create numConnections new connections and add them to the

Throws:
ConnectionException
InterruptedException

getHost

Host getHost()
Get the host to which this pool is associated

Returns:

getActiveConnectionCount

int getActiveConnectionCount()
Get number of open connections including any that are currently borrowed and those that are currently idel

Returns:

getPendingConnectionCount

int getPendingConnectionCount()
Get the number of pending connection open attempts

Returns:

getBlockedThreadCount

int getBlockedThreadCount()
Get number of threads blocked waiting for a free connection

Returns:

getIdleConnectionCount

int getIdleConnectionCount()
Return the number of idle active connections. These are connections that can be borrowed immediatley without having to make a new connection to the remote server.

Returns:

getBusyConnectionCount

int getBusyConnectionCount()
Get number of currently borrowed connections

Returns:

isShutdown

boolean isShutdown()
Determine if pool is shut down.

Returns:

getScore

double getScore()
Return implementation specific score to be used by weighted pool selection algorithms

Returns:

getMeanLatency

double getMeanLatency()
Get the average latency as calculated by the scoring strategy

Returns:

addLatencySample

void addLatencySample(long lastLatency,
                      long now)
Add a single latency sample after an operation on a connection belonging to this pool

Parameters:
lastLatency -


Copyright © 2012. All Rights Reserved.