com.netflix.astyanax.connectionpool.impl
Class CountingConnectionPoolMonitor

java.lang.Object
  extended by com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor
All Implemented Interfaces:
ConnectionPoolMonitor
Direct Known Subclasses:
Slf4jConnectionPoolMonitorImpl

public class CountingConnectionPoolMonitor
extends java.lang.Object
implements ConnectionPoolMonitor

Impl for ConnectionPoolMonitor that employs counters to track stats such as

  1. operation success / failures / timeouts / socket timeouts / interrupted
  2. connection created / borrowed / returned / closed / create failures
  3. hosts added / removed / marked as down / reactivated
  4. transport failures and other useful stats


Constructor Summary
CountingConnectionPoolMonitor()
           
 
Method Summary
 long getBadRequestCount()
           
 long getConnectionBorrowedCount()
           
 long getConnectionClosedCount()
           
 long getConnectionCreatedCount()
           
 long getConnectionCreateFailedCount()
           
 long getConnectionReturnedCount()
           
 long getFailoverCount()
           
 long getHostActiveCount()
           
 long getHostAddedCount()
          Return the number of times a host was added to the pool.
 long getHostCount()
           
 long getHostDownCount()
           
 long getHostReactivatedCount()
           
 long getHostRemovedCount()
          Return the number of times any host was removed to the pool.
 java.util.Map<Host,HostStats> getHostStats()
           
 long getInterruptedCount()
           
 long getNoHostCount()
           
 long getNumBusyConnections()
           
 long getNumOpenConnections()
           
 long getOperationFailureCount()
           
 long getOperationSuccessCount()
           
 long getOperationTimeoutCount()
          Timeout waiting for a response from the cluster
 long getPoolExhaustedTimeoutCount()
          Timeout trying to get a connection from the pool
 long getSocketTimeoutCount()
           
 long getTransportErrorCount()
           
 long getUnknownErrorCount()
           
 void incConnectionBorrowed(Host host, long delay)
          Incremented for each connection borrowed
 void incConnectionClosed(Host host, java.lang.Exception reason)
          Closed a connection
 void incConnectionCreated(Host host)
          Created a connection successfully
 void incConnectionCreateFailed(Host host, java.lang.Exception reason)
          Attempt to create a connection failed
 void incConnectionReturned(Host host)
          Incremented for each connection returned.
 void incFailover(Host host, java.lang.Exception reason)
          An operation failed but the connection pool will attempt to fail over to another host/connection.
 void incOperationFailure(Host host, java.lang.Exception reason)
          Errors trying to execute an operation.
 void incOperationSuccess(Host host, long latency)
          Succeeded in executing an operation
 long notFoundCount()
           
 void onHostAdded(Host host, HostConnectionPool<?> pool)
          A host was added and given the associated pool.
 void onHostDown(Host host, java.lang.Exception reason)
          A host was identified as downed.
 void onHostReactivated(Host host, HostConnectionPool<?> pool)
          A host was reactivated after being marked down
 void onHostRemoved(Host host)
          A host was removed from the pool.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CountingConnectionPoolMonitor

public CountingConnectionPoolMonitor()
Method Detail

incOperationFailure

public void incOperationFailure(Host host,
                                java.lang.Exception reason)
Description copied from interface: ConnectionPoolMonitor
Errors trying to execute an operation.

Specified by:
incOperationFailure in interface ConnectionPoolMonitor

getOperationFailureCount

public long getOperationFailureCount()
Specified by:
getOperationFailureCount in interface ConnectionPoolMonitor

incOperationSuccess

public void incOperationSuccess(Host host,
                                long latency)
Description copied from interface: ConnectionPoolMonitor
Succeeded in executing an operation

Specified by:
incOperationSuccess in interface ConnectionPoolMonitor

getOperationSuccessCount

public long getOperationSuccessCount()
Specified by:
getOperationSuccessCount in interface ConnectionPoolMonitor

incConnectionCreated

public void incConnectionCreated(Host host)
Description copied from interface: ConnectionPoolMonitor
Created a connection successfully

Specified by:
incConnectionCreated in interface ConnectionPoolMonitor

getConnectionCreatedCount

public long getConnectionCreatedCount()
Specified by:
getConnectionCreatedCount in interface ConnectionPoolMonitor

incConnectionClosed

public void incConnectionClosed(Host host,
                                java.lang.Exception reason)
Description copied from interface: ConnectionPoolMonitor
Closed a connection

Specified by:
incConnectionClosed in interface ConnectionPoolMonitor
reason - TODO: Make the host available to this

getConnectionClosedCount

public long getConnectionClosedCount()
Specified by:
getConnectionClosedCount in interface ConnectionPoolMonitor

incConnectionCreateFailed

public void incConnectionCreateFailed(Host host,
                                      java.lang.Exception reason)
Description copied from interface: ConnectionPoolMonitor
Attempt to create a connection failed

Specified by:
incConnectionCreateFailed in interface ConnectionPoolMonitor

getConnectionCreateFailedCount

public long getConnectionCreateFailedCount()
Specified by:
getConnectionCreateFailedCount in interface ConnectionPoolMonitor

incConnectionBorrowed

public void incConnectionBorrowed(Host host,
                                  long delay)
Description copied from interface: ConnectionPoolMonitor
Incremented for each connection borrowed

Specified by:
incConnectionBorrowed in interface ConnectionPoolMonitor
Parameters:
host - Host from which the connection was borrowed
delay - Time spent in the connection pool borrowing the connection

