/** * list of all active pools * @return {@link List<HostConnectionPool>} */ @Override public List<HostConnectionPool<CL>> getActivePools() { return ImmutableList.copyOf(topology.getAllPools().getPools()); }
public BagExecuteWithFailover(ConnectionPoolConfiguration config) throws ConnectionException { super(config, monitor); size = topology.getAllPools().getPools().size(); retryCountdown = Math.min(config.getMaxFailoverCount(), size); if (retryCountdown < 0) retryCountdown = size; }
/** * list of all active pools * @return {@link List<HostConnectionPool>} */ @Override public List<HostConnectionPool<CL>> getActivePools() { return ImmutableList.copyOf(topology.getAllPools().getPools()); }
public BagExecuteWithFailover(ConnectionPoolConfiguration config) throws ConnectionException { super(config, monitor); size = topology.getAllPools().getPools().size(); retryCountdown = Math.min(config.getMaxFailoverCount(), size); if (retryCountdown < 0) retryCountdown = size; }
@Override public Connection<CL> borrowConnection(Operation<CL, R> operation) throws ConnectionException { pool = null; connection = BagOfConnectionsConnectionPoolImpl.this.borrowConnection(operation); pool = connection.getHostConnectionPool(); return connection; }
@Override public Connection<CL> borrowConnection(Operation<CL, R> operation) throws ConnectionException { pool = null; connection = BagOfConnectionsConnectionPoolImpl.this.borrowConnection(operation); pool = connection.getHostConnectionPool(); return connection; }
@SuppressWarnings("unchecked") public <R> ExecuteWithFailover<CL, R> newExecuteWithFailover(Operation<CL, R> operation) throws ConnectionException { try { if (operation.getPinnedHost() != null) { HostConnectionPool<CL> pool = hosts.get(operation.getPinnedHost()); if (pool == null) { throw new NoAvailableHostsException("Host " + operation.getPinnedHost() + " not active"); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, Arrays.<HostConnectionPool<CL>> asList(pool), 0); } int index = roundRobinCounter.incrementAndGet(); if (index > MAX_RR_COUNTER) { roundRobinCounter.set(0); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, topology.getAllPools().getPools(), index); } catch (ConnectionException e) { monitor.incOperationFailure(e.getHost(), e); throw e; } } }
@SuppressWarnings("unchecked") public <R> ExecuteWithFailover<CL, R> newExecuteWithFailover(Operation<CL, R> operation) throws ConnectionException { try { if (operation.getPinnedHost() != null) { HostConnectionPool<CL> pool = hosts.get(operation.getPinnedHost()); if (pool == null) { throw new NoAvailableHostsException("Host " + operation.getPinnedHost() + " not active"); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, Arrays.<HostConnectionPool<CL>> asList(pool), 0); } int index = roundRobinCounter.incrementAndGet(); if (index > MAX_RR_COUNTER) { roundRobinCounter.set(0); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, topology.getAllPools().getPools(), index); } catch (ConnectionException e) { monitor.incOperationFailure(e.getHost(), e); throw e; } } }