Package redis.clients.jedis

Examples of redis.clients.jedis.JedisPool$JedisFactory


        shardInfo.setTimeout(timeout);
      }
    }

    if (usePool) {
      pool = new JedisPool(poolConfig, shardInfo.getHost(), shardInfo.getPort(), shardInfo.getTimeout(),
          shardInfo.getPassword());
    }
  }
View Full Code Here


    }
    return success;
  }

  private JedisPool createPool(String url) {
    JedisPool pool = null;
    if (!StringUtils.isEmpty(url)) {
      try {
        URI uri = URI.create(url);
        if (uri.getScheme() != null && uri.getScheme().equalsIgnoreCase("redis")) {
          int database = Protocol.DEFAULT_DATABASE;
          String password = null;
          if (uri.getUserInfo() != null) {
            password = uri.getUserInfo().split(":", 2)[1];
          }
          if (uri.getPath().indexOf('/') > -1) {
            database = Integer.parseInt(uri.getPath().split("/", 2)[1]);
          }
          pool = new JedisPool(new GenericObjectPoolConfig(), uri.getHost(), uri.getPort(), Protocol.DEFAULT_TIMEOUT, password, database);
        } else {
          pool = new JedisPool(url);
        }
      } catch (JedisException e) {
        log.error("failed to create a Redis pool!", e);
      }
    }
View Full Code Here

        }
        String password = null;
        if(!JOrphanUtils.isBlank(this.password)) {
            password = this.password;
        }
        this.pool = new JedisPool(config, this.host, port, timeout, password, database);
    }
View Full Code Here

        int port = config.port().get() == null ? Protocol.DEFAULT_PORT : config.port().get();
        int timeout = config.timeout().get() == null ? Protocol.DEFAULT_TIMEOUT : config.timeout().get();
        String password = config.password().get();
        int database = config.database().get() == null ? Protocol.DEFAULT_DATABASE : config.database().get();

        pool = new JedisPool( new JedisPoolConfig(), host, port, timeout, password, database );
    }
View Full Code Here

  @Test
  public void testSimpleOperationsAfterRun() throws Exception {
    redisServer = new RedisServer(6379);
    redisServer.start();
   
    JedisPool pool = null;
    Jedis jedis = null;
    try {
      pool = new JedisPool("localhost", 6379);
      jedis = pool.getResource();
      jedis.mset("abc", "1", "def", "2");
     
      assertEquals("1", jedis.mget("abc").get(0));
      assertEquals("2", jedis.mget("def").get(0));
      assertEquals(null, jedis.mget("xyz").get(0));
      pool.returnResource(jedis);
    } finally {
      if (jedis != null)
        pool.returnResource(jedis);
      redisServer.stop();
    }
  }
View Full Code Here

        redisServer2.start();
    }

    @Test
    public void testSimpleOperationsAfterRun() throws Exception {
        JedisPool pool = null;
        Jedis jedis = null;
        try {
            pool = new JedisPool("localhost", 6300);
            jedis = pool.getResource();
            jedis.mset("abc", "1", "def", "2");

            assertEquals("1", jedis.mget("abc").get(0));
            assertEquals("2", jedis.mget("def").get(0));
            assertEquals(null, jedis.mget("xyz").get(0));
            pool.returnResource(jedis);
        } finally {
            if (jedis != null)
                pool.returnResource(jedis);
        }
    }
View Full Code Here

  public void start() {
    if(logger.isInfoEnabled()) logger.info("Starting Redis River stream");

    // Next, we'll try to connect our redis pool
    try {
      this.jedisPool = new JedisPool(new JedisPoolConfig(), this.redisHost, this.redisPort, 0, this.redisPsw, this.redisDB);
    } catch (Exception e) {
      // We can't connect to redis for some reason, so
      // let's not even try to finish this.
      logger.error("Unable to allocate redis pool. Disabling River.");
      return;
View Full Code Here

public class RedisTaskResultStore implements TaskResultStore {
  private JedisPool _jedisPool;

  public RedisTaskResultStore(String redisServer, int redisPort, int timeout) {
    _jedisPool = new JedisPool(new JedisPoolConfig(), redisServer,
        redisPort, timeout);
  }
View Full Code Here

            @Override
            public <V> V execute(JedisCallback<V> cb) {
                if (delegate == null) {
                    try {
                        InitialContext ic = new InitialContext();
                        JedisPool jedisPool = (JedisPool) ic.lookup(jndiName);
                        delegate = new PooledJedisExecutor(jedisPool);
                    } catch (Exception e) {
                        throw new IllegalStateException("Unable to find instance of " + JedisExecutor.class.getName() + " in JNDI location " + jndiName + " : " + e.getMessage(), e);
                    }
                }
View Full Code Here

            @Override
            public <V> V execute(JedisCallback<V> cb) {
                if (delegate == null) {
                    try {
                        InitialContext ic = new InitialContext();
                        JedisPool jedisPool = (JedisPool) ic.lookup(jndiName);
                        delegate = new PooledJedisExecutor(jedisPool);
                    } catch (Exception e) {
                        throw new IllegalStateException("Unable to find instance of " + JedisExecutor.class.getName() + " in JNDI location " + jndiName + " : " + e.getMessage(), e);
                    }
                }
View Full Code Here

TOP

Related Classes of redis.clients.jedis.JedisPool$JedisFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.