com.bigdata.zookeeper
Class ZNodeDeletedWatcher

java.lang.Object
  extended by com.bigdata.zookeeper.AbstractZNodeConditionWatcher
      extended by com.bigdata.zookeeper.ZNodeDeletedWatcher
All Implemented Interfaces:
org.apache.zookeeper.Watcher

public class ZNodeDeletedWatcher
extends AbstractZNodeConditionWatcher

An instance of this class may be used to watch for the delete of a single znode.

Version:
$Id$
Author:
Bryan Thompson

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
org.apache.zookeeper.Watcher.Event
 
Field Summary
 
Fields inherited from class com.bigdata.zookeeper.AbstractZNodeConditionWatcher
log, zookeeper, zpath
 
Constructor Summary
protected ZNodeDeletedWatcher(org.apache.zookeeper.ZooKeeper zookeeper, String zpath)
           
 
Method Summary
static boolean awaitDelete(org.apache.zookeeper.ZooKeeper zookeeper, String zpath, long timeout, TimeUnit unit)
          If the znode identified by the path exists, then wait up to the timeout for the znode to be deleted.
protected  void clearWatch()
          Clear any watches.
protected  boolean isConditionSatisfied()
          Implementation must check the state of the znode using the AbstractZNodeConditionWatcher.zpath and determine if the conditions are satisfied always resetting the watch(es) as a side-effect.
protected  boolean isConditionSatisfied(org.apache.zookeeper.WatchedEvent event)
          Implementation must inspect the event and determine if the conditions are satisfied.
 
Methods inherited from class com.bigdata.zookeeper.AbstractZNodeConditionWatcher
_resumeWatch, awaitCondition, awaitCondition, isCancelled, process, success, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZNodeDeletedWatcher

protected ZNodeDeletedWatcher(org.apache.zookeeper.ZooKeeper zookeeper,
                              String zpath)
Method Detail

awaitDelete

public static boolean awaitDelete(org.apache.zookeeper.ZooKeeper zookeeper,
                                  String zpath,
                                  long timeout,
                                  TimeUnit unit)
                           throws InterruptedException
If the znode identified by the path exists, then wait up to the timeout for the znode to be deleted.

Parameters:
zookeeper -
zpath -
timeout -
unit -
Returns:
false if the waiting time detectably elapsed before return from the method, else true.
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

isConditionSatisfied

protected boolean isConditionSatisfied(org.apache.zookeeper.WatchedEvent event)
                                throws org.apache.zookeeper.KeeperException,
                                       InterruptedException
Description copied from class: AbstractZNodeConditionWatcher
Implementation must inspect the event and determine if the conditions are satisfied.

Specified by:
isConditionSatisfied in class AbstractZNodeConditionWatcher
Parameters:
event - The WatchedEvent
Returns:
true if the event satisfied the condition.
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

isConditionSatisfied

protected boolean isConditionSatisfied()
                                throws org.apache.zookeeper.KeeperException,
                                       InterruptedException
Description copied from class: AbstractZNodeConditionWatcher
Implementation must check the state of the znode using the AbstractZNodeConditionWatcher.zpath and determine if the conditions are satisfied always resetting the watch(es) as a side-effect.

This is used to handle the initial case, where we need to know whether or not the condition is satisfied before waiting for an event.

Specified by:
isConditionSatisfied in class AbstractZNodeConditionWatcher
Returns:
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

clearWatch

protected void clearWatch()
                   throws org.apache.zookeeper.KeeperException,
                          InterruptedException
Description copied from class: AbstractZNodeConditionWatcher
Clear any watches.

Specified by:
clearWatch in class AbstractZNodeConditionWatcher
Throws:
org.apache.zookeeper.KeeperException
InterruptedException


Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.