Examples of blockUntilActive()


Examples of com.xiaomi.infra.chronos.zookeeper.FailoverWatcher.blockUntilActive()

  @Test
  public void testBlockUntilActive() throws IOException, KeeperException, InterruptedException {
    // the first server, expect to be active master
    HostPort hostPort1 = new HostPort("127.0.0.1", 11111);
    FailoverWatcher failoverWatcher1 = createFailoverWatcher(hostPort1);
    failoverWatcher1.blockUntilActive();

    assertTrue(failoverWatcher1.hasActiveServer());
    String activeServer = new String(ZooKeeperUtil.getDataAndWatch(failoverWatcher1,
      failoverWatcher1.masterZnode));
    assertTrue(activeServer.equals(hostPort1.getHostPort()));
View Full Code Here

Examples of com.xiaomi.infra.chronos.zookeeper.FailoverWatcher.blockUntilActive()

    HostPort hostPort2 = new HostPort("127.0.0.1", 22222);
    final FailoverWatcher failoverWatcher2 = createFailoverWatcher(hostPort2);
    Thread thread2 = new Thread() {
      @Override
      public void run() {
        failoverWatcher2.blockUntilActive();
      }
    };
    thread2.start();

    Thread.sleep(500); // wait for second watcher to create znode
View Full Code Here

Examples of com.xiaomi.infra.chronos.zookeeper.FailoverWatcher.blockUntilActive()

  @Test
  public void testRestartActiveMaster() throws IOException, KeeperException {
    // the first server, expect to be active master
    HostPort hostPort1 = new HostPort("127.0.0.1", 11111);
    FailoverWatcher failoverWatcher1 = createFailoverWatcher(hostPort1);
    failoverWatcher1.blockUntilActive();

    assertTrue(failoverWatcher1.hasActiveServer());
    String activeServer = new String(ZooKeeperUtil.getDataAndWatch(failoverWatcher1,
      failoverWatcher1.masterZnode));
    assertTrue(activeServer.equals(hostPort1.getHostPort()));
View Full Code Here

Examples of com.xiaomi.infra.chronos.zookeeper.FailoverWatcher.blockUntilActive()

      failoverWatcher1.masterZnode));
    assertTrue(activeServer.equals(hostPort1.getHostPort()));

    // the same server start, expect to restart active master
    FailoverWatcher failoverWatcher2 = createFailoverWatcher(hostPort1);
    failoverWatcher2.blockUntilActive();
    assertTrue(failoverWatcher2.hasActiveServer());
    String activeServer2 = new String(ZooKeeperUtil.getDataAndWatch(failoverWatcher1,
      failoverWatcher1.masterZnode));
    assertTrue(activeServer2.equals(hostPort1.getHostPort()));
View Full Code Here

Examples of com.xiaomi.infra.chronos.zookeeper.FailoverWatcher.blockUntilActive()

  @Test
  public void testHandleMasterNodeChange() throws IOException, KeeperException,
      InterruptedException {
    HostPort hostPort1 = new HostPort("127.0.0.1", 11111);
    FailoverWatcher failoverWatcher1 = createFailoverWatcher(hostPort1);
    failoverWatcher1.blockUntilActive();

    // hostPort2 is backup master
    HostPort hostPort2 = new HostPort("127.0.0.1", 22222);
    final FailoverWatcher failoverWatcher2 = createFailoverWatcher(hostPort2);
    Thread thread2 = new Thread() {
View Full Code Here

Examples of com.xiaomi.infra.chronos.zookeeper.FailoverWatcher.blockUntilActive()

    HostPort hostPort2 = new HostPort("127.0.0.1", 22222);
    final FailoverWatcher failoverWatcher2 = createFailoverWatcher(hostPort2);
    Thread thread2 = new Thread() {
      @Override
      public void run() {
        failoverWatcher2.blockUntilActive();
      }
    };
    thread2.start();

    // hostPort3 is backup master
View Full Code Here

Examples of com.xiaomi.infra.chronos.zookeeper.FailoverWatcher.blockUntilActive()

    HostPort hostPort3 = new HostPort("127.0.0.1", 33333);
    final FailoverWatcher failoverWatcher3 = createFailoverWatcher(hostPort3);
    Thread thread3 = new Thread() {
      @Override
      public void run() {
        failoverWatcher3.blockUntilActive();
      }
    };
    thread3.start();

    // delete the master node, then one of them will become master, the other will be backup master
View Full Code Here

Examples of com.xiaomi.infra.chronos.zookeeper.FailoverWatcher.blockUntilActive()

  @Test
  public void testCloseMaster() throws KeeperException, IOException {
    HostPort hostPort1 = new HostPort("127.0.0.1", 11111);
    FailoverWatcher failoverWatcher1 = createFailoverWatcher(hostPort1);
    failoverWatcher1.blockUntilActive();

    HostPort hostPort2 = new HostPort("127.0.0.1", 22222);
    final FailoverWatcher failoverWatcher2 = createFailoverWatcher(hostPort2);
    Thread thread2 = new Thread() {
      @Override
View Full Code Here

Examples of com.xiaomi.infra.chronos.zookeeper.FailoverWatcher.blockUntilActive()

    HostPort hostPort2 = new HostPort("127.0.0.1", 22222);
    final FailoverWatcher failoverWatcher2 = createFailoverWatcher(hostPort2);
    Thread thread2 = new Thread() {
      @Override
      public void run() {
        failoverWatcher2.blockUntilActive();
      }
    };
    thread2.start();

    // delete master znode, then failoverWatcher2 will be master
View Full Code Here

Examples of com.xiaomi.infra.chronos.zookeeper.FailoverWatcher.blockUntilActive()

  @Test
  public void testCloseBackupMaster() throws IOException, KeeperException, InterruptedException {
    HostPort hostPort1 = new HostPort("127.0.0.1", 11111);
    FailoverWatcher failoverWatcher1 = createFailoverWatcher(hostPort1);
    failoverWatcher1.blockUntilActive();

    HostPort hostPort2 = new HostPort("127.0.0.1", 22222);
    final FailoverWatcher failoverWatcher2 = createFailoverWatcher(hostPort2);
    Thread thread2 = new Thread() {
      @Override
View Full Code Here
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.