|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.javagroups.service.AbstractService
org.javagroups.service.lease.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.
Nested Class Summary | |
static class |
LeaseFactoryService.LeaseInfo
This class represents granted lease that is replicated between services. |
Field Summary | |
protected PullPushAdapter |
clientAdapter
|
static int |
DEFAULT_BEST_FIT_DURATION
|
static java.lang.String |
LEASE_SERVICE_NAME
|
protected java.util.Map |
leases
|
static int |
MAXIMUM_DURATION
|
Fields inherited from class org.javagroups.service.AbstractService |
blocked, blockMonitor, clientChannel, members, runThread, serviceAdapter, serviceChannel, threadMonitor |
Constructor Summary | |
LeaseFactoryService(Channel serviceChannel,
Channel clientChannel)
Create instance of this class. |
Method Summary | |
protected void |
denyLeaseRequest(int denialType,
Address requester,
java.lang.String reason,
java.lang.Object leaseTarget,
java.lang.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 . |
java.lang.String |
getName()
Get name of this service. |
protected void |
incorrectStateReceived(java.lang.Object incorrectState)
This method is called when service queries new state but received state contains incorrect entries. |
protected void |
processCancelLeaseRequest(LeaseRequestHeader header,
java.lang.Object leaseTarget,
Address requester)
Process request to cancel lease. |
protected void |
processNewLeaseRequest(LeaseRequestHeader header,
java.lang.Object leaseTarget,
Address requester)
Process new lease request. |
protected void |
processRenewLeaseRequest(LeaseRequestHeader header,
java.lang.Object leaseTarget,
Address requester)
Process request to renew a lease. |
protected void |
propagateStateChange(int type,
LeaseFactoryService.LeaseInfo leaseInfo,
java.lang.Object leaseTarget)
Propagate state change to other members. |
Methods inherited from class org.javagroups.service.AbstractService |
block, getAddress, isBlocked, isCoordinator, setMessageListener, start, stop, suspect, viewAccepted, waitOnBlocked |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String LEASE_SERVICE_NAME
public static final int DEFAULT_BEST_FIT_DURATION
public static final int MAXIMUM_DURATION
protected PullPushAdapter clientAdapter
protected java.util.Map leases
Constructor Detail |
public LeaseFactoryService(Channel serviceChannel, Channel clientChannel)
serviceChannel
- channel that will be used for inter-service
communication.clientChannel
- channel that will be used for client-service
communication.Method Detail |
public java.lang.String getName()
getName
in class AbstractService
LEASE_SERVICE_NAME
constant.protected long getBestFitDuration()
LeaseFactory.DURATION_ANY
.
Value returned by this method is absolute expiration time.
System.currentTimeMillis() + DEFAULT_BEST_FIT_DURATION;
protected long getMaximumDuration()
LeaseFactory.DURATION_FOREVER
.
Value returned by this method is absolute expiration time.
System.currentTimeMillis() + MAXIMUM_DURATION;
protected void incorrectStateReceived(java.lang.Object incorrectState)
protected void propagateStateChange(int type, LeaseFactoryService.LeaseInfo leaseInfo, java.lang.Object leaseTarget)
protected void denyLeaseRequest(int denialType, Address requester, java.lang.String reason, java.lang.Object leaseTarget, java.lang.Object tenant)
protected void processNewLeaseRequest(LeaseRequestHeader header, java.lang.Object leaseTarget, Address requester)
protected void processRenewLeaseRequest(LeaseRequestHeader header, java.lang.Object leaseTarget, Address requester)
protected void processCancelLeaseRequest(LeaseRequestHeader header, java.lang.Object leaseTarget, Address requester)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |