org.javagroups.service.lease
Class LeaseFactoryClient
java.lang.Object
|
+--org.javagroups.service.lease.LeaseFactoryClient
- All Implemented Interfaces:
- LeaseFactory
- public class LeaseFactoryClient
- extends java.lang.Object
- implements LeaseFactory
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.
- Author:
- Roman Rokytskyy (rrokytskyy@acm.org)
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 |
DEFAULT_LEASE_TIMEOUT
public static final int DEFAULT_LEASE_TIMEOUT
DEFAULT_CANCEL_TIMEOUT
public static final int DEFAULT_CANCEL_TIMEOUT
clientChannel
protected Channel clientChannel
clientAdapter
protected PullPushAdapter clientAdapter
leaseTimeout
protected int leaseTimeout
cancelTimeout
protected int cancelTimeout
pendingLeases
protected java.util.HashMap pendingLeases
pendingRenewals
protected java.util.HashMap pendingRenewals
pendingCancels
protected java.util.HashMap pendingCancels
LeaseFactoryClient
public LeaseFactoryClient(Channel clientChannel)
- Create instance of this class for specified client channel with
default timeouts.
LeaseFactoryClient
public LeaseFactoryClient(Channel clientChannel,
int leaseTimeout,
int cancelTimeout)
- Create instance of this class for the specified channel with specified
timeouts.
- Parameters:
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.
cancelLease
public void cancelLease(Lease existingLease)
throws UnknownLeaseException
- Cancel existing lease.
- Specified by:
cancelLease
in interface LeaseFactory
- Following copied from interface:
org.javagroups.service.lease.LeaseFactory
- Parameters:
existingLease
- lease to cancel.- Throws:
UnknownLeaseException
- if existingLease
is unknown
for this lease factory. Usually means that lease was granted by another
factory.
newLease
public Lease newLease(java.lang.Object leaseTarget,
java.lang.Object tenant,
long requestedDuration,
boolean isAbsolute)
throws LeaseDeniedException
- Get new lease.
- Specified by:
newLease
in interface LeaseFactory
- Following copied from interface:
org.javagroups.service.lease.LeaseFactory
- Parameters:
leaseTarget
- unique identifier of resource to be leased.tenant
- unique identifier of entity that requests lease.leaseDuration
- duration of lease in milliseconds.isAbsolute
- specified if lease duration is absolute or relative.- Returns:
- instance of
Lease
representing granted lease. Note,
granted lease might have different duration than requested. - Throws:
LeaseDeniedException
- if lease cannot be granted.
renewLease
public Lease renewLease(Lease existingLease,
long requestedDuration,
boolean isAbsolute)
throws LeaseDeniedException
- Renew existing lease. This method is used to extend lease time, therefore
existingLease
must be valid.
- Specified by:
renewLease
in interface LeaseFactory
- Following copied from interface:
org.javagroups.service.lease.LeaseFactory
- Parameters:
leaseTarget
- unique identifier of resource to be leased.leaseDuration
- duration of lease in milliseconds.isAbsolute
- specified if lease duration is absolute or relative.- Returns:
- instance of
Lease
representing granted lease. Note,
granted lease might have different duration than requested. - Throws:
LeaseDeniedException
- if lease cannot be granted.
getAddress
public Address getAddress()
- Get address of this client in group.
Copyright © 2001,2002 www.javagroups.com . All Rights Reserved.