org.springframework.data.redis.connection.RedisSentinelConnection Java Examples
The following examples show how to use
org.springframework.data.redis.connection.RedisSentinelConnection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringRedis.java From xmanager with Apache License 2.0 | 6 votes |
/** * redis 得到所有的master and slave 信息 */ @Test public void testGetAllMasterAndSlave() { RedisSentinelConnection conn = stringRedisTemplate.getConnectionFactory().getSentinelConnection(); for (RedisServer master : conn.masters()) { System.out.println("master => " + master);// 打印master信息 Collection<RedisServer> slaves = conn.slaves(master); // 打印该master下的所有slave信息 for (RedisServer slave : slaves) { System.out.println("slaves of " + master + " => " + slave); } System.out.println("--------------"); } }
Example #2
Source File: RedissonConnectionFactory.java From redisson with Apache License 2.0 | 6 votes |
@Override public RedisSentinelConnection getSentinelConnection() { if (!redisson.getConfig().isSentinelConfig()) { throw new InvalidDataAccessResourceUsageException("Redisson is not in Sentinel mode"); } SentinelConnectionManager manager = ((SentinelConnectionManager)((Redisson)redisson).getConnectionManager()); for (RedisClient client : manager.getSentinels()) { org.redisson.client.RedisConnection connection = client.connect(); try { String res = connection.sync(RedisCommands.PING); if ("pong".equalsIgnoreCase(res)) { return new RedissonSentinelConnection(connection); } } catch (Exception e) { log.warn("Can't connect to " + client, e); connection.closeAsync(); } } throw new InvalidDataAccessResourceUsageException("Sentinels are not found"); }
Example #3
Source File: RedissonConnectionFactory.java From redisson with Apache License 2.0 | 6 votes |
@Override public RedisSentinelConnection getSentinelConnection() { if (!redisson.getConfig().isSentinelConfig()) { throw new InvalidDataAccessResourceUsageException("Redisson is not in Sentinel mode"); } SentinelConnectionManager manager = ((SentinelConnectionManager)((Redisson)redisson).getConnectionManager()); for (RedisClient client : manager.getSentinels()) { org.redisson.client.RedisConnection connection = client.connect(); try { String res = connection.sync(RedisCommands.PING); if ("pong".equalsIgnoreCase(res)) { return new RedissonSentinelConnection(connection); } } catch (Exception e) { log.warn("Can't connect to " + client, e); connection.closeAsync(); } } throw new InvalidDataAccessResourceUsageException("Sentinels are not found"); }
Example #4
Source File: RedissonConnectionFactory.java From redisson with Apache License 2.0 | 6 votes |
@Override public RedisSentinelConnection getSentinelConnection() { if (!redisson.getConfig().isSentinelConfig()) { throw new InvalidDataAccessResourceUsageException("Redisson is not in Sentinel mode"); } SentinelConnectionManager manager = ((SentinelConnectionManager)((Redisson)redisson).getConnectionManager()); for (RedisClient client : manager.getSentinels()) { org.redisson.client.RedisConnection connection = client.connect(); try { String res = connection.sync(RedisCommands.PING); if ("pong".equalsIgnoreCase(res)) { return new RedissonSentinelConnection(connection); } } catch (Exception e) { log.warn("Can't connect to " + client, e); connection.closeAsync(); } } throw new InvalidDataAccessResourceUsageException("Sentinels are not found"); }
Example #5
Source File: RedissonConnectionFactory.java From redisson with Apache License 2.0 | 6 votes |
@Override public RedisSentinelConnection getSentinelConnection() { if (!redisson.getConfig().isSentinelConfig()) { throw new InvalidDataAccessResourceUsageException("Redisson is not in Sentinel mode"); } SentinelConnectionManager manager = ((SentinelConnectionManager)((Redisson)redisson).getConnectionManager()); for (RedisClient client : manager.getSentinels()) { org.redisson.client.RedisConnection connection = client.connect(); try { String res = connection.sync(RedisCommands.PING); if ("pong".equalsIgnoreCase(res)) { return new RedissonSentinelConnection(connection); } } catch (Exception e) { log.warn("Can't connect to " + client, e); connection.closeAsync(); } } throw new InvalidDataAccessResourceUsageException("Sentinels are not found"); }
Example #6
Source File: RedissonConnectionFactory.java From redisson with Apache License 2.0 | 6 votes |
@Override public RedisSentinelConnection getSentinelConnection() { if (!redisson.getConfig().isSentinelConfig()) { throw new InvalidDataAccessResourceUsageException("Redisson is not in Sentinel mode"); } SentinelConnectionManager manager = ((SentinelConnectionManager)((Redisson)redisson).getConnectionManager()); for (RedisClient client : manager.getSentinels()) { org.redisson.client.RedisConnection connection = client.connect(); try { String res = connection.sync(RedisCommands.PING); if ("pong".equalsIgnoreCase(res)) { return new RedissonSentinelConnection(connection); } } catch (Exception e) { log.warn("Can't connect to " + client, e); connection.closeAsync(); } } throw new InvalidDataAccessResourceUsageException("Sentinels are not found"); }
Example #7
Source File: LCNJedisFactoryProxy.java From tx-lcn with Apache License 2.0 | 4 votes |
@Override public RedisSentinelConnection getSentinelConnection() { System.out.println("getSentinelConnection"); return redisConnectionFactory.getSentinelConnection(); }
Example #8
Source File: TracingRedisSentinelConnection.java From java-redis-client with Apache License 2.0 | 4 votes |
public TracingRedisSentinelConnection(RedisSentinelConnection redisSentinelConnection, TracingConfiguration configuration) { this.redisSentinelConnection = redisSentinelConnection; this.helper = new TracingHelper(configuration); }
Example #9
Source File: TracingRedisConnection.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public RedisSentinelConnection getSentinelConnection() { return new TracingRedisSentinelConnection(connection.getSentinelConnection(), tracingConfiguration); }
Example #10
Source File: TracingRedisConnectionFactory.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public RedisSentinelConnection getSentinelConnection() { return new TracingRedisSentinelConnection(delegate.getSentinelConnection(), tracingConfiguration); }
Example #11
Source File: TracingRedisConnectionFactoryTest.java From java-redis-client with Apache License 2.0 | 4 votes |
@Test public void delegatesCallToGetSentinelConnection() { RedisSentinelConnection connection = connectionFactory.getSentinelConnection(); verify(delegate).getSentinelConnection(); assertTrue(connection instanceof TracingRedisSentinelConnection); }
Example #12
Source File: TracingRedisSentinelConnection.java From java-redis-client with Apache License 2.0 | 4 votes |
public TracingRedisSentinelConnection(RedisSentinelConnection redisSentinelConnection, TracingConfiguration configuration) { this.redisSentinelConnection = redisSentinelConnection; this.helper = new TracingHelper(configuration); }
Example #13
Source File: TracingRedisConnection.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public RedisSentinelConnection getSentinelConnection() { return new TracingRedisSentinelConnection(connection.getSentinelConnection(), tracingConfiguration); }
Example #14
Source File: TracingRedisConnectionFactory.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public RedisSentinelConnection getSentinelConnection() { return new TracingRedisSentinelConnection(delegate.getSentinelConnection(), tracingConfiguration); }
Example #15
Source File: TracingRedisConnectionFactoryTest.java From java-redis-client with Apache License 2.0 | 4 votes |
@Test public void delegatesCallToGetSentinelConnection() { RedisSentinelConnection connection = connectionFactory.getSentinelConnection(); verify(delegate).getSentinelConnection(); assertTrue(connection instanceof TracingRedisSentinelConnection); }