public LeastOutstandingExecuteWithFailover(ConnectionPoolConfiguration config, ConnectionPoolMonitor monitor, List<HostConnectionPool<CL>> pools) throws ConnectionException { super(config, monitor); this.pools = Lists.newArrayList(pools); if (this.pools == null || this.pools.isEmpty()) { throw new NoAvailableHostsException("No hosts to borrow from"); } int size = this.pools.size(); retryCountdown = Math.min(config.getMaxFailoverCount(), size); if (retryCountdown < 0) retryCountdown = size; else if (retryCountdown == 0) retryCountdown = 1; waitDelta = config.getMaxTimeoutWhenExhausted() / retryCountdown; }
public LeastOutstandingExecuteWithFailover(ConnectionPoolConfiguration config, ConnectionPoolMonitor monitor, List<HostConnectionPool<CL>> pools) throws ConnectionException { super(config, monitor); this.pools = Lists.newArrayList(pools); if (this.pools == null || this.pools.isEmpty()) { throw new NoAvailableHostsException("No hosts to borrow from"); } int size = this.pools.size(); retryCountdown = Math.min(config.getMaxFailoverCount(), size); if (retryCountdown < 0) retryCountdown = size; else if (retryCountdown == 0) retryCountdown = 1; waitDelta = config.getMaxTimeoutWhenExhausted() / retryCountdown; }
public Keyspace toHost(String hostName) throws ConnectionException { Host host = _keyspace.getConnectionPool().getPools().stream() .map(HostConnectionPool::getHost) .filter(poolHost -> hostName.equals(poolHost.getHostName())) .findFirst().orElseThrow(() -> new NoAvailableHostsException("No hosts pools found")); return pinToVerifiedHost(host); }
public RoundRobinExecuteWithFailover(ConnectionPoolConfiguration config, ConnectionPoolMonitor monitor, List<HostConnectionPool<CL>> pools, int index) throws ConnectionException { super(config, monitor); this.index = index; this.pools = pools; if (pools == null || pools.isEmpty()) { throw new NoAvailableHostsException("No hosts to borrow from"); } size = pools.size(); retryCountdown = Math.min(config.getMaxFailoverCount(), size); if (retryCountdown < 0) retryCountdown = size; else if (retryCountdown == 0) retryCountdown = 1; waitDelta = config.getMaxTimeoutWhenExhausted() / retryCountdown; }
public RoundRobinExecuteWithFailover(ConnectionPoolConfiguration config, ConnectionPoolMonitor monitor, List<HostConnectionPool<CL>> pools, int index) throws ConnectionException { super(config, monitor); this.index = index; this.pools = pools; if (pools == null || pools.isEmpty()) { throw new NoAvailableHostsException("No hosts to borrow from"); } size = pools.size(); retryCountdown = Math.min(config.getMaxFailoverCount(), size); if (retryCountdown < 0) retryCountdown = size; else if (retryCountdown == 0) retryCountdown = 1; waitDelta = config.getMaxTimeoutWhenExhausted() / retryCountdown; }
public Keyspace toHost(String hostName) throws ConnectionException { Host host = _keyspace.getConnectionPool().getPools().stream() .map(HostConnectionPool::getHost) .filter(poolHost -> hostName.equals(poolHost.getHostName())) .findFirst().orElseThrow(() -> new NoAvailableHostsException("No hosts pools found")); return pinToVerifiedHost(host); }
@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; }
/** * Returns a view of the provided Keyspace that pins all operations to the provided host. */ public Keyspace toHost(Host host) throws ConnectionException { if (!_keyspace.getConnectionPool().getPools().stream() .map(HostConnectionPool::getHost) .anyMatch(poolHost -> poolHost.equals(host))) { throw new NoAvailableHostsException("Host not found in pool"); } return pinToVerifiedHost(host); }
/** * Returns a view of the provided Keyspace that pins all operations to the provided host. */ public Keyspace toHost(Host host) throws ConnectionException { if (!_keyspace.getConnectionPool().getPools().stream() .map(HostConnectionPool::getHost) .anyMatch(poolHost -> poolHost.equals(host))) { throw new NoAvailableHostsException("Host not found in pool"); } return pinToVerifiedHost(host); }
@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; } } }
HostConnectionPool<CL> pool = hosts.get(op.getPinnedHost()); if (pool == null) { throw new NoAvailableHostsException("Host " + op.getPinnedHost() + " not active");
HostConnectionPool<CL> pool = hosts.get(op.getPinnedHost()); if (pool == null) { throw new NoAvailableHostsException("Host " + op.getPinnedHost() + " not active");