Search in sources :

Example 1 with MissingRequiredConfiguration

use of com.netflix.spinnaker.kork.jedis.exception.MissingRequiredConfiguration in project kork by spinnaker.

the class JedisPoolFactory method build.

public Pool<Jedis> build(String name, JedisDriverProperties properties) {
    if (properties.connection == null || "".equals(properties.connection)) {
        throw new MissingRequiredConfiguration("Jedis client must have a connection defined");
    }
    URI redisConnection = URI.create(properties.connection);
    String host = redisConnection.getHost();
    int port = redisConnection.getPort() == -1 ? Protocol.DEFAULT_PORT : redisConnection.getPort();
    int database = parseDatabase(redisConnection.getPath());
    String password = parsePassword(redisConnection.getUserInfo());
    GenericObjectPoolConfig objectPoolConfig = properties.poolConfig;
    return new JedisPool(objectPoolConfig, host, port, properties.timeoutMs, password, database, name);
}
Also used : MissingRequiredConfiguration(com.netflix.spinnaker.kork.jedis.exception.MissingRequiredConfiguration) GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) JedisPool(redis.clients.jedis.JedisPool) URI(java.net.URI)

Example 2 with MissingRequiredConfiguration

use of com.netflix.spinnaker.kork.jedis.exception.MissingRequiredConfiguration in project kork by spinnaker.

the class JedisPoolFactory method build.

public Pool<Jedis> build(String name, JedisDriverProperties properties, GenericObjectPoolConfig objectPoolConfig) {
    if (properties.connection == null || "".equals(properties.connection)) {
        throw new MissingRequiredConfiguration("Jedis client must have a connection defined");
    }
    RedisClientConnectionProperties cxp = new RedisClientConnectionProperties(URI.create(properties.connection));
    GenericObjectPoolConfig poolConfig = Optional.ofNullable(properties.poolConfig).orElse(objectPoolConfig);
    return new InstrumentedJedisPool(registry, // offerings
    new JedisPool(poolConfig, cxp.addr(), cxp.port(), properties.timeoutMs, cxp.password(), cxp.database(), null, cxp.isSSL()), name);
}
Also used : MissingRequiredConfiguration(com.netflix.spinnaker.kork.jedis.exception.MissingRequiredConfiguration) GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) InstrumentedJedisPool(com.netflix.spinnaker.kork.jedis.telemetry.InstrumentedJedisPool) JedisPool(redis.clients.jedis.JedisPool) InstrumentedJedisPool(com.netflix.spinnaker.kork.jedis.telemetry.InstrumentedJedisPool)

Aggregations

MissingRequiredConfiguration (com.netflix.spinnaker.kork.jedis.exception.MissingRequiredConfiguration)2 GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)2 JedisPool (redis.clients.jedis.JedisPool)2 InstrumentedJedisPool (com.netflix.spinnaker.kork.jedis.telemetry.InstrumentedJedisPool)1 URI (java.net.URI)1