Examples of Watcher


Examples of org.apache.zookeeper.Watcher

            readerFuture.setException(t);
          }
        };

        // Fetch list of broker ids
        Futures.addCallback(zkClient.getChildren(BROKER_IDS_PATH, new Watcher() {
          @Override
          public void process(WatchedEvent event) {
            if (!isRunning()) {
              return;
            }
View Full Code Here

Examples of org.apache.zookeeper.Watcher

                readyFuture.setException(t);
              }
            };

            // Fetch node data
            Futures.addCallback(zkClient.getData(path, new Watcher() {
              @Override
              public void process(WatchedEvent event) {
                if (!isRunning()) {
                  return;
                }
View Full Code Here

Examples of org.apache.zookeeper.Watcher

  /**
   * Checks exists of a given ZK path and execute the action when it exists.
   */
  private void actOnExists(final String path, final Runnable action,
                           final SettableFuture<?> readyFuture, final long retryTime, final TimeUnit retryUnit) {
    Futures.addCallback(zkClient.exists(path, new Watcher() {
      @Override
      public void process(WatchedEvent event) {
        if (!isRunning()) {
          return;
        }
View Full Code Here

Examples of org.apache.zookeeper.Watcher

      final CountDownLatch expireReconnectLatch = new CountDownLatch(1);
      final AtomicBoolean expired = new AtomicBoolean(false);
      final ZKClientService client = ZKClientServices.delegate(ZKClients.reWatchOnExpire(
                                        ZKClientService.Builder.of(zkServer.getConnectionStr())
                                                       .setSessionTimeout(2000)
                                                       .setConnectionWatcher(new Watcher() {
            @Override
            public void process(WatchedEvent event) {
              if (event.getState() == Event.KeeperState.Expired) {
                expired.set(true);
              } else if (event.getState() == Event.KeeperState.SyncConnected && expired.compareAndSet(true, true)) {
                expireReconnectLatch.countDown();
              }
            }
          }).build()));
      client.startAndWait();

      try {
        final BlockingQueue<Watcher.Event.EventType> events = new LinkedBlockingQueue<Watcher.Event.EventType>();
        client.exists("/expireRewatch", new Watcher() {
          @Override
          public void process(WatchedEvent event) {
            client.exists("/expireRewatch", this);
            events.add(event.getType());
          }
View Full Code Here

Examples of org.apache.zookeeper.Watcher

    zkServer.startAndWait();
    int port = zkServer.getLocalAddress().getPort();

    final CountDownLatch disconnectLatch = new CountDownLatch(1);
    ZKClientService client = ZKClientServices.delegate(ZKClients.retryOnFailure(
      ZKClientService.Builder.of(zkServer.getConnectionStr()).setConnectionWatcher(new Watcher() {
      @Override
      public void process(WatchedEvent event) {
        if (event.getState() == Event.KeeperState.Disconnected) {
          disconnectLatch.countDown();
        }
View Full Code Here

Examples of org.apache.zookeeper.Watcher

   */
  private Watcher wrapWatcher(final Watcher watcher) {
    if (watcher == null) {
      return null;
    }
    return new Watcher() {
      @Override
      public void process(final WatchedEvent event) {
        eventExecutor.execute(new Runnable() {
          @Override
          public void run() {
View Full Code Here

Examples of org.apache.zookeeper.Watcher

        CreateLMThread(String root, String type, CyclicBarrier barrier) throws Exception {
            this.type = type;
            this.barrier = barrier;
            this.root = root;
            final CountDownLatch latch = new CountDownLatch(1);
            zkc = new ZooKeeper("127.0.0.1", 10000, new Watcher() {
                    public void process(WatchedEvent event) {
                        latch.countDown();
                    }
                });
            latch.await();
View Full Code Here

Examples of org.apache.zookeeper.Watcher

     * @return zk client instance
     */
    private ZooKeeper newZookeeper(final String zkServers,
                                   final int sessionTimeout) throws IOException {
        ZooKeeper newZk = new ZooKeeper(zkServers, sessionTimeout,
        new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                // handle session disconnects and expires
                if (event.getType()
                .equals(Watcher.Event.EventType.None)) {
View Full Code Here

Examples of org.apache.zookeeper_voltpatches.Watcher

            newChildren.removeAll(m_lastKnownSnapshots);
            m_lastKnownSnapshots = children;
            for (String newSnapshot : newChildren) {
                String path = VoltZK.completed_snapshots + "/" + newSnapshot;
                try {
                    byte data[] = m_zk.getData(path, new Watcher() {
                        @Override
                        public void process(final WatchedEvent event) {
                            switch (event.getType()) {
                            case NodeDataChanged:
                                m_es.execute(new Runnable() {
View Full Code Here

Examples of org.cipango.kaleo.presence.watcherinfo.WatcherDocument.Watcher

    winfoSession.sendResponse(Response.OK, tx); // 8
    watcherinfo = getWatcherinfo(notify);
    assertEquals(1, watcherinfo.getVersion().intValue());
    watcherList = watcherinfo.getWatcherListArray(0);
    assertEquals(1, watcherList.sizeOfWatcherArray());
    Watcher watcher = watcherList.getWatcherArray(0);
    assertEquals(Event.SUBSCRIBE, watcher.getEvent());
    assertEquals(getAliceUri(), watcher.getStringValue());
    assertEquals(Status.ACTIVE, watcher.getStatus());
   
   
    tx = presenceSession.waitForNotify(); // 9
    presenceSession.sendResponse(Response.OK, tx); // 10
   
   
    subscribe = presenceSession.newSubsequentSubscribe(0); // 11
    presenceSession.sendRequest(subscribe, Response.OK); // 12
   
    tx = winfoSession.waitForNotify(); // 13
    notify = tx.getRequest();
    // System.out.println(notify);
    winfoSession.sendResponse(Response.OK, tx); // 14
    watcherinfo = getWatcherinfo(notify);
    assertEquals(2, watcherinfo.getVersion().intValue());
    watcherList = watcherinfo.getWatcherListArray(0);
    assertEquals(1, watcherList.sizeOfWatcherArray());
    watcher = watcherList.getWatcherArray(0);
    assertEquals(Event.TIMEOUT, watcher.getEvent());
    assertEquals(getAliceUri(), watcher.getStringValue());
    assertEquals(Status.TERMINATED, watcher.getStatus());
   
    tx = presenceSession.waitForNotify(); // 15
    presenceSession.sendResponse(Response.OK, tx); // 16
   
    subscribe = winfoSession.newSubsequentSubscribe(0); // 17
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.