public class

SimpleHostConnectionPool

extends Object
implements HostConnectionPool<CL>
java.lang.Object
   ↳ com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool<CL>

Class Overview

Pool of connections for a single host. Features 1. Async open connection 2.

Summary

Nested Classes
interface SimpleHostConnectionPool.Listener<CL> Interface to notify the owning connection pool of up/down state changes. 
Fields
protected final ConnectionPoolConfiguration config
Public Constructors
SimpleHostConnectionPool(Host host, ConnectionFactory<CL> factory, ConnectionPoolMonitor monitor, ConnectionPoolConfiguration config, Listener<CL> listener)
Public Methods
void addLatencySample(long latency, long now)
Add a single latency sample after an operation on a connection belonging to this pool
Connection<CL> borrowConnection(int timeout)
Create a connection as long the max hasn't been reached@return
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)
Mark the host as down.
Connection<CL> openConnection()
Open a new connection synchronously@return
boolean returnConnection(Connection<CL> connection)
Return a connection to this host
void shutdown()
Completely shut down this connection pool as part of a client shutdown
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.netflix.astyanax.connectionpool.HostConnectionPool

Fields

protected final ConnectionPoolConfiguration config

Public Constructors

public SimpleHostConnectionPool (Host host, ConnectionFactory<CL> factory, ConnectionPoolMonitor monitor, ConnectionPoolConfiguration config, Listener<CL> listener)

Public Methods

public void addLatencySample (long latency, long now)

Add a single latency sample after an operation on a connection belonging to this pool

public Connection<CL> borrowConnection (int timeout)

Create a connection as long the max hasn't been reached@return

Parameters
timeout - Max wait timeout if max connections have been allocated and pool is empty. 0 to throw a MaxConnsPerHostReachedException.
Throws
TimeoutException if timeout specified and no new connection is available MaxConnsPerHostReachedException if max connections created and no timeout was specified
ConnectionException

public boolean closeConnection (Connection<CL> connection)

Close this connection and update internal state

public int getActiveConnectionCount ()

Get number of open connections including any that are currently borrowed and those that are currently idel

public int getBlockedThreadCount ()

Get number of threads blocked waiting for a free connection

public int getBusyConnectionCount ()

Get number of currently borrowed connections

public Host getHost ()

Get the host to which this pool is associated

public 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.

public double getMeanLatency ()

Get the average latency as calculated by the scoring strategy

public int getPendingConnectionCount ()

Get the number of pending connection open attempts

public double getScore ()

Return implementation specific score to be used by weighted pool selection algorithms

public int growConnections (int numConnections)

Create numConnections new connections and add them to the

public boolean isShutdown ()

Determine if pool is shut down.

public void markAsDown (ConnectionException reason)

Mark the host as down. No new connections will be created from this host. Connections currently in use will be allowed to continue processing.

public Connection<CL> openConnection ()

Open a new connection synchronously@return

public boolean returnConnection (Connection<CL> connection)

Return a connection to this host

Returns
  • True if connection was closed

public void shutdown ()

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

public String toString ()