Package redis.clients.jedis

Examples of redis.clients.jedis.JedisShardInfo


  jedis = new Jedis(redis2.getHost(), redis2.getPort());
  jedis.auth("foobared");
  jedis.flushAll();
  jedis.disconnect();

  JedisShardInfo shardInfo1 = new JedisShardInfo(redis1.getHost(),
    redis1.getPort());
  JedisShardInfo shardInfo2 = new JedisShardInfo(redis2.getHost(),
    redis2.getPort());
  shardInfo1.setPassword("foobared");
  shardInfo2.setPassword("foobared");
  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(shardInfo1);
  shards.add(shardInfo2);
  this.jedis = new ShardedJedis(shards);
View Full Code Here


    private List<JedisShardInfo> shards;

    @Before
    public void startUp() {
  shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo(redis1.getHost(), redis1.getPort()));
  shards.add(new JedisShardInfo(redis2.getHost(), redis2.getPort()));
  shards.get(0).setPassword("foobared");
  shards.get(1).setPassword("foobared");
  Jedis j = new Jedis(shards.get(0));
  j.connect();
  j.flushAll();
View Full Code Here

  j.disconnect();
  // shutdown shard 2 and check thay the pool returns an instance with c1
  // items on one shard
  // alter shard 1 and recreate pool
  pool.destroy();
  shards.set(1, new JedisShardInfo("localhost", 1234));
  pool = new ShardedJedisPool(redisConfig, shards);
  jedis = pool.getResource();
  Long actual = Long.valueOf(0);
  Long fails = Long.valueOf(0);
  for (int i = 0; i < 1000; i++) {
View Full Code Here

  j = new Jedis("localhost", 6379);
  j.auth("foobared");
  j.set("foo", "bar");

  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo("redis://:foobared@localhost:6380"));
  shards.add(new JedisShardInfo("redis://:foobared@localhost:6379"));

  GenericObjectPoolConfig redisConfig = new GenericObjectPoolConfig();
  ShardedJedisPool pool = new ShardedJedisPool(redisConfig, shards);

  Jedis[] jedises = pool.getResource().getAllShards()
View Full Code Here

  j = new Jedis("localhost", 6379);
  j.auth("foobared");
  j.set("foo", "bar");

  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo(new URI(
    "redis://:foobared@localhost:6380")));
  shards.add(new JedisShardInfo(new URI(
    "redis://:foobared@localhost:6379")));

  GenericObjectPoolConfig redisConfig = new GenericObjectPoolConfig();
  ShardedJedisPool pool = new ShardedJedisPool(redisConfig, shards);
View Full Code Here

  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);

  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo(new URI(
    "redis://:foobared@localhost:6380")));
  shards.add(new JedisShardInfo(new URI(
    "redis://:foobared@localhost:6379")));

  ShardedJedisPool pool = new ShardedJedisPool(config, shards);

  ShardedJedis jedis = pool.getResource();
View Full Code Here

  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);

  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo(new URI(
    "redis://:foobared@localhost:6380")));
  shards.add(new JedisShardInfo(new URI(
    "redis://:foobared@localhost:6379")));

  ShardedJedisPool pool = new ShardedJedisPool(config, shards);

  ShardedJedis jedis = pool.getResource();
View Full Code Here

    private static HostAndPort redis2 = HostAndPortUtil.getRedisServers()
      .get(1);

    private List<String> getKeysDifferentShard(ShardedJedis jedis) {
  List<String> ret = new ArrayList<String>();
  JedisShardInfo first = jedis.getShardInfo("a0");
  ret.add("a0");
  for (int i = 1; i < 100; ++i) {
      JedisShardInfo actual = jedis.getShardInfo("a" + i);
      if (actual != first) {
    ret.add("a" + i);
    break;

      }
View Full Code Here

    }

    @Test
    public void checkSharding() {
  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo(redis1.getHost(), redis1.getPort()));
  shards.add(new JedisShardInfo(redis2.getHost(), redis2.getPort()));
  ShardedJedis jedis = new ShardedJedis(shards);
  List<String> keys = getKeysDifferentShard(jedis);
  JedisShardInfo s1 = jedis.getShardInfo(keys.get(0));
  JedisShardInfo s2 = jedis.getShardInfo(keys.get(1));
  assertNotSame(s1, s2);
    }
View Full Code Here

    }

    @Test
    public void trySharding() {
  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  JedisShardInfo si = new JedisShardInfo(redis1.getHost(),
    redis1.getPort());
  si.setPassword("foobared");
  shards.add(si);
  si = new JedisShardInfo(redis2.getHost(), redis2.getPort());
  si.setPassword("foobared");
  shards.add(si);
  ShardedJedis jedis = new ShardedJedis(shards);
  jedis.set("a", "bar");
  JedisShardInfo s1 = jedis.getShardInfo("a");
  jedis.set("b", "bar1");
  JedisShardInfo s2 = jedis.getShardInfo("b");
  jedis.disconnect();

  Jedis j = new Jedis(s1.getHost(), s1.getPort());
  j.auth("foobared");
  assertEquals("bar", j.get("a"));
  j.disconnect();

  j = new Jedis(s2.getHost(), s2.getPort());
  j.auth("foobared");
  assertEquals("bar1", j.get("b"));
  j.disconnect();
    }
View Full Code Here

TOP

Related Classes of redis.clients.jedis.JedisShardInfo

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.