org.apache.camel.component.zookeeper.operations
Class FutureEventDrivenOperation<ResultType>

java.lang.Object
  extended by org.apache.camel.component.zookeeper.operations.ZooKeeperOperation<ResultType>
      extended by org.apache.camel.component.zookeeper.operations.FutureEventDrivenOperation<ResultType>
All Implemented Interfaces:
WatchedEventProvider, org.apache.zookeeper.Watcher
Direct Known Subclasses:
ChildrenChangedOperation, DataChangedOperation, ExistenceChangedOperation

public abstract class FutureEventDrivenOperation<ResultType>
extends ZooKeeperOperation<ResultType>
implements org.apache.zookeeper.Watcher, WatchedEventProvider

FutureEventDrivenOperation uses ZooKeepers Watcher mechanism to await specific ZooKeeper events. Typically this is used to await changes to a particular node before retrieving the change.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
org.apache.zookeeper.Watcher.Event
 
Field Summary
 
Fields inherited from class org.apache.camel.component.zookeeper.operations.ZooKeeperOperation
connection, CONSTRUCTOR_ARGS, LOG, node, result, waitingThreads
 
Constructor Summary
FutureEventDrivenOperation(org.apache.zookeeper.ZooKeeper connection, String node, org.apache.zookeeper.Watcher.Event.EventType... awaitedTypes)
           
 
Method Summary
 OperationResult<ResultType> get()
           
 OperationResult<ResultType> get(long timeout, TimeUnit unit)
           
 org.apache.zookeeper.WatchedEvent getWatchedEvent()
           
 org.apache.zookeeper.Watcher.Event.EventType[] getWatchedForTypes()
           
protected abstract  void installWatch()
          Install the watcher to receive WatchedEvents.
 void process(org.apache.zookeeper.WatchedEvent event)
           
 
Methods inherited from class org.apache.camel.component.zookeeper.operations.ZooKeeperOperation
cancel, createCopy, getNode, getResult, isCancelled, isDone, shouldProduceExchange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FutureEventDrivenOperation

public FutureEventDrivenOperation(org.apache.zookeeper.ZooKeeper connection,
                                  String node,
                                  org.apache.zookeeper.Watcher.Event.EventType... awaitedTypes)
Method Detail

process

public void process(org.apache.zookeeper.WatchedEvent event)
Specified by:
process in interface org.apache.zookeeper.Watcher

get

public OperationResult<ResultType> get()
                                throws InterruptedException,
                                       ExecutionException
Overrides:
get in class ZooKeeperOperation<ResultType>
Throws:
InterruptedException
ExecutionException

get

public OperationResult<ResultType> get(long timeout,
                                       TimeUnit unit)
                                throws InterruptedException,
                                       ExecutionException,
                                       TimeoutException
Overrides:
get in class ZooKeeperOperation<ResultType>
Throws:
InterruptedException
ExecutionException
TimeoutException

installWatch

protected abstract void installWatch()
Install the watcher to receive WatchedEvents. It should use the appropriate asynchronous ZooKeeper call to do this so as not to block the route from starting. Once one of the watched for types of event is received a call is made to getResult, which can use the appropriate synchronous call to retrieve the actual data.


getWatchedEvent

public org.apache.zookeeper.WatchedEvent getWatchedEvent()
Specified by:
getWatchedEvent in interface WatchedEventProvider

getWatchedForTypes

public org.apache.zookeeper.Watcher.Event.EventType[] getWatchedForTypes()


Apache CAMEL