Package redis.clients.jedis

Examples of redis.clients.jedis.Jedis


      @Override
      public void onSubscribe(String channel, int subscribedChannels) {
    count++;
    // All channels are subscribed
    if (count == 3) {
        Jedis otherJedis = createJedis();
        List<String> activeChannels = otherJedis
          .pubsubChannels("test*");
        assertTrue(expectedActiveChannels
          .containsAll(activeChannels));
        unsubscribe();
    }
View Full Code Here


      @Override
      public void onPSubscribe(String pattern, int subscribedChannels) {
    count++;
    if (count == 3) {
        Jedis otherJedis = createJedis();
        Long numPatterns = otherJedis.pubsubNumPat();
        assertEquals(new Long(2l), numPatterns);
        punsubscribe();
    }
      }
View Full Code Here

      @Override
      public void onSubscribe(String channel, int subscribedChannels) {
    count++;
    if (count == 2) {
        Jedis otherJedis = createJedis();
        Map<String, String> numSub = otherJedis.pubsubNumSub(
          "testchannel1", "testchannel2");
        assertEquals(expectedNumSub, numSub);
        unsubscribe();
    }
      }
View Full Code Here

    }

    @Test(expected = JedisConnectionException.class)
    public void handleClientOutputBufferLimitForSubscribeTooSlow()
      throws InterruptedException {
  final Jedis j = createJedis();
  final AtomicBoolean exit = new AtomicBoolean(false);

  final Thread t = new Thread(new Runnable() {
      public void run() {
    try {

        // we already set jedis1 config to
        // client-output-buffer-limit pubsub 256k 128k 5
        // it means if subscriber delayed to receive over 256k or
        // 128k continuously 5 sec,
        // redis disconnects subscriber

        // we publish over 100M data for making situation for exceed
        // client-output-buffer-limit
        String veryLargeString = makeLargeString(10485760);

        // 10M * 10 = 100M
        for (int i = 0; i < 10 && !exit.get(); i++) {
      j.publish("foo", veryLargeString);
        }

        j.disconnect();
    } catch (Exception ex) {
    }
      }
  });
  t.start();
View Full Code Here

    try {
        // sleep 100ms to make sure that monitor thread runs first
        Thread.sleep(100);
    } catch (InterruptedException e) {
    }
    Jedis j = new Jedis("localhost");
    j.auth("foobared");
    for (int i = 0; i < 5; i++) {
        j.incr("foobared");
    }
    j.disconnect();
      }
  }).start();

  jedis.monitor(new JedisMonitor() {
      private int count = 0;
View Full Code Here

    private HostAndPort nodeInfo4 = HostAndPortUtil.getClusterServers().get(3);
    protected Logger log = Logger.getLogger(getClass().getName());

    @Before
    public void setUp() throws InterruptedException {
  node1 = new Jedis(nodeInfo1.getHost(), nodeInfo1.getPort());
  node1.connect();
  node1.flushAll();

  node2 = new Jedis(nodeInfo2.getHost(), nodeInfo2.getPort());
  node2.connect();
  node2.flushAll();

  node3 = new Jedis(nodeInfo3.getHost(), nodeInfo3.getPort());
  node3.connect();
  node3.flushAll();

  node4 = new Jedis(nodeInfo4.getHost(), nodeInfo4.getPort());
  node4.connect();
  node4.flushAll();

  // ---- configure cluster
View Full Code Here

  super();
    }

    @Before
    public void setUp() throws Exception {
  jedis = new Jedis(hnp.getHost(), hnp.getPort(), 500);
  jedis.connect();
  jedis.auth("foobared");
  jedis.configSet("timeout", "300");
  jedis.flushAll();
    }
View Full Code Here

      j.close();
  }
    }

    private void ensureRemoved(String masterName) {
  Jedis j = new Jedis(sentinel.getHost(), sentinel.getPort());
  try {
      j.sentinelRemove(masterName);
  } catch (JedisDataException e) {
  } finally {
      j.close();
  }
    }
View Full Code Here

    public void tearDown() {
  jedis.disconnect();
    }

    protected Jedis createJedis() {
  Jedis j = new Jedis(hnp.getHost(), hnp.getPort());
  j.connect();
  j.auth("foobared");
  j.flushAll();
  return j;
    }
View Full Code Here

    @Before
    public void setUp() throws Exception {
  sentinels.add(sentinel1.toString());
  sentinels.add(sentinel2.toString());

  sentinelJedis1 = new Jedis(sentinel1.getHost(), sentinel1.getPort());
  sentinelJedis2 = new Jedis(sentinel2.getHost(), sentinel2.getPort());
    }
View Full Code Here

TOP

Related Classes of redis.clients.jedis.Jedis

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.