List of usage examples for org.springframework.data.redis.connection RedisConnection info
@Nullable Properties info(String section);
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Load server information for given {@code selection}. * <p>/*from www .j a v a 2s. c o m*/ * See http://redis.io/commands/info * * @param section section * @return Properties */ public static Properties info(String section) { return redisTemplate.execute(new RedisCallback<Properties>() { @Override public Properties doInRedis(RedisConnection redis) throws DataAccessException { return redis.info(section); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Load server information for given {@code selection}. * <p>//from ww w.j a v a 2 s. c om * See http://redis.io/commands/info * * @param section section * @return Properties */ public Properties info(String section) { return redisTemplate.execute(new RedisCallback<Properties>() { @Override public Properties doInRedis(RedisConnection redis) throws DataAccessException { return redis.info(section); } }); }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@Test // DATAREDIS-762, DATAREDIS-869 public void factoryUsesElastiCacheMasterReplicaConnections() { assumeThat(String.format("No slaves connected to %s:%s.", SettingsUtils.getHost(), SettingsUtils.getPort()), connection.info("replication").getProperty("connected_slaves", "0").compareTo("0") > 0, is(true)); LettuceClientConfiguration configuration = LettuceTestClientConfiguration.builder().readFrom(ReadFrom.SLAVE) .build();//from w w w. j a v a 2s. com RedisStaticMasterReplicaConfiguration elastiCache = new RedisStaticMasterReplicaConfiguration( SettingsUtils.getHost()).node(SettingsUtils.getHost(), SettingsUtils.getPort() + 1); LettuceConnectionFactory factory = new LettuceConnectionFactory(elastiCache, configuration); factory.afterPropertiesSet(); RedisConnection connection = factory.getConnection(); try { assertThat(connection.ping(), is(equalTo("PONG"))); assertThat(connection.info().getProperty("role"), is(equalTo("slave"))); } finally { connection.close(); } factory.destroy(); }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@Test // DATAREDIS-762, DATAREDIS-869 public void factoryUsesElastiCacheMasterWithoutMaster() { assumeThat(/*from www .j a v a 2s.c o m*/ String.format("No replicas connected to %s:%s.", SettingsUtils.getHost(), SettingsUtils.getPort()), connection.info("replication").getProperty("connected_slaves", "0").compareTo("0") > 0, is(true)); LettuceClientConfiguration configuration = LettuceTestClientConfiguration.builder() .readFrom(ReadFrom.MASTER).build(); RedisStaticMasterReplicaConfiguration elastiCache = new RedisStaticMasterReplicaConfiguration( SettingsUtils.getHost(), SettingsUtils.getPort() + 1); LettuceConnectionFactory factory = new LettuceConnectionFactory(elastiCache, configuration); factory.afterPropertiesSet(); RedisConnection connection = factory.getConnection(); try { connection.ping(); fail("Expected RedisException: Master is currently unknown"); } catch (RedisSystemException e) { assertThat(e.getCause(), is(instanceOf(RedisException.class))); assertThat(e.getCause().getMessage(), containsString("Master is currently unknown")); } finally { connection.close(); } factory.destroy(); }
From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java
@Test // DATAREDIS-580, DATAREDIS-869 public void factoryUsesMasterReplicaConnections() { assumeThat(/*from www. j a v a2 s .co m*/ String.format("No replicas connected to %s:%s.", SettingsUtils.getHost(), SettingsUtils.getPort()), connection.info("replication").getProperty("connected_slaves", "0").compareTo("0") > 0, is(true)); LettuceClientConfiguration configuration = LettuceTestClientConfiguration.builder().readFrom(ReadFrom.SLAVE) .build(); LettuceConnectionFactory factory = new LettuceConnectionFactory(SettingsUtils.standaloneConfiguration(), configuration); factory.afterPropertiesSet(); RedisConnection connection = factory.getConnection(); try { assertThat(connection.ping(), is(equalTo("PONG"))); assertThat(connection.info().getProperty("role"), is(equalTo("slave"))); } finally { connection.close(); } factory.destroy(); }