CL - R - public abstract class AbstractExecuteWithFailoverImpl<CL,R> extends java.lang.Object implements ExecuteWithFailover<CL,R>
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. 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.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| Modifier and Type | Field and Description |
|---|---|
protected ConnectionPoolConfiguration |
config |
protected Connection<CL> |
connection |
| Constructor and Description |
|---|
AbstractExecuteWithFailoverImpl(ConnectionPoolConfiguration config,
ConnectionPoolMonitor monitor)
Public constructor
|
| Modifier and Type | Method and Description |
|---|---|
abstract Connection<CL> |
borrowConnection(Operation<CL,R> operation) |
abstract boolean |
canRetry() |
Host |
getCurrentHost() |
abstract HostConnectionPool<CL> |
getCurrentHostConnectionPool() |
protected void |
releaseConnection() |
OperationResult<R> |
tryOperation(Operation<CL,R> operation)
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
|
protected Connection<CL> connection
protected final ConnectionPoolConfiguration config
public AbstractExecuteWithFailoverImpl(ConnectionPoolConfiguration config, ConnectionPoolMonitor monitor) throws ConnectionException
config - monitor - ConnectionExceptionpublic abstract HostConnectionPool<CL> getCurrentHostConnectionPool()
HostConnectionPoolpublic abstract Connection<CL> borrowConnection(Operation<CL,R> operation) throws ConnectionException
operation - ConnectionConnectionExceptionpublic abstract boolean canRetry()
public OperationResult<R> tryOperation(Operation<CL,R> operation) throws ConnectionException
tryOperation in interface ExecuteWithFailover<CL,R>operation - OperationResultConnectionExceptionprotected void releaseConnection()