| | |
| | | |
| | | |
| | | /** |
| | | * A load balancing connection factory allocates connections using the |
| | | * provided algorithm. |
| | | * A load balancing connection factory allocates connections using the provided |
| | | * algorithm. |
| | | */ |
| | | final class LoadBalancingConnectionFactory extends |
| | | AbstractConnectionFactory |
| | | final class LoadBalancingConnectionFactory extends AbstractConnectionFactory |
| | | { |
| | | private final LoadBalancingAlgorithm algorithm; |
| | | |
| | | |
| | | |
| | | public LoadBalancingConnectionFactory(LoadBalancingAlgorithm algorithm) |
| | | public LoadBalancingConnectionFactory(final LoadBalancingAlgorithm algorithm) |
| | | { |
| | | Validator.ensureNotNull(algorithm); |
| | | this.algorithm = algorithm; |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public FutureResult<AsynchronousConnection> getAsynchronousConnection( |
| | | ResultHandler<AsynchronousConnection> resultHandler) |
| | | final ResultHandler<AsynchronousConnection> resultHandler) |
| | | { |
| | | ConnectionFactory factory; |
| | | |
| | |
| | | { |
| | | factory = algorithm.getNextConnectionFactory(); |
| | | } |
| | | catch (ErrorResultException e) |
| | | catch (final ErrorResultException e) |
| | | { |
| | | AbstractFutureResult<AsynchronousConnection> future = new AbstractFutureResult<AsynchronousConnection>( |
| | | resultHandler) |
| | | final AbstractFutureResult<AsynchronousConnection> future = |
| | | new AbstractFutureResult<AsynchronousConnection>(resultHandler) |
| | | { |
| | | public int getRequestID() |
| | | { |