abstract class EventRegistrationWatcher extends TransitionWatcher implements EventRegistrationRecord
TransitionWatcher for event
registrations. Also represents the registration itself.| Modifier and Type | Class and Description |
|---|---|
private class |
EventRegistrationWatcher.BasicEventSender
Common implementation of
EventSender. |
| Modifier and Type | Field and Description |
|---|---|
(package private) Uuid |
cookie
The UUID that identifies this registration
Protected, but 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 TemplateHandle |
owner
The
TemplateHandle associated with this
watcher. |
startOrdinal| Constructor and Description |
|---|
EventRegistrationWatcher(long timestamp,
long startOrdinal,
long currentSeqNum)
Used during log recovery to create a mostly empty
EventRegistrationWatcher. |
EventRegistrationWatcher(long timestamp,
long startOrdinal,
Uuid cookie,
MarshalledObject handback,
long eventID)
Create a new
EventRegistrationWatcher. |
| 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(TemplateHandle owner,
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, isInterestedvolatile long expiration
Uuid cookie
MarshalledObject handback
long eventID
private long currentSeqNum
private TemplateHandle owner
TemplateHandle associated with this
watcher.EventRegistrationWatcher(long timestamp,
long startOrdinal,
long currentSeqNum)
EventRegistrationWatcher.
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.EventRegistrationWatcher(long timestamp,
long startOrdinal,
Uuid cookie,
MarshalledObject handback,
long eventID)
EventRegistrationWatcher.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.handback - 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 occured).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.EventRegistrationWatcher.IOException - 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 found.SecurityException - if the prepareProxy
call does.boolean addTemplateHandle(TemplateHandle h)
TemplateHandle with this object. May
only be called once on any given
EventRegistrationWatcher 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
nullpublic void setExpiration(long newExpiration)
setTemplateHandle is called.
Assumes locking is handled by the caller.setExpiration in interface LeasedResourcenewExpiration - The expiration time.public 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(TemplateHandle owner, boolean expired)
cancel or
removeIfExpired. Called after releasing the lock
on this. Will be called at most once.owner - A reference to the owner.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.