getConnectionBorrowedCount

public long getConnectionBorrowedCount()
Specified by:
getConnectionBorrowedCount in interface ConnectionPoolMonitor

incConnectionReturned

public void incConnectionReturned(Host host)
Description copied from interface: ConnectionPoolMonitor
Incremented for each connection returned.

Specified by:
incConnectionReturned in interface ConnectionPoolMonitor
Parameters:
host - Host to which connection is returned

getConnectionReturnedCount

public long getConnectionReturnedCount()
Specified by:
getConnectionReturnedCount in interface ConnectionPoolMonitor

getPoolExhaustedTimeoutCount

public long getPoolExhaustedTimeoutCount()
Description copied from interface: ConnectionPoolMonitor
Timeout trying to get a connection from the pool

Specified by:
getPoolExhaustedTimeoutCount in interface ConnectionPoolMonitor

getSocketTimeoutCount

public long getSocketTimeoutCount()
Specified by:
getSocketTimeoutCount in interface ConnectionPoolMonitor
Returns:
Count of socket timeouts trying to execute an operation

getOperationTimeoutCount

public long getOperationTimeoutCount()
Description copied from interface: ConnectionPoolMonitor
Timeout waiting for a response from the cluster

Specified by:
getOperationTimeoutCount in interface ConnectionPoolMonitor

incFailover

public void incFailover(Host host,
                        java.lang.Exception reason)
Description copied from interface: ConnectionPoolMonitor
An operation failed but the connection pool will attempt to fail over to another host/connection.

Specified by:
incFailover in interface ConnectionPoolMonitor

getFailoverCount

public long getFailoverCount()
Specified by:
getFailoverCount in interface ConnectionPoolMonitor

onHostAdded

public void onHostAdded(Host host,
                        HostConnectionPool<?> pool)
Description copied from interface: ConnectionPoolMonitor
A host was added and given the associated pool. The pool is immutable and can be used to get info about the number of open connections

Specified by:
onHostAdded in interface ConnectionPoolMonitor

getHostAddedCount

public long getHostAddedCount()
Description copied from interface: ConnectionPoolMonitor
Return the number of times a host was added to the pool. This number will be incremented multiple times if the same hosts is added and removed multiple times. A constantly increating number of host added and host removed may indicate a problem with the host discovery service

Specified by:
getHostAddedCount in interface ConnectionPoolMonitor

onHostRemoved

public void onHostRemoved(Host host)
Description copied from interface: ConnectionPoolMonitor
A host was removed from the pool. This is usually called when a downed host is removed from the ring.

Specified by:
onHostRemoved in interface ConnectionPoolMonitor

getHostRemovedCount

public long getHostRemovedCount()
Description copied from interface: ConnectionPoolMonitor
Return the number of times any host was removed to the pool. This number will be incremented multiple times if the same hosts is added and removed multiple times. A constantly increating number of host added and host removed may indicate a problem with the host discovery service

Specified by:
getHostRemovedCount in interface ConnectionPoolMonitor

onHostDown

public void onHostDown(Host host,
                       java.lang.Exception reason)
Description copied from interface: ConnectionPoolMonitor
A host was identified as downed.

Specified by:
onHostDown in interface ConnectionPoolMonitor
reason - Exception that caused the host to be identified as down

getHostDownCount

public long getHostDownCount()
Specified by:
getHostDownCount in interface ConnectionPoolMonitor
Returns:
Return the number of times any host was marked as down.

onHostReactivated

public void onHostReactivated(Host host,
                              HostConnectionPool<?> pool)
Description copied from interface: ConnectionPoolMonitor
A host was reactivated after being marked down

Specified by:
onHostReactivated in interface ConnectionPoolMonitor

getHostReactivatedCount

public long getHostReactivatedCount()

getNoHostCount

public long getNoHostCount()
Specified by:
getNoHostCount in interface ConnectionPoolMonitor
Returns:
Count of times no hosts at all were available to execute an operation.

getUnknownErrorCount

public long getUnknownErrorCount()
Specified by:
getUnknownErrorCount in interface ConnectionPoolMonitor
Returns:
Get number of unknown errors

getInterruptedCount

public long getInterruptedCount()
Specified by:
getInterruptedCount in interface ConnectionPoolMonitor
Returns:
Number of times operations were cancelled

getTransportErrorCount

public long getTransportErrorCount()
Specified by:
getTransportErrorCount in interface ConnectionPoolMonitor
Returns:
Number of times transport errors occurred

getBadRequestCount

public long getBadRequestCount()
Specified by:
getBadRequestCount in interface ConnectionPoolMonitor
Returns:
Get number of invalid requests (i.e. bad argument values)

getNumBusyConnections

public long getNumBusyConnections()

getNumOpenConnections

public long getNumOpenConnections()

notFoundCount

public long notFoundCount()
Specified by:
notFoundCount in interface ConnectionPoolMonitor
Returns:
Tracks the number of column not found error

getHostCount

public long getHostCount()
Specified by:
getHostCount in interface ConnectionPoolMonitor
Returns:
Return the number of hosts in the pool

getHostActiveCount

public long getHostActiveCount()
Specified by:
getHostActiveCount in interface ConnectionPoolMonitor
Returns:
Return the number of active hosts

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getHostStats

public java.util.Map<Host,HostStats> getHostStats()
Specified by:
getHostStats in interface ConnectionPoolMonitor
Returns:
Return a mapping of all hosts and their statistics