Ejemplo n.º 1
0
  @Override
  public void destroy() {
    masterSwitchListener.shutdown();

    destroyInternalPool();

    try {
      logger.info("Waiting for MasterSwitchListener thread finish");
      masterSwitchListener.join();
      logger.info("MasterSwitchListener thread finished");
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
Ejemplo n.º 2
0
  /**
   * Creates a new instance of <code>JedisSentinelPool</code>.
   *
   * @param sentinelInfos Array of connection information to sentinel instances.
   * @param masterName One sentinel can monitor several redis master-slave pair, use master name to
   *     identify it.
   * @param masterAddtionalInfo The master host and port would dynamic get from sentinel, and the
   *     other information like password, timeout store in it.
   * @param masterPoolConfig Configuration of redis pool.
   */
  public JedisSentinelPool(
      ConnectionInfo[] sentinelInfos,
      String masterName,
      ConnectionInfo masterAddtionalInfo,
      JedisPoolConfig masterPoolConfig) {
    // check and assign parameter, all parameter can't not be null or empty
    assertArgument(
        ((sentinelInfos != null) && (sentinelInfos.length != 0)), "seintinelInfos is not set");
    this.sentinelInfos = sentinelInfos;

    assertArgument(masterAddtionalInfo != null, "masterAddtionalInfo is not set");
    this.masterAddtionalInfo = masterAddtionalInfo;

    assertArgument(((masterName != null) && !masterName.isEmpty()), "masterName is not set");
    this.masterName = masterName;

    assertArgument(masterPoolConfig != null, "masterPoolConfig is not set");
    this.masterPoolConfig = masterPoolConfig;

    // Start MasterSwitchListener thread ,internal poll will be start in the thread
    masterSwitchListener = new MasterSwitchListener();
    masterSwitchListener.start();
  }