|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.javagroups.service.lease.LeaseFactoryClient
LeaseFactoryClient
is an implementation of LeaseFactory
interface that delegates lease granting to group containing one or more
LeaseFactoryService
instances.
This service tries to implement semi-synchronous communication pattern: each call blocks until reply from service received or timeout occurs.
Also this implementation assumes that pending new lease request conflicts with renewal request and request that came last is aborted.
Field Summary | |
protected int |
cancelTimeout
|
protected PullPushAdapter |
clientAdapter
|
protected Channel |
clientChannel
|
static int |
DEFAULT_CANCEL_TIMEOUT
|
static int |
DEFAULT_LEASE_TIMEOUT
|
protected int |
leaseTimeout
|
protected java.util.HashMap |
pendingCancels
|
protected java.util.HashMap |
pendingLeases
|
protected java.util.HashMap |
pendingRenewals
|
Fields inherited from interface org.javagroups.service.lease.LeaseFactory |
DURATION_ANY, DURATION_FOREVER |
Constructor Summary | |
LeaseFactoryClient(Channel clientChannel)
Create instance of this class for specified client channel with default timeouts. |
|
LeaseFactoryClient(Channel clientChannel,
int leaseTimeout,
int cancelTimeout)
Create instance of this class for the specified channel with specified timeouts. |
Method Summary | |
void |
cancelLease(Lease existingLease)
Cancel existing lease. |
Address |
getAddress()
Get address of this client in group. |
Lease |
newLease(java.lang.Object leaseTarget,
java.lang.Object tenant,
long requestedDuration,
boolean isAbsolute)
Get new lease. |
Lease |
renewLease(Lease existingLease,
long requestedDuration,
boolean isAbsolute)
Renew existing lease. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_LEASE_TIMEOUT
public static final int DEFAULT_CANCEL_TIMEOUT
protected Channel clientChannel
protected PullPushAdapter clientAdapter
protected int leaseTimeout
protected int cancelTimeout
protected java.util.HashMap pendingLeases
protected java.util.HashMap pendingRenewals
protected java.util.HashMap pendingCancels
Constructor Detail |
public LeaseFactoryClient(Channel clientChannel)
public LeaseFactoryClient(Channel clientChannel, int leaseTimeout, int cancelTimeout)
clientChannel
- channel that will be used for client-service
communication.leaseTimeout
- timeout for "new lease" and "renew lease" requests.cancelTimeout
- timeout for "cancel lease" timeout.Method Detail |
public void cancelLease(Lease existingLease) throws UnknownLeaseException
cancelLease
in interface LeaseFactory
existingLease
- lease to cancel.
UnknownLeaseException
- if existingLease
is unknown
for this lease factory. Usually means that lease was granted by another
factory.public Lease newLease(java.lang.Object leaseTarget, java.lang.Object tenant, long requestedDuration, boolean isAbsolute) throws LeaseDeniedException
newLease
in interface LeaseFactory
leaseTarget
- unique identifier of resource to be leased.tenant
- unique identifier of entity that requests lease.isAbsolute
- specified if lease duration is absolute or relative.
Lease
representing granted lease. Note,
granted lease might have different duration than requested.
LeaseDeniedException
- if lease cannot be granted.public Lease renewLease(Lease existingLease, long requestedDuration, boolean isAbsolute) throws LeaseDeniedException
existingLease
must be valid.
renewLease
in interface LeaseFactory
isAbsolute
- specified if lease duration is absolute or relative.
Lease
representing granted lease. Note,
granted lease might have different duration than requested.
LeaseDeniedException
- if lease cannot be granted.public Address getAddress()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |