Search in sources :

Example 1 with RedisConnectionException

use of org.redisson.client.RedisConnectionException in project redisson by redisson.

the class ConnectionPool method promiseFailure.

private void promiseFailure(ClientConnectionsEntry entry, RPromise<T> promise, T conn) {
    int attempts = entry.incFailedAttempts();
    if (attempts == config.getFailedAttempts()) {
        conn.closeAsync();
        checkForReconnect(entry);
    } else if (attempts < config.getFailedAttempts()) {
        releaseConnection(entry, conn);
    } else {
        conn.closeAsync();
    }
    releaseConnection(entry);
    RedisConnectionException cause = new RedisConnectionException(conn + " is not active!");
    promise.tryFailure(cause);
}
Also used : RedisConnectionException(org.redisson.client.RedisConnectionException)

Example 2 with RedisConnectionException

use of org.redisson.client.RedisConnectionException in project redisson by redisson.

the class LoadBalancerManager method getConnection.

public RFuture<RedisConnection> getConnection(RedisCommand<?> command, InetSocketAddress addr) {
    ClientConnectionsEntry entry = addr2Entry.get(addr);
    if (entry != null) {
        return slaveConnectionPool.get(command, entry);
    }
    RedisConnectionException exception = new RedisConnectionException("Can't find entry for " + addr);
    return connectionManager.newFailedFuture(exception);
}
Also used : ClientConnectionsEntry(org.redisson.connection.ClientConnectionsEntry) RedisConnectionException(org.redisson.client.RedisConnectionException)

Example 3 with RedisConnectionException

use of org.redisson.client.RedisConnectionException in project redisson by redisson.

the class ConnectionPool method get.

public RFuture<T> get(RedisCommand<?> command) {
    for (int j = entries.size() - 1; j >= 0; j--) {
        final ClientConnectionsEntry entry = getEntry();
        if (!entry.isFreezed() && tryAcquireConnection(entry)) {
            return acquireConnection(command, entry);
        }
    }
    List<InetSocketAddress> failedAttempts = new LinkedList<InetSocketAddress>();
    List<InetSocketAddress> freezed = new LinkedList<InetSocketAddress>();
    for (ClientConnectionsEntry entry : entries) {
        if (entry.isFreezed()) {
            freezed.add(entry.getClient().getAddr());
        } else {
            failedAttempts.add(entry.getClient().getAddr());
        }
    }
    StringBuilder errorMsg = new StringBuilder(getClass().getSimpleName() + " no available Redis entries. ");
    if (!freezed.isEmpty()) {
        errorMsg.append(" Disconnected hosts: " + freezed);
    }
    if (!failedAttempts.isEmpty()) {
        errorMsg.append(" Hosts disconnected due to `failedAttempts` limit reached: " + failedAttempts);
    }
    RedisConnectionException exception = new RedisConnectionException(errorMsg.toString());
    return connectionManager.newFailedFuture(exception);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ClientConnectionsEntry(org.redisson.connection.ClientConnectionsEntry) RedisConnectionException(org.redisson.client.RedisConnectionException) LinkedList(java.util.LinkedList)

Aggregations

RedisConnectionException (org.redisson.client.RedisConnectionException)3 ClientConnectionsEntry (org.redisson.connection.ClientConnectionsEntry)2 InetSocketAddress (java.net.InetSocketAddress)1 LinkedList (java.util.LinkedList)1