Class FutureEventDrivenOperation<ResultType>
java.lang.Object
org.apache.camel.component.zookeeper.operations.ZooKeeperOperation<ResultType>
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, org.apache.zookeeper.Watcher.WatcherType -
Field Summary
Fields inherited from class org.apache.camel.component.zookeeper.operations.ZooKeeperOperation
connection, CONSTRUCTOR_ARGS, LOG, node, result, waitingThreads -
Constructor Summary
ConstructorsConstructorDescriptionFutureEventDrivenOperation(org.apache.zookeeper.ZooKeeper connection, String node, org.apache.zookeeper.Watcher.Event.EventType... awaitedTypes) -
Method Summary
Methods inherited from class org.apache.camel.component.zookeeper.operations.ZooKeeperOperation
cancel, createCopy, getNode, getResult, isCancelled, isDone, shouldProduceExchange
-
Constructor Details
-
FutureEventDrivenOperation
public FutureEventDrivenOperation(org.apache.zookeeper.ZooKeeper connection, String node, org.apache.zookeeper.Watcher.Event.EventType... awaitedTypes)
-
-
Method Details
-
process
public void process(org.apache.zookeeper.WatchedEvent event) - Specified by:
processin interfaceorg.apache.zookeeper.Watcher
-
get
- Overrides:
getin classZooKeeperOperation<ResultType>- Throws:
ExecutionExceptionInterruptedException
-
get
public OperationResult<ResultType> get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Overrides:
getin classZooKeeperOperation<ResultType>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
installWatch
protected abstract void installWatch()Install the watcher to receiveWatchedEvents. 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:
getWatchedEventin interfaceWatchedEventProvider
-
getWatchedForTypes
public org.apache.zookeeper.Watcher.Event.EventType[] getWatchedForTypes()
-