org.jgroups.service.lease
Interface LeaseFactory
- LeaseFactoryClient
public interface LeaseFactory
LeaseFactory
is responsible for granting new leases, renewing
existing leases and canceling leases when it is no longer needed. For batch
purposes, LeaseFactory
creates instances of LeaseGroup
.
- Roman Rokytskyy (rrokytskyy@acm.org)
static long | DURATION_ANY - This constant represents arbitrary duration.
|
static long | DURATION_FOREVER - This constant represents maximum possible duration.
|
void | cancelLease(Lease existingLease) - Cancels existing lease.
|
Lease | newLease(Object leaseTarget, Object tenant, long requestedDuration, boolean isAbsolute) - Obtain new lease.
|
Lease | renewLease(Lease existingLease, long requestedDuration, boolean isAbsolute) - Renew existing lease.
|
DURATION_ANY
public static final long DURATION_ANY
This constant represents arbitrary duration. When passed to
LeaseFactory.newLease(Object, long, boolean)
, implementation
grants lease for a duration that best fits leased resource.
- -1L
DURATION_FOREVER
public static final long DURATION_FOREVER
This constant represents maximum possible duration. When passed to
LeaseFactory.newLease(Object, long, boolean)
, implementation
usually will grant lease for a maximum possible duration for leased
resource.
cancelLease
public void cancelLease(Lease existingLease)
throws UnknownLeaseException
Cancels existing lease. After invoking this method leased resource is
free.
existingLease
- lease to cancel.
UnknownLeaseException
- if existingLease
is unknown
for this lease factory. Usually means that lease was granted by another
factory.
newLease
public Lease newLease(Object leaseTarget,
Object tenant,
long requestedDuration,
boolean isAbsolute)
throws LeaseDeniedException
Obtain new lease. When client wants to access to resource that is
protected by leasing mechanism, he needs to obtain lease. Each lease
contains lease target that is unique identifier of resource and lease
duration, either relative or absolute.
LeaseFactory
checks its internal lease map and decides
if the lease can be granted or not. In latter case,
LeaseDeniedException
is thrown.
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.
- instance of
Lease
representing granted lease. Note,
granted lease might have different duration than requested.
LeaseDeniedException
- if lease cannot be granted.
renewLease
public Lease renewLease(Lease existingLease,
long requestedDuration,
boolean isAbsolute)
throws LeaseDeniedException
Renew existing lease. This method extends lease duration from now for
a specified duration. If existingLease
has expired, an
exception is thrown. In this case client has to use
newLease(Object, long, boolean)
method to obtain a lease.
isAbsolute
- specified if lease duration is absolute or relative.
- instance of
Lease
representing granted lease. Note,
granted lease might have different duration than requested.
LeaseDeniedException
- if lease cannot be granted.
Copyright B) 2001,2002 www.jgroups.com . All Rights Reserved.