abstract class AvailabilityRegistrationWatcher extends TransitionWatcher implements EventRegistrationRecord
TransitionWatcher for availability event
registrations. Also represents the event registration itself.| Modifier and Type | Class and Description |
|---|---|
private class |
AvailabilityRegistrationWatcher.VisibilityEventSender
Common implementation of
EventSender for visibility events |
| Modifier and Type | Field and Description |
|---|---|
(package private) Uuid |
cookie
The UUID that identifies this registration
Only for use by subclasses.
|
private long |
currentSeqNum
The current sequence number.
|
(package private) long |
eventID
The event ID associated with this registration
Protected, but only for use by subclasses.
|
(package private) long |
expiration
The current expiration time of the registration
Protected, but only for use by subclasses.
|
(package private) MarshalledObject |
handback
The handback associated with this registration.
|
private Set<TemplateHandle> |
owners
The
TemplateHandles associated with this
watcher. |
private boolean |
removed |
private OutriggerServerImpl |
server
The OutriggerServerImpl we are part of.
|
(package private) boolean |
visibilityOnly
true if client is interested
in only visibility events, false
otherwise. |
startOrdinal| Constructor and Description |
|---|
AvailabilityRegistrationWatcher(long timestamp,
long startOrdinal,
long currentSeqNum)
Used during log recovery to create a mostly empty
AvailabilityRegistrationWatcher. |
AvailabilityRegistrationWatcher(long timestamp,
long startOrdinal,
Uuid cookie,
boolean visibilityOnly,
MarshalledObject handback,
long eventID)
Create a new
AvailabilityRegistrationWatcher. |
| Modifier and Type | Method and Description |
|---|---|
(package private) boolean |
addTemplateHandle(TemplateHandle h)
Associate a
TemplateHandle with this object. |
boolean |
cancel()
Make sure this object will be removed from the system
independent of the expiration time.
|
(package private) void |
cleanup(OutriggerServerImpl server,
boolean expired)
Overridden by subclasses if there is any cleanup work they need
to do as part of
cancel or
removeIfExpired. |
private boolean |
doRemove(long now,
boolean doIt)
The heavy lifting of removing ourselves.
|
Uuid |
getCookie()
Get the unique identifier associated with this object.
|
long |
getExpiration()
Get the expiration time of this object.
|
(package private) abstract RemoteEventListener |
getListener(ProxyPreparer preparer)
Return the remote listener associated with this
EventRegistrationWatcher. |
(package private) void |
process(EntryTransition transition,
long now)
Process the given transition by queuing up a task with the
notifier for event delivery.
|
(package private) void |
removeIfExpired(long now)
Remove this watcher from the system if it
has expired.
|
void |
setExpiration(long newExpiration)
Set the expiration time of this object.
|
compareTo, isInterestedlong expiration
volatile Uuid cookie
MarshalledObject handback
volatile boolean visibilityOnly
true if client is interested
in only visibility events, false
otherwise.
Only for use by subclasses.
Should not be changed.long eventID
private long currentSeqNum
private final Set<TemplateHandle> owners
TemplateHandles associated with this
watcher.private boolean removed
private OutriggerServerImpl server
AvailabilityRegistrationWatcher(long timestamp,
long startOrdinal,
long currentSeqNum)
AvailabilityRegistrationWatcher.
Note, we set the time stamp and tie-breaker here instead of getting them from the log. This means they will be inconstant with their value from the last VM we were in, but since they never leak out and events are read-only anyway this should not be a problem (this also allows us to keep the tie-breaker and time stamp in final fields).
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.currentSeqNum - Sequence number to start with.AvailabilityRegistrationWatcher(long timestamp,
long startOrdinal,
Uuid cookie,
boolean visibilityOnly,
MarshalledObject handback,
long eventID)
AvailabilityRegistrationWatcher.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.cookie - The unique identifier associated
with this watcher. Must not be null.visibilityOnly - pass true if client
only wants visibility eventshandback - The handback object that
should be sent along with event
notifications to the the listener.eventID - The event ID for event type
represented by this object.NullPointerException - if the cookie
argument is null.void process(EntryTransition transition, long now)
TemplateHandle associated with
this watcher and that isInterested returned
true. If remove has been called or
the expiration time of this watcher has passed, this call
should have no effect. This call may cause the watcher to be
removed.process in class TransitionWatchertransition - A EntryTransition that
describes the transition and what
entry is transitioning. This method
will assume that transition.getHandle
returns a non-null value.now - An estimate of the current time (not the time
when the event occurred).NullPointerException - if transition is
null.abstract RemoteEventListener getListener(ProxyPreparer preparer) throws ClassNotFoundException, IOException
EventRegistrationWatcher. Optionally
prepare the listener if it has been recovered from
the store and not yet re-prepared.EventRegistrationWatcherIOException - if the listener can not
be unmarshalled. May throw RemoteException
if the call to the preparer doesClassNotFoundException - if the listener
needs to be unmarshalled and a necessary
class can not be foundSecurityException - if the prepareProxy
call does.boolean addTemplateHandle(TemplateHandle h)
TemplateHandle with this object. May
call more than once.addTemplateHandle in class TransitionWatcherh - The TemplateHandle associate
with this watchertrue if the handle was successfully added,
and false if the watcher has already
been removedNullPointerException - if h is
nullpublic final void setExpiration(long newExpiration)
setTemplateHandle is called.setExpiration in interface LeasedResourcenewExpiration - The expiration time.public final long getExpiration()
TransitionWatcheraddTemplateHandle is called.
Assumes locking is handled by the caller.getExpiration in interface LeasedResourcegetExpiration in class TransitionWatcherpublic Uuid getCookie()
setTemplateHandle is
called.getCookie in interface LeasedResourcevoid cleanup(OutriggerServerImpl server, boolean expired)
cancel or
removeIfExpired. Called after releasing the lock
on this. Will be called at most once.server - A reference to the top level server object.expired - true if being called from
removeIfExpired and false otherwise.private boolean doRemove(long now,
boolean doIt)
now - The current time (or a bit earlier).doIt - If true ignore
now and just remove this
object.true if this call removed
this object, false if
it had already been done. Should be ignored if
doIt is false.void removeIfExpired(long now)
TransitionWatcherremove method
of the associated TemplateHandle.
This method can be called more than once,
though second and subsequent calls may have no effect.removeIfExpired in class TransitionWatchernow - An estimate of the current time that must be
less than or equal to the current time.public boolean cancel()
EventRegistrationRecordcancel in interface EventRegistrationRecordtrue if this call was
the first removal attempt.Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.