context.arch.discoverer.lease
Class LeasesKeeper

java.lang.Object
  extended bycontext.arch.discoverer.lease.LeasesKeeper

public class LeasesKeeper
extends java.lang.Object

A component registers to the discoverer for a given period of time that is defined with a lease. That allows the discovery system to make sure a component is still available. This class keeps all information about the context components leases that are registered. It contains a LeasesWatcher object that watches the end of leases each xx minutes as defined in the Lease class by the constant Lease.TIME_SLOT_MILLIS. If the LeaseKeeper detects the end of a lease, it sends it to the discoverer that will send a checking message to the component.

Author:
Agathe
See Also:
LeasesWatcher, Discoverer

Field Summary
protected  java.util.Hashtable leases
          All leases, associates the component (Integer)index -> Lease object
protected  DiscovererMediator mediator
          The discoverer object
protected  LeasesWatcher watcher
          The watcher that triggers the leases examination
 
Constructor Summary
LeasesKeeper(DiscovererMediator mediator)
          Creates new LeasesKeeper TO COMPLETE (if the discoverer restarts from a log file)
 
Method Summary
 void addLease(Lease lease)
          Adds a Lease object and update the LeaseWatcher object
 java.lang.Integer contains(java.lang.Integer componentIndex)
          This method tests if an index of a ComponentDescription exists
 boolean existingComponentDescription(java.lang.Integer componentDescriptionIndex)
          Tests if an index corresponds to an existing ComponentDescription in the discoverer
 void leaseEndNotificationTo(java.util.ArrayList listOfLeaseEnd)
          This method allows to send a list of leases that should end to the discoverer.
 Lease removeLease(java.lang.Integer indexToRemove)
          This method allows to remove a Lease corresponding to the index
 boolean renewLease(Lease renewal)
          This method allows to renew an exiting lease
 java.lang.String toString()
          Returns a printable version of this object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mediator

protected DiscovererMediator mediator
The discoverer object


leases

protected java.util.Hashtable leases
All leases, associates the component (Integer)index -> Lease object


watcher

protected LeasesWatcher watcher
The watcher that triggers the leases examination

Constructor Detail

LeasesKeeper

public LeasesKeeper(DiscovererMediator mediator)
Creates new LeasesKeeper TO COMPLETE (if the discoverer restarts from a log file)

Method Detail

addLease

public void addLease(Lease lease)
Adds a Lease object and update the LeaseWatcher object

Parameters:
lease - The Lease object

leaseEndNotificationTo

public void leaseEndNotificationTo(java.util.ArrayList listOfLeaseEnd)
This method allows to send a list of leases that should end to the discoverer.

Parameters:
listOfLeaseEnd - The leases to send to the discoverer

removeLease

public Lease removeLease(java.lang.Integer indexToRemove)
This method allows to remove a Lease corresponding to the index

Parameters:
indexToRemove - The index of the ComponentDescription for which we want to remove the lease
Returns:
Lease The removed Lease object

contains

public java.lang.Integer contains(java.lang.Integer componentIndex)
This method tests if an index of a ComponentDescription exists

Parameters:
componentIndex - The Integer to test
Returns:
boolean True if this object contains componentIndex

toString

public java.lang.String toString()
Returns a printable version of this object

Returns:
String

renewLease

public boolean renewLease(Lease renewal)
This method allows to renew an exiting lease

Parameters:
renewal - The new lease
Returns:
boolean True if the lease has been updated for the given index

existingComponentDescription

public boolean existingComponentDescription(java.lang.Integer componentDescriptionIndex)
Tests if an index corresponds to an existing ComponentDescription in the discoverer

Parameters:
componentDescriptionIndex - The index of the object to test
Returns:
boolean True if there is an existing component description with this index in the discoverer