Refine search
@Override public RedisSentinelConnection getSentinelConnection() { return new LettuceSentinelConnection(connectionProvider); }
@Override public void failover(NamedNode master) { Assert.notNull(master, "Redis node master must not be 'null' for failover."); Assert.hasText(master.getName(), "Redis master name must not be 'null' or empty for failover."); getSentinelCommands().failover(master.getName()); }
/** * Creates a {@link LettuceSentinelConnection} using a {@link LettuceConnectionProvider}. * * @param connectionProvider must not be {@literal null}. * @since 2.0 */ public LettuceSentinelConnection(LettuceConnectionProvider connectionProvider) { Assert.notNull(connectionProvider, "LettuceConnectionProvider must not be null!"); this.provider = connectionProvider; init(); }
/** * @param masterName * @see org.springframework.data.redis.connection.RedisSentinelCommands#remove(org.springframework.data.redis.connection.NamedNode) */ public void remove(String masterName) { Assert.hasText(masterName, "Name of redis master cannot be 'null' or empty when trying to remove."); getSentinelCommands().remove(masterName); }
@Override public List<RedisServer> masters() { try { return LettuceConverters.toListOfRedisServer(getSentinelCommands().masters()); } catch (Exception e) { throw EXCEPTION_TRANSLATION.translate(e); } }
/** * @param masterName * @see org.springframework.data.redis.connection.RedisSentinelCommands#slaves(org.springframework.data.redis.connection.NamedNode) * @return */ public List<RedisServer> slaves(String masterName) { Assert.hasText(masterName, "Name of redis master cannot be 'null' or empty when loading slaves."); try { return LettuceConverters.toListOfRedisServer(getSentinelCommands().slaves(masterName)); } catch (Exception e) { throw EXCEPTION_TRANSLATION.translate(e); } }
@Override public List<RedisServer> masters() { try { return LettuceConverters.toListOfRedisServer(getSentinelCommands().masters()); } catch (Exception e) { throw EXCEPTION_TRANSLATION.translate(e); } }
/** * Creates a {@link LettuceSentinelConnection} using a supplied {@link RedisClient}. * * @param redisClient must not be {@literal null}. */ public LettuceSentinelConnection(RedisClient redisClient) { Assert.notNull(redisClient, "Cannot create LettuceSentinelConnection using 'null' as client."); this.provider = new LettuceConnectionProvider() { @Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> t) { return t.cast(redisClient.connectSentinel()); } @Override public <T extends StatefulConnection<?, ?>> CompletableFuture<T> getConnectionAsync(Class<T> t) { return CompletableFuture.completedFuture(t.cast(connection)); } }; init(); }
@Override public void monitor(RedisServer server) { Assert.notNull(server, "Cannot monitor 'null' server."); Assert.hasText(server.getName(), "Name of server to monitor must not be 'null' or empty."); Assert.hasText(server.getHost(), "Host must not be 'null' for server to monitor."); Assert.notNull(server.getPort(), "Port must not be 'null' for server to monitor."); Assert.notNull(server.getQuorum(), "Quorum must not be 'null' for server to monitor."); getSentinelCommands().monitor(server.getName(), server.getHost(), server.getPort().intValue(), server.getQuorum().intValue()); }
/** * @param masterName * @see org.springframework.data.redis.connection.RedisSentinelCommands#remove(org.springframework.data.redis.connection.NamedNode) */ public void remove(String masterName) { Assert.hasText(masterName, "Name of redis master cannot be 'null' or empty when trying to remove."); getSentinelCommands().remove(masterName); }
@Override protected RedisSentinelConnection getSentinelConnection(RedisNode sentinel) { StatefulRedisSentinelConnection<String, String> connection = getConnection(sentinel); return new LettuceSentinelConnection(connection); }
@Override public List<RedisServer> masters() { try { return LettuceConverters.toListOfRedisServer(getSentinelCommands().masters()); } catch (Exception e) { throw EXCEPTION_TRANSLATION.translate(e); } }
/** * Creates a {@link LettuceSentinelConnection} using a supplied redis connection. * * @param connection native Lettuce connection, must not be {@literal null} */ protected LettuceSentinelConnection(StatefulRedisSentinelConnection<String, String> connection) { Assert.notNull(connection, "Cannot create LettuceSentinelConnection using 'null' as connection."); this.provider = new LettuceConnectionProvider() { @Override public <T extends StatefulConnection<?, ?>> T getConnection(Class<T> t) { return t.cast(connection); } @Override public <T extends StatefulConnection<?, ?>> CompletableFuture<T> getConnectionAsync(Class<T> t) { return CompletableFuture.completedFuture(t.cast(connection)); } }; init(); }
@Override public void failover(NamedNode master) { Assert.notNull(master, "Redis node master must not be 'null' for failover."); Assert.hasText(master.getName(), "Redis master name must not be 'null' or empty for failover."); getSentinelCommands().failover(master.getName()); }