Examples of JedisPool


Examples of org.springside.modules.nosql.redis.pool.JedisPool

  private void initNodes(JedisPool... jedisPools) {
    for (int i = 0; i != jedisPools.length; i++) {
      // more entry the make the hash ring be more balance
      for (int n = 0; n < 128; n++) {
        final JedisPool jedisPool = jedisPools[i];
        nodes.put(this.algo.hash("SHARD-" + i + "-NODE-" + n), new JedisTemplate(jedisPool));
      }
    }
  }
View Full Code Here

Examples of redis.clients.jedis.JedisPool

    private JedisPool pool;

    @Inject
    public RedisClient(Settings settings) {
        try {
            pool = new JedisPool(new JedisPoolConfig(), settings.get("redis.host"), settings.getAsInt("redis.port", 6379));
        } catch (SettingsException e) {
            // ignore
        }
    }
View Full Code Here

Examples of redis.clients.jedis.JedisPool

            if (jedisPool == null) {
                GenericObjectPool.Config gConfig = new GenericObjectPool.Config();
                gConfig.testOnBorrow = true;
                gConfig.testWhileIdle = true;

                jedisPool = new JedisPool(gConfig, uri.getHost(), uri.getPort());

                config.properties().put(REDIS_SHARED_POOL, jedisPool);
            } else {
                disconnectSubscriber();
            }
View Full Code Here

Examples of redis.clients.jedis.JedisPool

  }

  Iterator<JedisPool> poolIterator = jc.getClusterNodes().values()
    .iterator();
  while (poolIterator.hasNext()) {
      JedisPool pool = poolIterator.next();
      try {
    pool.getResource();
    fail("JedisCluster's internal pools should be already destroyed");
      } catch (JedisConnectionException e) {
    // ok to go...
      }
  }
View Full Code Here

Examples of redis.clients.jedis.JedisPool

public class JedisPoolTest extends Assert {
    private static HostAndPort hnp = HostAndPortUtil.getRedisServers().get(0);

    @Test
    public void checkConnections() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(),
    hnp.getPort(), 2000);
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "bar");
  assertEquals("bar", jedis.get("foo"));
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
    }
View Full Code Here

Examples of redis.clients.jedis.JedisPool

  assertTrue(pool.isClosed());
    }

    @Test
    public void checkCloseableConnections() throws Exception {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(),
    hnp.getPort(), 2000);
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "bar");
  assertEquals("bar", jedis.get("foo"));
  pool.returnResource(jedis);
  pool.close();
  assertTrue(pool.isClosed());
    }
View Full Code Here

Examples of redis.clients.jedis.JedisPool

  assertTrue(pool.isClosed());
    }

    @Test
    public void checkConnectionWithDefaultPort() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(),
    hnp.getPort());
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "bar");
  assertEquals("bar", jedis.get("foo"));
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
    }
View Full Code Here

Examples of redis.clients.jedis.JedisPool

    }

    @Test
    public void checkJedisIsReusedWhenReturned() {

  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(),
    hnp.getPort());
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "0");
  pool.returnResource(jedis);

  jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.incr("foo");
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
    }
View Full Code Here

Examples of redis.clients.jedis.JedisPool

  assertTrue(pool.isClosed());
    }

    @Test
    public void checkPoolRepairedWhenJedisIsBroken() {
  JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(),
    hnp.getPort());
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.quit();
  pool.returnBrokenResource(jedis);

  jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.incr("foo");
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
    }
View Full Code Here

Examples of redis.clients.jedis.JedisPool

    @Test(expected = JedisConnectionException.class)
    public void checkPoolOverflow() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort());
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "0");

  Jedis newJedis = pool.getResource();
  newJedis.auth("foobared");
  newJedis.incr("foo");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.