Package org.springside.modules.nosql.redis.pool

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


  public static EmbeddedRedis embeddedRedisRule = EmbeddedRedisRuleBuilder.newEmbeddedRedisRule().build();

  @Before
  public void setup() {
    Jedis embeddedRedis = EmbeddedRedisInstances.getInstance().getDefaultJedis();
    JedisPool jedisPool1 = Mockito.mock(JedisPool.class);
    Mockito.when(jedisPool1.getResource()).thenReturn(embeddedRedis);

    JedisPool jedisPool2 = Mockito.mock(JedisPool.class);
    Mockito.when(jedisPool2.getResource()).thenReturn(embeddedRedis);

    jedisTemplate = new JedisShardedTemplate(new JedisPool[] { jedisPool1, jedisPool2 });
  }
View Full Code Here

  public static EmbeddedRedis embeddedRedisRule = EmbeddedRedisRuleBuilder.newEmbeddedRedisRule().build();

  @Before
  public void setup() {
    Jedis embeddedRedis = EmbeddedRedisInstances.getInstance().getDefaultJedis();
    JedisPool jedisPool = Mockito.mock(JedisPool.class);
    Mockito.when(jedisPool.getResource()).thenReturn(embeddedRedis);

    jedisTemplate = new JedisTemplate(jedisPool);
  }
View Full Code Here

  private static ScheduledFuture statisticsTask;

  public static void main(String[] args) throws Exception {

    JedisPool pool = new JedisPoolBuilder().setDirectHostAndPort("localhost", "6379").setPoolSize(1).buildPool();
    try {
      JobDispatcher dispatcher = new JobDispatcher("ss", pool);
      JobStatistics statistics = new JobStatistics("ss", pool);

      startPrintStatistics(statistics);
      dispatcher.start();

      System.out.println("Hit enter to stop.");
      while (true) {
        char c = (char) System.in.read();
        if (c == '\n') {
          System.out.println("Shuting down");
          dispatcher.stop();
          stopPrintStatistics();
          return;
        }
      }
    } finally {
      pool.destroy();
    }
  }
View Full Code Here

  private static ScheduledFuture statisticsTask;

  public static void main(String[] args) throws Exception {

    JedisPool pool = new JedisPoolBuilder().setDirectHostAndPort("localhost", "6379").setPoolSize(1).buildPool();
    try {
      JobDispatcher dispatcher = new JobDispatcher("ss", pool);
      dispatcher.setReliable(true);

      JobStatistics statistics = new JobStatistics("ss", pool);

      startPrintStatistics(statistics);
      dispatcher.start();

      System.out.println("Hit enter to stop.");
      while (true) {
        char c = (char) System.in.read();
        if (c == '\n') {
          System.out.println("Shuting down");
          dispatcher.stop();
          stopPrintStatistics();
          return;
        }
      }
    } finally {
      pool.destroy();
    }
  }
View Full Code Here

public class MasterElectorDemo {

  public static void main(String[] args) throws Exception {

    JedisPool pool = new JedisPoolBuilder().setDirectHostAndPort("localhost", "6379").setPoolSize(1).buildPool();
    try {
      MasterElector masterElector = new MasterElector(pool, 5);

      masterElector.start();

      System.out.println("Hit enter to stop.");
      while (true) {
        char c = (char) System.in.read();
        if (c == '\n') {
          System.out.println("Shuting down");
          masterElector.stop();
          return;
        }
      }
    } finally {
      pool.destroy();
    }
  }
View Full Code Here

TOP

Related Classes of org.springside.modules.nosql.redis.pool.JedisPool

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.