Package org.apache.hadoop.hbase.zookeeper

Examples of org.apache.hadoop.hbase.zookeeper.DeletionListener


        break;
      }
      CountDownLatch deletedLatch = new CountDownLatch(1);
      String zkPathToWatch =
          ZKUtil.joinZNode(parentLockNode, pathToWatch);
      DeletionListener deletionListener =
          new DeletionListener(zkWatcher, zkPathToWatch, deletedLatch);
      zkWatcher.registerListener(deletionListener);
      try {
        if (ZKUtil.setWatchIfNodeExists(zkWatcher, zkPathToWatch)) {
          // Wait for the watcher to fire
          if (hasTimeout) {
            long remainingMs = waitUntilMs - EnvironmentEdgeManager.currentTimeMillis();
            if (remainingMs < 0 ||
                !deletedLatch.await(remainingMs, TimeUnit.MILLISECONDS)) {
              LOG.warn("Unable to acquire the lock in " + timeoutMs +
                  " milliseconds.");
              try {
                ZKUtil.deleteNode(zkWatcher, createdZNode);
              } catch (KeeperException e) {
                LOG.warn("Unable to remove ZNode " + createdZNode);
              }
              return false;
            }
          } else {
            deletedLatch.await();
          }
          if (deletionListener.hasException()) {
            Throwable t = deletionListener.getException();
            throw new IOException("Exception in the watcher", t);
          }
        }
      } catch (KeeperException e) {
        throw new IOException("Unexpected ZooKeeper exception", e);
View Full Code Here


        break;
      }
      CountDownLatch deletedLatch = new CountDownLatch(1);
      String zkPathToWatch =
          ZKUtil.joinZNode(parentLockNode, pathToWatch);
      DeletionListener deletionListener =
          new DeletionListener(zkWatcher, zkPathToWatch, deletedLatch);
      zkWatcher.registerListener(deletionListener);
      try {
        if (ZKUtil.setWatchIfNodeExists(zkWatcher, zkPathToWatch)) {
          // Wait for the watcher to fire
          if (hasTimeout) {
            long remainingMs = waitUntilMs - EnvironmentEdgeManager.currentTime();
            if (remainingMs < 0 ||
                !deletedLatch.await(remainingMs, TimeUnit.MILLISECONDS)) {
              LOG.warn("Unable to acquire the lock in " + timeoutMs +
                  " milliseconds.");
              try {
                ZKUtil.deleteNode(zkWatcher, createdZNode);
              } catch (KeeperException e) {
                LOG.warn("Unable to remove ZNode " + createdZNode);
              }
              return false;
            }
          } else {
            deletedLatch.await();
          }
          if (deletionListener.hasException()) {
            Throwable t = deletionListener.getException();
            throw new IOException("Exception in the watcher", t);
          }
        }
      } catch (KeeperException e) {
        throw new IOException("Unexpected ZooKeeper exception", e);
View Full Code Here

        break;
      }
      CountDownLatch deletedLatch = new CountDownLatch(1);
      String zkPathToWatch =
          ZKUtil.joinZNode(parentLockNode, pathToWatch);
      DeletionListener deletionListener =
          new DeletionListener(zkWatcher, zkPathToWatch, deletedLatch);
      zkWatcher.registerListener(deletionListener);
      try {
        if (ZKUtil.setWatchIfNodeExists(zkWatcher, zkPathToWatch)) {
          // Wait for the watcher to fire
          if (hasTimeout) {
            long remainingMs = waitUntilMs - EnvironmentEdgeManager.currentTime();
            if (remainingMs < 0 ||
                !deletedLatch.await(remainingMs, TimeUnit.MILLISECONDS)) {
              LOG.warn("Unable to acquire the lock in " + timeoutMs +
                  " milliseconds.");
              try {
                ZKUtil.deleteNode(zkWatcher, createdZNode);
              } catch (KeeperException e) {
                LOG.warn("Unable to remove ZNode " + createdZNode);
              }
              return false;
            }
          } else {
            deletedLatch.await();
          }
          if (deletionListener.hasException()) {
            Throwable t = deletionListener.getException();
            throw new IOException("Exception in the watcher", t);
          }
        }
      } catch (KeeperException e) {
        throw new IOException("Unexpected ZooKeeper exception", e);
View Full Code Here

        break;
      }
      CountDownLatch deletedLatch = new CountDownLatch(1);
      String zkPathToWatch =
          ZKUtil.joinZNode(parentLockNode, pathToWatch);
      DeletionListener deletionListener =
          new DeletionListener(zkWatcher, zkPathToWatch, deletedLatch);
      zkWatcher.registerListener(deletionListener);
      try {
        if (ZKUtil.setWatchIfNodeExists(zkWatcher, zkPathToWatch)) {
          // Wait for the watcher to fire
          if (hasTimeout) {
            long remainingMs = waitUntilMs - EnvironmentEdgeManager.currentTimeMillis();
            if (remainingMs < 0 ||
                !deletedLatch.await(remainingMs, TimeUnit.MILLISECONDS)) {
              LOG.warn("Unable to acquire the lock in " + timeoutMs +
                  " milliseconds.");
              try {
                ZKUtil.deleteNode(zkWatcher, createdZNode);
              } catch (KeeperException e) {
                LOG.warn("Unable to remove ZNode " + createdZNode);
              }
              return false;
            }
          } else {
            deletedLatch.await();
          }
          if (deletionListener.hasException()) {
            Throwable t = deletionListener.getException();
            throw new IOException("Exception in the watcher", t);
          }
        }
      } catch (KeeperException e) {
        throw new IOException("Unexpected ZooKeeper exception", e);
View Full Code Here

        break;
      }
      CountDownLatch deletedLatch = new CountDownLatch(1);
      String zkPathToWatch =
          ZKUtil.joinZNode(parentLockNode, pathToWatch);
      DeletionListener deletionListener =
          new DeletionListener(zkWatcher, zkPathToWatch, deletedLatch);
      zkWatcher.registerListener(deletionListener);
      try {
        if (ZKUtil.setWatchIfNodeExists(zkWatcher, zkPathToWatch)) {
          // Wait for the watcher to fire
          if (hasTimeout) {
            long remainingMs = waitUntilMs - EnvironmentEdgeManager.currentTimeMillis();
            if (remainingMs < 0 ||
                !deletedLatch.await(remainingMs, TimeUnit.MILLISECONDS)) {
              LOG.warn("Unable to acquire the lock in " + timeoutMs +
                  " milliseconds.");
              try {
                ZKUtil.deleteNode(zkWatcher, createdZNode);
              } catch (KeeperException e) {
                LOG.warn("Unable to remove ZNode " + createdZNode);
              }
              return false;
            }
          } else {
            deletedLatch.await();
          }
          if (deletionListener.hasException()) {
            Throwable t = deletionListener.getException();
            throw new IOException("Exception in the watcher", t);
          }
        }
      } catch (KeeperException e) {
        throw new IOException("Unexpected ZooKeeper exception", e);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.zookeeper.DeletionListener

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.