Package org.springside.examples.showcase.demos.redis.elector

Source Code of org.springside.examples.showcase.demos.redis.elector.MasterElectorDemo

/*******************************************************************************
* Copyright (c) 2005, 2014 springside.github.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
*******************************************************************************/
package org.springside.examples.showcase.demos.redis.elector;

import org.springside.modules.nosql.redis.pool.JedisPool;
import org.springside.modules.nosql.redis.pool.JedisPoolBuilder;
import org.springside.modules.nosql.redis.service.elector.MasterElector;

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();
    }
  }

}
TOP

Related Classes of org.springside.examples.showcase.demos.redis.elector.MasterElectorDemo

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.