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
ConstructorDescriptionFutureEventDrivenOperation
(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:
process
in interfaceorg.apache.zookeeper.Watcher
-
get
- Overrides:
get
in classZooKeeperOperation<ResultType>
- Throws:
ExecutionException
InterruptedException
-
get
public OperationResult<ResultType> get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Overrides:
get
in classZooKeeperOperation<ResultType>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
installWatch
protected abstract void installWatch()Install the watcher to receiveWatchedEvent
s. 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 interfaceWatchedEventProvider
-
getWatchedForTypes
public org.apache.zookeeper.Watcher.Event.EventType[] getWatchedForTypes()
-