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 |
owners
The
TemplateHandle s associated with this
watcher. |
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, isInterested
long expiration
Uuid cookie
MarshalledObject handback
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 Set owners
TemplateHandle
s associated with this
watcher.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 TransitionWatcher
s.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 TransitionWatcher
s.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 TransitionWatcher
transition
- 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.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 foundSecurityException
- if the prepareProxy
call does.boolean addTemplateHandle(TemplateHandle h)
TemplateHandle
with this object. May
call more than once.addTemplateHandle
in class TransitionWatcher
h
- The TemplateHandle
associate
with this watchertrue
if the handle was successfully added,
and false
if the watcher has already
been removedNullPointerException
- if h
is
null
public void setExpiration(long newExpiration)
setTemplateHandle
is called.
Assumes locking is handled by the caller.setExpiration
in interface LeasedResource
newExpiration
- The expiration time.public long getExpiration()
TransitionWatcher
addTemplateHandle
is called.
Assumes locking is handled by the caller.getExpiration
in interface LeasedResource
getExpiration
in class TransitionWatcher
public Uuid getCookie()
setTemplateHandle
is
called.getCookie
in interface LeasedResource
void 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)
TransitionWatcher
remove
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 TransitionWatcher
now
- An estimate of the current time that must be
less than or equal to the current time.public boolean cancel()
EventRegistrationRecord
cancel
in interface EventRegistrationRecord
true
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.