|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.mbari.siam.distributed.leasing.LeaseManager
public class LeaseManager
LeaseManager was written to manage an intermittent communication link, though it could be used to manage other resources that fit the paradigm. The paradigm consists of two types of "clients". Lessees are clients who want to keep the resource (link) open, and do so by calling establish(), renew() and terminate(). LeaseManager can manage multiple such clients simultaneously, and keeps them in a vector. LeaseListeners are clients who actually perform the resource management based on whether there are any outstanding lessees. In the current implementation, there is just one LeaseListener, who simply turns on/off the RF power to the link. But in principle there can also be multiple listeners, who presumably perform different functions based on the lease state. NOTE: It is important that the callbacks implemented by LeaseListeners execute in a timely manner, so that the remote client is not blocked for an excessive amount of time.
| Nested Class Summary | |
|---|---|
class |
LeaseManager.Lessee
A Lessee is constructed and put on the _lessees list for every LeaseManager.establish(). |
| Field Summary | |
|---|---|
static long |
UNKNOWN_TIME
Constant which indicates an indeterminate time. |
| Constructor Summary | |
|---|---|
LeaseManager()
Constructor. |
|
| Method Summary | |
|---|---|
void |
addListener(LeaseListener listener)
Add a lease listener. |
protected void |
debugPrint(java.lang.String message)
Print debug message. |
int |
establish(long leaseMillisec,
long nextEstablishTime,
java.lang.String clientNote)
Called to establish the communications link. |
int |
establish(long leaseMillisec,
java.lang.String clientNote)
Called to establish the communications link. |
LeaseManager.Lessee |
getLessee(int leaseID)
Get the Lessee that has a given LeaseID |
java.util.Vector |
getLessees()
Return vector of lessess. |
int |
nLessees()
Return number of lessees |
void |
renew(int leaseID,
long leaseDurationMsec)
Called when lease is being renewed. |
void |
terminate(int leaseID,
long nextConnectTime)
Called when communications link is being disconnected. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final long UNKNOWN_TIME
| Constructor Detail |
|---|
public LeaseManager()
| Method Detail |
|---|
public void addListener(LeaseListener listener)
public int establish(long leaseMillisec,
long nextEstablishTime,
java.lang.String clientNote)
throws LeaseRefused
leaseMillisec - lease period in millisecondsnextEstablishTime - Estimated time that this task expects to
call establish() again.clientNote - note about connection
LeaseRefused
public int establish(long leaseMillisec,
java.lang.String clientNote)
throws LeaseRefused
leaseMillisec - lease period in milliseconds
LeaseRefusedpublic LeaseManager.Lessee getLessee(int leaseID)
public int nLessees()
public java.util.Vector getLessees()
public void renew(int leaseID,
long leaseDurationMsec)
throws LeaseRefused
leaseID - lease identifierleaseDurationMsec - lease period in milliseconds
LeaseRefused
public void terminate(int leaseID,
long nextConnectTime)
throws LeaseRefused
nextConnectTime - next scheduled connection time
(millisec from epoch)
LeaseRefusedprotected void debugPrint(java.lang.String message)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||