abstract class SingletonQueryWatcher extends QueryWatcher
QueryWatcher for singleton queries. Most
of the usage model is laid out in QueryWatcher except
how the result of the query is obtained from the
watcher. SingletonQueryWatcher defines the
resolvedWithEntry and
resolvedWithThrowable methods which can be used to
obtain the entry or throwable the query was resolved with (and in
the case of IfExistsWatchers
isConflictSetEmpty).| Modifier and Type | Field and Description |
|---|---|
private EntryHandle |
handle
If resolved and an entry was found the entry to return
|
private TemplateHandle |
owner
The
TemplateHandle associated with this
watcher. |
private boolean |
resolved
Set to true when this query is resolved
|
private Throwable |
toThrow
If resolved and an exception needs to be thrown the exception
to throw
|
startOrdinal| Constructor and Description |
|---|
SingletonQueryWatcher(long expiration,
long timestamp,
long startOrdinal)
Create a new
SingletonQueryWatcher. |
| Modifier and Type | Method and Description |
|---|---|
(package private) boolean |
addTemplateHandle(TemplateHandle h)
Associate a
TemplateHandle with this object. |
(package private) OutriggerServerImpl |
getServer()
Method to give sub-classes access to OutriggerServerImpl
Assumes caller owns lock on
this and that
this watcher has not been removed. |
(package private) boolean |
isResolved()
Returns
true if this query has been resolved. |
(package private) void |
resolve(EntryHandle handle,
Throwable throwable)
Mark this query as resolved.
|
(package private) EntryHandle |
resolvedWithEntry()
If the query has been resolved by finding an matching entry,
returns the
EntryHandle for that entry. |
(package private) Throwable |
resolvedWithThrowable()
If the query has been resolved with an exceptional condition,
the exception that should be thrown to the client.
|
(package private) void |
waitOnResolution()
Block until the query this object represents is resolved.
|
catchUp, getExpiration, removeIfExpiredcompareTo, isInterested, processprivate volatile boolean resolved
private volatile EntryHandle handle
private volatile Throwable toThrow
private volatile TemplateHandle owner
TemplateHandle associated with this
watcher.SingletonQueryWatcher(long expiration,
long timestamp,
long startOrdinal)
SingletonQueryWatcher.expiration - the initial expiration time
for this TransitionWatcher in
milliseconds since the beginning of the epoch.timestamp - the value that is used
to sort TransitionWatchers.startOrdinal - the highest ordinal associated
with operations that are considered to have occurred
before the operation associated with this watcher.boolean addTemplateHandle(TemplateHandle h)
TemplateHandle with this object. May
only be called once on any given SingletonQueryWatcher
instance.addTemplateHandle in class TransitionWatcherh - The TemplateHandle associated
with this watcher.true if the handle was succfully added,
and false if the watcher has already
been removed.NullPointerException - if h is
nullvoid waitOnResolution()
throws InterruptedException
waitOnResolution in class QueryWatcherInterruptedExceptionEntryHandle resolvedWithEntry()
EntryHandle for that entry. If the query has
been resolved but no entry is available (e.g. the expiration time has
been reached or an exception needs to be thrown) returns
null. Note, once resolution has been reached this
method can only return non-null if resolvedWithThrowable
returns null.null if
no entry is available.IllegalStateException - if the query has not
yet been resolved.Throwable resolvedWithThrowable()
null otherwise. Note, once resolution has been
reached this method can only return non-null if
resolvedWithEntry returns null.IllegalStateException - if the query has not
yet been resolved.boolean isResolved()
true if this query has been resolved. If the
calling thread is owns the lock on this object the answer is
definitive. If the lock is not held only a true answer
can be considered definitive.isResolved in class QueryWatchertrue if the query has been
resolved, false otherwise.void resolve(EntryHandle handle, Throwable throwable)
handle - If being resolved by finding an entry
the entry which was found and that should be returned
by resolvedWithEntry. Otherwise should be
null. May only be non-null if throwable
is null.throwable - If being resolved by an exception
the throwable to be thrown and that should be returned
by resolvedWithThrowable otherwise should
be null. May only be non-null if entry is
null.IllegalArgumentException - if both
entry and throwable
are non-null.IllegalStateException - if the query has already
been resolved.OutriggerServerImpl getServer()
this and that
this watcher has not been removed.Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.