Example usage for org.springframework.data.redis.connection.jedis JedisConnectionFactory getHostName

List of usage examples for org.springframework.data.redis.connection.jedis JedisConnectionFactory getHostName

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection.jedis JedisConnectionFactory getHostName.

Prototype

public String getHostName() 

Source Link

Document

Returns the Redis hostname.

Usage

From source file:org.cloudfoundry.reconfiguration.spring.RedisCloudServiceBeanFactoryPostProcessorTest.java

private void assertConfiguration(JedisConnectionFactory factory, String password, String host, int port) {
    assertEquals(password, factory.getPassword());
    assertEquals(host, factory.getHostName());
    assertEquals(port, factory.getPort());
}

From source file:com.snowstore.mercury.indicator.RedisHealthIndicator.java

@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    if (valid) {/*  www.  j a  va2  s.co  m*/
        RedisConnection connection = RedisConnectionUtils.getConnection(this.redisConnectionFactory);
        try {
            Properties info = connection.info();
            builder.up().withDetail("version", info.getProperty("redis_version"));
            if (redisConnectionFactory instanceof JedisConnectionFactory) {
                JedisConnectionFactory jedisConnectionFactory = (JedisConnectionFactory) redisConnectionFactory;
                builder.withDetail(SERVER, jedisConnectionFactory.getHostName() + ":"
                        + jedisConnectionFactory.getPort() + ":" + jedisConnectionFactory.getDatabase());
            }
            addBuilder(builder);
        } finally {
            RedisConnectionUtils.releaseConnection(connection, this.redisConnectionFactory);
        }
    } else {
        builder.none();
    }
}

From source file:com.gopivotal.cloudfoundry.test.core.RedisUtils.java

public String getUrl(RedisConnectionFactory redisConnectionFactory) {
    if (isClass(redisConnectionFactory, "com.gopivotal.cloudfoundry.test.core.FakeRedisConnectionFactory")) {
        return "redis://fake";
    } else if (isClass(redisConnectionFactory,
            "org.springframework.data.redis.connection.jedis" + ".JedisConnectionFactory")) {
        org.springframework.data.redis.connection.jedis.JedisConnectionFactory jedisConnectionFactory = (org.springframework.data.redis.connection.jedis.JedisConnectionFactory) redisConnectionFactory;
        String host = jedisConnectionFactory.getHostName();
        int port = jedisConnectionFactory.getPort();

        return String.format("redis://%s:%d", host, port);
    }//from   w w  w . j ava2s .c  om

    return String.format("Unable to determine URL for RedisConnectionFactory of type %s",
            redisConnectionFactory.getClass().getName());
}

From source file:org.cloudfoundry.test.ServiceController.java

@RequestMapping(value = "/redis/host", method = RequestMethod.GET)
public ResponseEntity<String> getRedisHostAddress() {
    if (serviceHolder.getRedisConnectionFactory() == null) {
        return new ResponseEntity<String>(HttpStatus.NOT_FOUND);
    }//from   w w w. j  a  v a 2 s.com
    // Jedis is the only client we currently support
    JedisConnectionFactory jedisConnectionFactory = (JedisConnectionFactory) serviceHolder
            .getRedisConnectionFactory();
    return new ResponseEntity<String>(
            jedisConnectionFactory.getHostName() + ':' + jedisConnectionFactory.getPort(), HttpStatus.OK);
}