com.sun.jini.norm
Class LeaseExpirationMgr

java.lang.Object
  extended by com.sun.jini.norm.LeaseExpirationMgr
All Implemented Interfaces:
WeakTable.KeyGCHandler

 class LeaseExpirationMgr
extends Object
implements WeakTable.KeyGCHandler

Lease manager that aggressively expires leases as their expiration times occur. Also schedules and manages expiration warning events.

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.

Author:
Sun Microsystems, Inc.

Nested Class Summary
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.
 
Field Summary
(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 Summary
LeaseExpirationMgr(NormServerBaseImpl server)
          Create a LeaseExpirationMgr to aggressively expire the leases of the passed NormServerBaseImpl
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static final Logger logger
Logger for logging messages for this class


ticketMap

private WeakTable ticketMap
Map of sets to task tickets.

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.


server

private NormServerBaseImpl server
Ref to the main server object has all the top level methods


runQueue

private WakeupManager runQueue
Queue of tasks, ordered by time


expireQueue

final List expireQueue
Queue of tasks to expire sets


expireThread

private final Thread expireThread
Thread to expire sets

Constructor Detail

LeaseExpirationMgr

LeaseExpirationMgr(NormServerBaseImpl server)
Create a LeaseExpirationMgr to aggressively expire the leases of the passed NormServerBaseImpl

Method Detail

terminate

void terminate()
Terminate the LeaseExpirationMgr, killing any threads it has started


register

void register(LeasedResource resource)
Notifies the manager of a new lease being created.

Parameters:
resource - the resource associated with the new lease

reschedule

void reschedule(LeasedResource resource)
Notifies the manager of a lease being renewed.

This method assumes the lock on set is owned by the current thread.

Parameters:
resource - the set for which tasks have to be rescheduled

schedule

void schedule(LeasedResource resource)
Schedule a leased resource to be reaped in the future. Called when a resource gets a lease, a lease is renewed, and during log recovery.

This method assumes the lock on resource is owned by the current thread.


keyGC

public void keyGC(Object value)
Description copied from interface: WeakTable.KeyGCHandler
Called by WeakTable when it notices that a key has been collected and the value still exists.

Specified by:
keyGC in interface WeakTable.KeyGCHandler
Parameters:
value - The value associated with the collected key


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.