com.netflix.astyanax.connectionpool.impl
Class AbstractExecuteWithFailoverImpl<CL,R>
java.lang.Object
com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl<CL,R>
- Type Parameters:
CL - R -
- All Implemented Interfaces:
- ExecuteWithFailover<CL,R>
- Direct Known Subclasses:
- LeastOutstandingExecuteWithFailover, RoundRobinExecuteWithFailover
public abstract class AbstractExecuteWithFailoverImpl<CL,R>
- extends java.lang.Object
- implements ExecuteWithFailover<CL,R>
Abstract class that provides a basic impl of ExecuteWithFailover.
This is used within the context of a AbstractHostPartitionConnectionPool implementation, where
the abstract failover class repeatedly attempts to borrow a connection from the implementing ConnectionPool
and also releases the connection as cleanup. It also maintains stats about the attempts and informs latency metrics
on the exceptions when executing Operations or borrowing Connections from the pool.
Note that extending classes need to implement functionality to borrowConnection(Operation) that must be used
to execute the operation. They also need to implement canRetry() to tell this class
when to stop borrowing connections on failed attempts.
- See Also:
AbstractHostPartitionConnectionPool#executeWithFailover(Operation, com.netflix.astyanax.retry.RetryPolicy)} for references to this.,
RoundRobinExecuteWithFailover} as an example class that extends the functionality.,
RoundRobinConnectionPoolImpl} as an example of a {@link ConnectionPool} that employs the {@link RoundRobinExecuteWithFailover} for it's failover impl
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
connection
protected Connection<CL> connection
config
protected final ConnectionPoolConfiguration config
AbstractExecuteWithFailoverImpl
public AbstractExecuteWithFailoverImpl(ConnectionPoolConfiguration config,
ConnectionPoolMonitor monitor)
throws ConnectionException
- Public constructor
- Parameters:
config - monitor -
- Throws:
ConnectionException
getCurrentHost
public final Host getCurrentHost()
- Returns:
Host
getCurrentHostConnectionPool
public abstract HostConnectionPool<CL> getCurrentHostConnectionPool()
- Returns:
HostConnectionPool
borrowConnection
public abstract Connection<CL> borrowConnection(Operation<CL,R> operation)
throws ConnectionException
- Parameters:
operation -
- Returns:
Connection
- Throws:
ConnectionException
canRetry
public abstract boolean canRetry()
- Returns:
- boolean
tryOperation
public OperationResult<R> tryOperation(Operation<CL,R> operation)
throws ConnectionException
- Basic impl that repeatedly borrows a conn and tries to execute the operation while maintaining metrics for
success, conn attempts, failures and latencies for operation executions
- Specified by:
tryOperation in interface ExecuteWithFailover<CL,R>
- Parameters:
operation -
- Returns:
OperationResult
- Throws:
ConnectionException
releaseConnection
protected void releaseConnection()