Class FailoverAccessPolicy
- All Implemented Interfaces:
ActionPolicy
While typically not necessary to ensure the timely recovery to a "safe" state, this access policy could be used in situations where a heavy load of of high-latency requests may prevent or significantly delay cache servers from successfully acquiring exclusive access to partitions needing to be transferred or backed up.
- Since:
- Coherence 12.1.2
- Author:
- rhl 09.12.2011
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
The MemberListener is used to listen to service membership events to monitor the endangered status of the service. -
Field Summary
Modifier and TypeFieldDescriptionlong
The amount of time after being in an endangered state after which the quorum policy makes a maximal effort to hold client requests.long
The maximum amount of time (in ms) that a request could be delayed by this quorum policy.long
The amount of time after being in an endangered state before the quorum policy should start to hold client requests.long
The time at which the service most recently became endangered (or 0 if the service is in the "safe" state).int
One of the STATE_* constants representing the current quorum state.protected PartitionedService
The PartitionedService that this quorum policy is bound to.static final int
Constant used to indicate that the service is in an endangered state.static final int
Constant used to indicate that the service is "safe" (non-endangered).static final int
Constant used to indicate that the service is in an unknown (possibly endangered) state. -
Constructor Summary
ConstructorDescriptionDefault constructor.FailoverAccessPolicy
(long cThresholdMillis, long cLimitMillis, long cMaxDelayMillis) Construct a FailoverAccessPolicy according to the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected long
calculateWaitTime
(long cMillisEndangered) Return the amount of time that a request should be delayed before being allowed to proceed.protected boolean
Check to see if the associated service is endangered.int
getState()
Return the current endangered state (one of the STATE_* constants).void
Called when the specified service loads and configures this policy.boolean
Evaluate if the specified action is currently allowed by this policy.protected void
setState
(int nState) Set the endangered state (one of the STATE_* constants).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tangosol.net.ActionPolicy
toString
-
Field Details
-
STATE_SAFE
public static final int STATE_SAFEConstant used to indicate that the service is "safe" (non-endangered).- See Also:
-
STATE_UNKNOWN
public static final int STATE_UNKNOWNConstant used to indicate that the service is in an unknown (possibly endangered) state.- See Also:
-
STATE_ENDANGERED
public static final int STATE_ENDANGEREDConstant used to indicate that the service is in an endangered state.- See Also:
-
m_cThresholdMillis
public long m_cThresholdMillisThe amount of time after being in an endangered state before the quorum policy should start to hold client requests. -
m_cLimitMillis
public long m_cLimitMillisThe amount of time after being in an endangered state after which the quorum policy makes a maximal effort to hold client requests. -
m_cMaxDelayMillis
public long m_cMaxDelayMillisThe maximum amount of time (in ms) that a request could be delayed by this quorum policy. -
m_nState
public int m_nStateOne of the STATE_* constants representing the current quorum state.Note: this field is intentionally left non-volatile. The consequence of a "stale" read is that the first request per thread following a transition to endangered could be missed by this quorum (allowed to proceed). As this has no impact, we would rather avoid the additional volatile read on each "normal" operation.
-
m_ldtEndangered
public long m_ldtEndangeredThe time at which the service most recently became endangered (or 0 if the service is in the "safe" state). -
m_service
The PartitionedService that this quorum policy is bound to.
-
-
Constructor Details
-
FailoverAccessPolicy
public FailoverAccessPolicy()Default constructor. -
FailoverAccessPolicy
public FailoverAccessPolicy(long cThresholdMillis, long cLimitMillis, long cMaxDelayMillis) Construct a FailoverAccessPolicy according to the specified parameters.- Parameters:
cThresholdMillis
- the delay before the policy should start holding requests (after becoming endangered)cLimitMillis
- the delay before the policy makes a maximal effort to hold requests (after becoming endangered)cMaxDelayMillis
- the maximum amount of time to hold a request
-
-
Method Details
-
getState
public int getState()Return the current endangered state (one of the STATE_* constants).- Returns:
- the current endangered state
-
setState
protected void setState(int nState) Set the endangered state (one of the STATE_* constants).- Parameters:
nState
- the new endangered state
-
init
Called when the specified service loads and configures this policy.Note: A policy could be applied to multiple services.
- Specified by:
init
in interfaceActionPolicy
- Parameters:
service
- the service that this policy applies to
-
isAllowed
Evaluate if the specified action is currently allowed by this policy.Note: for forward compatibility, implementations should generally return true for actions that are not recognized.
- Specified by:
isAllowed
in interfaceActionPolicy
- Parameters:
service
- the service that is performing the actionaction
- the action that is being performed- Returns:
- true iff the specified action is currently allowed by this policy
-
calculateWaitTime
protected long calculateWaitTime(long cMillisEndangered) Return the amount of time that a request should be delayed before being allowed to proceed.- Parameters:
cMillisEndangered
- the amount of time that the service has been endangered- Returns:
- the amount of time (in ms) to delay the client request
-
checkEndangered
protected boolean checkEndangered()Check to see if the associated service is endangered.Note: the caller must hold synchronization on this quorum policy.
- Returns:
- true iff the service is endangered
-