class LeaseSet extends Object implements Serializable, LeasedResource
Modifier and Type | Class and Description |
---|---|
(package private) static class |
LeaseSet.ChangeSetExpiration
Class used to log changes to the set expiration time.
|
private static class |
LeaseSet.ExpirationTime
Utility class that holds and guards the second copy of our expiration
time.
|
private static class |
LeaseSet.FailureEventRegistration
Class used to log changes to failure event registrations
|
private static class |
LeaseSet.RemoveClientLease
Class used to log the removal of a client lease from the set
|
private static class |
LeaseSet.RenewalFailure
Class used to log a renewal failure
|
private static class |
LeaseSet.UpdateClientLease
Class used to log adding or updating a client lease to the set
|
private static class |
LeaseSet.WarningEventRegistration
Class used to log changes to warning event registrations
|
private class |
LeaseSet.WarningFactory
Nested class that implements
EventFactory that
generates ExpirationWarningEvent s. |
Modifier and Type | Field and Description |
---|---|
private long |
expiration
Expiration time of the set
|
private LeaseSet.ExpirationTime |
expiration2
We keep two copies of the expiration time guarded by different
locks so the the client lease renewal threads don't have to wait
on the set's lock.
|
private EventType |
failureEventType
The event type for failure events
|
private Uuid |
ID
ID that uniquely identifies this set
|
private Set |
leases
A collection of the client leases in this set (in wrapped form).
|
private LeaseTable |
leaseTable
A table that maps client leases to client lease wrappers.
|
private long |
minWarning
Time before
expiration to send expiration warning events |
private NormServerBaseImpl |
normServerBaseImpl
The
NormServerBaseImpl are attached to |
private static long |
serialVersionUID |
private PersistentStore |
store
PersistentStore that changes should be logged to. |
private EventType |
warningEventType
The event type for expiration warning events
|
private long |
warningSeqNum
The current sequence number for expiration warning events
|
Constructor and Description |
---|
LeaseSet(Uuid ID,
EventTypeGenerator generator,
PersistentStore store,
NormServerBaseImpl normServerBaseImpl)
Simple constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
addToLeaseTable(ClientLeaseWrapper clw)
Add a lease already in the lease set to the lease table.
|
(package private) void |
definiteException(EventType type,
RemoteEvent ev,
long registrationNumber)
If the passed registrationNumber number matches the
current registrationNumber for the passed event
clear the current registration and persist the change
|
(package private) Set |
destroy()
Destroy a lease set
|
(package private) boolean |
doesContainWrapper(ClientLeaseWrapper clw)
Return true if the passed wrapper is in the set
|
(package private) boolean |
ensureCurrent(long now)
This method is used by the client lease renewal threads to make
sure that the set associated with the lease they are renewing is
non-expired.
|
(package private) ClientLeaseWrapper |
getClientLeaseWrapper(Lease clientLease)
Return the wrapper for the specified client lease, or null if not
found.
|
Uuid |
getCookie()
Returns the universally unique identifier associated with this
lease.
|
long |
getExpiration()
Returns the expiration time of the lease.
|
(package private) MarshalledInstance[] |
getLeases()
Return an array of leases in marshalled form.
|
(package private) Uuid |
getUuid()
Return the
Uuid for this set. |
(package private) long |
getWarningTime()
Return the absolute time when a expiration warning should be sent.
|
(package private) boolean |
haveWarningRegistration()
Return true if there is a non-
null listener registered
for the expiration warning event. |
protected boolean |
isolateSets()
Returns whether to isolate renewal sets or batch leases across sets for
all lease renewal sets associated with this set's service.
|
(package private) void |
logRenewal(ClientLeaseWrapper clw)
Log the renewal of a client lease.
|
private SetProxy |
newSetProxy()
Create a new SetProxy for this set that has a lease with the
current expiration
|
private void |
readObject(ObjectInputStream in)
Override readObject so we can restore expiration2
|
(package private) boolean |
remove(ClientLeaseWrapper clw)
Remove the specified wrapped client lease from the set.
|
private boolean |
removeInternal(ClientLeaseWrapper clw)
Utility method to remove a client lease.
|
(package private) void |
renewalFailure(ClientLeaseWrapper clw)
Handle failures to renew a lease by removing the lease from the set
and if needed schedule sending an event.
|
private boolean |
replace(ClientLeaseWrapper clw)
Utility method to replace a client lease in the lease set.
|
(package private) Iterator |
restoreTransientState(EventTypeGenerator generator,
PersistentStore store,
NormServerBaseImpl normServerBaseImpl,
ProxyPreparer recoveredListenerPreparer)
Restore the transient state of the set that can't be restored
automatically after a log recovery.
|
(package private) void |
sendWarningEvent()
Send an expiration warning event for this set
|
void |
setExpiration(long newExpiration)
Changes the expiration time of the lease.
|
(package private) EventRegistration |
setExpirationWarningListener(RemoteEventListener listener,
long minWarning,
MarshalledObject handback)
Set/update/clear the expiration warning listener.
|
(package private) EventRegistration |
setRenewalFailureListener(RemoteEventListener listener,
MarshalledObject handback)
Set/update/clear the renewal failure listener
|
String |
toString()
Returns a string representation of this object.
|
(package private) void |
update(ClientLeaseWrapper clw)
Add or update the specified wrapped client lease to the set.
|
private static final long serialVersionUID
private long expiration
private transient LeaseSet.ExpirationTime expiration2
private final Uuid ID
private final Set leases
private transient LeaseTable leaseTable
private long minWarning
expiration
to send expiration warning eventsprivate EventType warningEventType
private long warningSeqNum
private EventType failureEventType
private transient PersistentStore store
PersistentStore
that changes should be logged to.private transient NormServerBaseImpl normServerBaseImpl
NormServerBaseImpl
are attached toLeaseSet(Uuid ID, EventTypeGenerator generator, PersistentStore store, NormServerBaseImpl normServerBaseImpl)
ID
- for this setgenerator
- object set can use to create new event type objectsstore
- PersistentStore that changes should be logged
to
normServerBaseImpl
- the NormServerBaseImpl
that
created this setprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
Iterator restoreTransientState(EventTypeGenerator generator, PersistentStore store, NormServerBaseImpl normServerBaseImpl, ProxyPreparer recoveredListenerPreparer)
generator
- event type generator associated with this set's eventsstore
- PersistentStore that changes should be
logged to
normServerBaseImpl
- the normServerBaseImpl
that
created this setrecoveredListenerPreparer
- the proxy preparer to use to prepare
recovered listenersClientLeaseWrapper getClientLeaseWrapper(Lease clientLease)
private boolean replace(ClientLeaseWrapper clw)
void update(ClientLeaseWrapper clw)
clw
- lease to be added or updatedvoid addToLeaseTable(ClientLeaseWrapper clw)
boolean doesContainWrapper(ClientLeaseWrapper clw)
private boolean removeInternal(ClientLeaseWrapper clw)
boolean remove(ClientLeaseWrapper clw)
clw
- lease to removedSet destroy()
Set
with all of the sets WrappedClientLeasesMarshalledInstance[] getLeases()
EventRegistration setExpirationWarningListener(RemoteEventListener listener, long minWarning, MarshalledObject handback) throws IOException
listener
- the new listenerminWarning
- how long before the lease on the set expires should
the event be senthandback
- the new handbacklistener
is non-null
return
an EventRegistration
otherwise return null
IOException
- if listener cannot be serializedEventRegistration setRenewalFailureListener(RemoteEventListener listener, MarshalledObject handback) throws IOException
listener
- the new listenerhandback
- the new handbacklistener
is non-null
return
an EventRegistration
otherwise return null
IOException
- if listener can not be serializedvoid renewalFailure(ClientLeaseWrapper clw)
clw
- the wrapped client lease for the lease that could not
be removedvoid sendWarningEvent()
private SetProxy newSetProxy()
boolean haveWarningRegistration()
null
listener registered
for the expiration warning event.
Note, this method assumes the current thread owns the set's lock
long getWarningTime()
void logRenewal(ClientLeaseWrapper clw)
clw
- the wrapper for the client lease that was renewedpublic void setExpiration(long newExpiration)
LeasedResource
setExpiration
in interface LeasedResource
newExpiration
- The new expiration time in milliseconds
since the beginning of the epochpublic long getExpiration()
LeasedResource
getExpiration
in interface LeasedResource
boolean ensureCurrent(long now)
now
- the current time in milliseconds since the beginning of
the epochpublic Uuid getCookie()
LeasedResource
ReferentUuid
should return this object from their
getReferentUuid
method and should base their implementation of equals
on
this object.getCookie
in interface LeasedResource
Uuid getUuid()
Uuid
for this set.void definiteException(EventType type, RemoteEvent ev, long registrationNumber)
protected boolean isolateSets()
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.