org.jgroups.service.lease
Class LeaseFactoryService
- MembershipListener
public class LeaseFactoryService
LeaseFactoryService
is service that is able to lease resources
to clients. Lease request is sent using client-service communication channel
and is identified by presence of
LeaseRequestHeader
header in
message headers. There might be only one lease request header per message.
It contains information about lease term and entity requesting lease, message
payload contains unique identifier of resource to lease.
There is only one lease factory service talking to the client, coordinator
of service group. Group of lease factory services is able to tolerate
failures detectable by failure detector of inter-service communication
channel.
This service is able to grant only one lease per resource, it is not able to
determine correctly best-fit lease duration and uses fixed duration of 10
seconds, maximum duration is 60 seconds. Note, these durations apply only
cases when lease term was not explicitly specified
(
LeaseFactory.DURATION_ANY
or
LeaseFactory.DURATION_FOREVER
used as lease term). Subclasses might use more intelligent algorithm to
determine lease duration and lease request conflicts using semantics of
underlying resource.
- Roman Rokytskyy (rrokytskyy@acm.org)
protected void | denyLeaseRequest(int denialType, Address requester, String reason, Object leaseTarget, Object tenant) - Deny lease request.
|
protected long | getBestFitDuration() - Get best-fit duration leases with duration
LeaseFactory.DURATION_ANY .
|
protected long | getMaximumDuration() - Get best-fit duration leases with duration
LeaseFactory.DURATION_FOREVER .
|
String | getName() - Get name of this service.
|
protected void | incorrectStateReceived(Object incorrectState) - This method is called when service queries new state but received state
contains incorrect entries.
|
protected void | processCancelLeaseRequest(LeaseRequestHeader header, Object leaseTarget, Address requester) - Process request to cancel lease.
|
protected void | processNewLeaseRequest(LeaseRequestHeader header, Object leaseTarget, Address requester) - Process new lease request.
|
protected void | processRenewLeaseRequest(LeaseRequestHeader header, Object leaseTarget, Address requester) - Process request to renew a lease.
|
protected void | propagateStateChange(int type, LeaseFactoryService.LeaseInfo leaseInfo, Object leaseTarget) - Propagate state change to other members.
|
block , getAddress , getName , isBlocked , isCoordinator , setMessageListener , start , stop , suspect , viewAccepted , waitOnBlocked |
DEFAULT_BEST_FIT_DURATION
public static final int DEFAULT_BEST_FIT_DURATION
LEASE_SERVICE_NAME
public static final String LEASE_SERVICE_NAME
MAXIMUM_DURATION
public static final int MAXIMUM_DURATION
leases
protected Map leases
LeaseFactoryService
public LeaseFactoryService(Channel serviceChannel,
Channel clientChannel)
Create instance of this class. This constructor constructs registers
message listeners on client-service and inter-service communication
channel.
serviceChannel
- channel that will be used for inter-service
communication.clientChannel
- channel that will be used for client-service
communication.
denyLeaseRequest
protected void denyLeaseRequest(int denialType,
Address requester,
String reason,
Object leaseTarget,
Object tenant)
Deny lease request.
getBestFitDuration
protected long getBestFitDuration()
Get best-fit duration leases with duration LeaseFactory.DURATION_ANY
.
Value returned by this method is absolute expiration time.
System.currentTimeMillis() + DEFAULT_BEST_FIT_DURATION;
getMaximumDuration
protected long getMaximumDuration()
Get best-fit duration leases with duration
LeaseFactory.DURATION_FOREVER
.
Value returned by this method is absolute expiration time.
System.currentTimeMillis() + MAXIMUM_DURATION;
getName
public String getName()
Get name of this service.
- getName in interface AbstractService
- value of
LEASE_SERVICE_NAME
constant.
incorrectStateReceived
protected void incorrectStateReceived(Object incorrectState)
This method is called when service queries new state but received state
contains incorrect entries. Subclasses should implement this method
according to their needs.
processCancelLeaseRequest
protected void processCancelLeaseRequest(LeaseRequestHeader header,
Object leaseTarget,
Address requester)
Process request to cancel lease. This method checks if lease was granted,
and cancels it if there is a match between party that was granted a lease
and a party that cancels a lease.
processNewLeaseRequest
protected void processNewLeaseRequest(LeaseRequestHeader header,
Object leaseTarget,
Address requester)
Process new lease request. This method checks if there is already lease
on the specified resource, and if no lease found grants it. Otherwise
lease request is denied and appropriate message is sent to client.
processRenewLeaseRequest
protected void processRenewLeaseRequest(LeaseRequestHeader header,
Object leaseTarget,
Address requester)
Process request to renew a lease. This method checks if lease was granted
and extends lease duration if
propagateStateChange
protected void propagateStateChange(int type,
LeaseFactoryService.LeaseInfo leaseInfo,
Object leaseTarget)
Propagate state change to other members.
Copyright B) 2001,2002 www.jgroups.com . All Rights Reserved.