Search in sources :

Example 1 with ClientConnectionsEntry

use of org.redisson.connection.ClientConnectionsEntry 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 2 with ClientConnectionsEntry

use of org.redisson.connection.ClientConnectionsEntry in project redisson by redisson.

the class LoadBalancerManager method returnPubSubConnection.

public void returnPubSubConnection(RedisPubSubConnection connection) {
    ClientConnectionsEntry entry = addr2Entry.get(connection.getRedisClient().getAddr());
    pubSubConnectionPool.returnConnection(entry, connection);
}
Also used : ClientConnectionsEntry(org.redisson.connection.ClientConnectionsEntry)

Example 3 with ClientConnectionsEntry

use of org.redisson.connection.ClientConnectionsEntry in project redisson by redisson.

the class LoadBalancerManager method returnConnection.

public void returnConnection(RedisConnection connection) {
    ClientConnectionsEntry entry = addr2Entry.get(connection.getRedisClient().getAddr());
    slaveConnectionPool.returnConnection(entry, connection);
}
Also used : ClientConnectionsEntry(org.redisson.connection.ClientConnectionsEntry)

Example 4 with ClientConnectionsEntry

use of org.redisson.connection.ClientConnectionsEntry in project redisson by redisson.

the class LoadBalancerManager method unfreeze.

public boolean unfreeze(String host, int port, FreezeReason freezeReason) {
    InetSocketAddress addr = new InetSocketAddress(host, port);
    ClientConnectionsEntry entry = addr2Entry.get(addr);
    if (entry == null) {
        throw new IllegalStateException("Can't find " + addr + " in slaves!");
    }
    synchronized (entry) {
        if (!entry.isFreezed()) {
            return false;
        }
        if ((freezeReason == FreezeReason.RECONNECT && entry.getFreezeReason() == FreezeReason.RECONNECT) || freezeReason != FreezeReason.RECONNECT) {
            entry.resetFailedAttempts();
            entry.setFreezed(false);
            entry.setFreezeReason(null);
            return true;
        }
    }
    return false;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ClientConnectionsEntry(org.redisson.connection.ClientConnectionsEntry)

Example 5 with ClientConnectionsEntry

use of org.redisson.connection.ClientConnectionsEntry in project redisson by redisson.

the class LoadBalancerManager method freeze.

public ClientConnectionsEntry freeze(String host, int port, FreezeReason freezeReason) {
    InetSocketAddress addr = new InetSocketAddress(host, port);
    ClientConnectionsEntry connectionEntry = addr2Entry.get(addr);
    return freeze(connectionEntry, freezeReason);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ClientConnectionsEntry(org.redisson.connection.ClientConnectionsEntry)

Aggregations

ClientConnectionsEntry (org.redisson.connection.ClientConnectionsEntry)7 InetSocketAddress (java.net.InetSocketAddress)4 RedisConnectionException (org.redisson.client.RedisConnectionException)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1