class LeaseExpirationMgr extends Object implements WeakTable.KeyGCHandler
Note, unlike Mahalo's LeaseExpirationManager
(which this
was seeded from), we make no attempt to make it generic because of
the need to schedule expiration warning events.
Modifier and Type | Class and Description |
---|---|
private class |
LeaseExpirationMgr.Expiration
Objects that do the actual expiration of the set in question,
stuck in
expireQueue . |
private class |
LeaseExpirationMgr.ExpirationThread
Expires sets queued for expiration.
|
private class |
LeaseExpirationMgr.MgrTask
Utility base class for our tasks, mainly provides the the proper
locking for manipulating the ticketMap.
|
private class |
LeaseExpirationMgr.QueueExpiration
Task that queues a task to expire a lease set.
|
private class |
LeaseExpirationMgr.SendWarning
Objects that do the schedule the warning events, also schedules
an expiration task.
|
Modifier and Type | Field and Description |
---|---|
(package private) List |
expireQueue
Queue of tasks to expire sets
|
private Thread |
expireThread
Thread to expire sets
|
(package private) static Logger |
logger
Logger for logging messages for this class
|
private WakeupManager |
runQueue
Queue of tasks, ordered by time
|
private NormServerBaseImpl |
server
Ref to the main server object has all the top level methods
|
private WeakTable |
ticketMap
Map of sets to task tickets.
|
Constructor and Description |
---|
LeaseExpirationMgr(NormServerBaseImpl server)
Create a
LeaseExpirationMgr to aggressively expire
the leases of the passed NormServerBaseImpl |
Modifier and Type | Method and Description |
---|---|
void |
keyGC(Object value)
Called by WeakTable when it notices that a key has been
collected and the value still exists.
|
(package private) void |
register(LeasedResource resource)
Notifies the manager of a new lease being created.
|
(package private) void |
reschedule(LeasedResource resource)
Notifies the manager of a lease being renewed.
|
(package private) void |
schedule(LeasedResource resource)
Schedule a leased resource to be reaped in the future.
|
(package private) void |
terminate()
Terminate the
LeaseExpirationMgr , killing any
threads it has started |
static final Logger logger
private WeakTable ticketMap
A Note on Synchronization
Whenever we operate on the ticketMap
we hold
the lock on the key being used. This is necessary because
expiration and warning sender tasks need to remove tickets from
the map but at the same time a renewal may be updating the map
to associate the set with a new ticket. If we don't synchronize
there is a small window where a task could remove the ticket
for its replacement.
private NormServerBaseImpl server
private WakeupManager runQueue
final List expireQueue
private final Thread expireThread
LeaseExpirationMgr(NormServerBaseImpl server)
LeaseExpirationMgr
to aggressively expire
the leases of the passed NormServerBaseImpl
void terminate()
LeaseExpirationMgr
, killing any
threads it has startedvoid register(LeasedResource resource)
resource
- the resource associated with the new leasevoid reschedule(LeasedResource resource)
This method assumes the lock on set
is owned by the
current thread.
resource
- the set for which tasks have to be rescheduledvoid schedule(LeasedResource resource)
This method assumes the lock on resource
is owned by
the current thread.
public void keyGC(Object value)
WeakTable.KeyGCHandler
keyGC
in interface WeakTable.KeyGCHandler
value
- The value associated with the collected keyCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.