Package org.apache.zookeeper

Examples of org.apache.zookeeper.Watcher


    zkClient.subscribeStateChanges(listener);
    ZkConnection connection = ((ZkConnection) zkClient.getConnection());
    ZooKeeper oldZookeeper = connection.getZookeeper();
    LOG.info("Old sessionId = " + oldZookeeper.getSessionId());

    Watcher watcher = new Watcher() {
      @Override
      public void process(WatchedEvent event) {
        LOG.info("In New connection, process event:" + event);
      }
    };
View Full Code Here


        try
        {
            client.create().forPath("/sessionTest");

            final AtomicBoolean sessionDied = new AtomicBoolean(false);
            Watcher watcher = new Watcher()
            {
                @Override
                public void process(WatchedEvent event)
                {
                    if ( event.getState() == Event.KeeperState.Expired )
View Full Code Here

        CuratorFramework client = builder.connectString(server.getConnectString()).namespace("aisa").retryPolicy(new RetryOneTime(1)).build();
        client.start();
        try
        {
            final BlockingQueue<String>     queue = new LinkedBlockingQueue<String>();
            Watcher                         watcher = new Watcher()
            {
                @Override
                public void process(WatchedEvent event)
                {
                    try
View Full Code Here

   * @throws InterruptedException
   * @throws KeeperException
   */
  public BookKeeper(String servers) throws IOException, InterruptedException,
      KeeperException {
    this(new ZooKeeper(servers, 10000, new Watcher() {
      @Override
      public void process(WatchedEvent event) {
        // TODO: handle session disconnects and expires
        if (LOG.isDebugEnabled()) {
          LOG.debug("Process: " + event.getType() + " " + event.getPath());
View Full Code Here

    public static byte[] readFileAsByteArray(File file) throws Exception {
        return Files.toByteArray(file);
    }

    public static ZooKeeper createZkClient() throws IOException {
        final ZooKeeper zk = new ZooKeeper("localhost:" + ZK_PORT, 4000, new Watcher() {
            @Override
            public void process(WatchedEvent event) {
            }
        });
        return zk;
View Full Code Here

                zk.delete(path, -1);
            } else {
                latch.countDown();
            }
        }
        zk.exists(path, new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                if (EventType.NodeCreated.equals(event.getType())) {
                    latch.countDown();
                }
View Full Code Here

    }

    public static void watchAndSignalChangedChildren(String path, final CountDownLatch latch, final ZooKeeper zk)
            throws KeeperException, InterruptedException {

        zk.getChildren(path, new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                if (EventType.NodeChildrenChanged.equals(event.getType())) {
                    latch.countDown();
                }
View Full Code Here

            LOG.warn("No ZK servers passed to Bookie constructor so BookKeeper clients won't know about this server!");
            zk = null;
            return;
        }
        // Create the ZooKeeper client instance
        zk = new ZooKeeper(zkServers, 10000, new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                // TODO: handle session disconnects and expires
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Process: " + event.getType() + " " + event.getPath());
View Full Code Here

      prev = child;
    }
   
    final String lockToWatch = path + "/" + prev;
    log.trace("Establishing watch on " + lockToWatch);
    Stat stat = zooKeeper.getStatus(lockToWatch, new Watcher() {
     
      @Override
      public void process(WatchedEvent event) {
        if (log.isTraceEnabled()) {
          log.trace("Processing event:");
View Full Code Here

    lockWasAcquired = false;
   
    try {
      final String asyncLockPath = zooKeeper.putEphemeralSequential(path + "/" + LOCK_PREFIX, data);
      log.trace("Ephemeral node " + asyncLockPath + " created");
      Stat stat = zooKeeper.getStatus(asyncLockPath, new Watcher() {
       
        private void failedToAcquireLock(){
          lw.failedToAcquireLock(new Exception("Lock deleted before acquired"));
          asyncLock = null;
        }
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.Watcher

Copyright © 2018 www.massapicom. 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.