Java 类redis.clients.jedis.tests.utils.JedisSentinelTestUtil 实例源码

项目:JRediClients    文件:JedisSentinelTest.java   
@Test
public void sentinelFailover() throws InterruptedException {
  Jedis j = new Jedis(sentinelForFailover.getHost(), sentinelForFailover.getPort());
  Jedis j2 = new Jedis(sentinelForFailover.getHost(), sentinelForFailover.getPort());

  try {
    List<String> masterHostAndPort = j.sentinelGetMasterAddrByName(FAILOVER_MASTER_NAME);
    HostAndPort currentMaster = new HostAndPort(masterHostAndPort.get(0),
        Integer.parseInt(masterHostAndPort.get(1)));

    JedisSentinelTestUtil.waitForNewPromotedMaster(FAILOVER_MASTER_NAME, j, j2);

    masterHostAndPort = j.sentinelGetMasterAddrByName(FAILOVER_MASTER_NAME);
    HostAndPort newMaster = new HostAndPort(masterHostAndPort.get(0),
        Integer.parseInt(masterHostAndPort.get(1)));

    assertNotEquals(newMaster, currentMaster);
  } finally {
    j.close();
  }

}
项目:cachecloud    文件:JedisSentinelTest.java   
@Test
public void sentinelFailover() throws InterruptedException {
  Jedis j = new Jedis(sentinelForFailover.getHost(), sentinelForFailover.getPort());
  Jedis j2 = new Jedis(sentinelForFailover.getHost(), sentinelForFailover.getPort());

  try {
    List<String> masterHostAndPort = j.sentinelGetMasterAddrByName(FAILOVER_MASTER_NAME);
    HostAndPort currentMaster = new HostAndPort(masterHostAndPort.get(0),
        Integer.parseInt(masterHostAndPort.get(1)));

    JedisSentinelTestUtil.waitForNewPromotedMaster(FAILOVER_MASTER_NAME, j, j2);

    masterHostAndPort = j.sentinelGetMasterAddrByName(FAILOVER_MASTER_NAME);
    HostAndPort newMaster = new HostAndPort(masterHostAndPort.get(0),
        Integer.parseInt(masterHostAndPort.get(1)));

    assertNotEquals(newMaster, currentMaster);
  } finally {
    j.close();
  }

}
项目:Jedis    文件:JedisSentinelTest.java   
@Test
public void sentinelFailover() throws InterruptedException {
  Jedis j = new Jedis(sentinelForFailover.getHost(), sentinelForFailover.getPort());
  Jedis j2 = new Jedis(sentinelForFailover.getHost(), sentinelForFailover.getPort());

  try {
    List<String> masterHostAndPort = j.sentinelGetMasterAddrByName(FAILOVER_MASTER_NAME);
    HostAndPort currentMaster = new HostAndPort(masterHostAndPort.get(0),
        Integer.parseInt(masterHostAndPort.get(1)));

    JedisSentinelTestUtil.waitForNewPromotedMaster(FAILOVER_MASTER_NAME, j, j2);

    masterHostAndPort = j.sentinelGetMasterAddrByName(FAILOVER_MASTER_NAME);
    HostAndPort newMaster = new HostAndPort(masterHostAndPort.get(0),
        Integer.parseInt(masterHostAndPort.get(1)));

    assertNotEquals(newMaster, currentMaster);
  } finally {
    j.close();
  }

}
项目:JRediClients    文件:JedisSentinelPoolTest.java   
private void waitForFailover(JedisSentinelPool pool, HostAndPort oldMaster)
    throws InterruptedException {
  HostAndPort newMaster = JedisSentinelTestUtil.waitForNewPromotedMaster(MASTER_NAME,
    sentinelJedis1, sentinelJedis2);

  waitForJedisSentinelPoolRecognizeNewMaster(pool, newMaster);
}
项目:cachecloud    文件:JedisSentinelPoolTest.java   
private void waitForFailover(JedisSentinelPool pool, HostAndPort oldMaster)
    throws InterruptedException {
  HostAndPort newMaster = JedisSentinelTestUtil.waitForNewPromotedMaster(MASTER_NAME,
    sentinelJedis1, sentinelJedis2);

  waitForJedisSentinelPoolRecognizeNewMaster(pool, newMaster);
}
项目:Jedis    文件:JedisSentinelPoolTest.java   
private void waitForFailover(JedisSentinelPool pool, HostAndPort oldMaster)
    throws InterruptedException {
  HostAndPort newMaster = JedisSentinelTestUtil.waitForNewPromotedMaster(MASTER_NAME,
    sentinelJedis1, sentinelJedis2);

  waitForJedisSentinelPoolRecognizeNewMaster(pool, newMaster);
}