Package com.tangosol.net
Class ConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.net.ConfigurableQuorumPolicy
-
- com.tangosol.net.ConfigurableQuorumPolicy.MembershipQuorumPolicy
-
- com.tangosol.net.ConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy
-
- All Implemented Interfaces:
ActionPolicy
- Enclosing class:
- ConfigurableQuorumPolicy
public static class ConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy extends ConfigurableQuorumPolicy.MembershipQuorumPolicy
PartitionedCacheQuorumPolicy defines a configurable quorum policy that is applicable to a DistributedCacheService.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy.ActionRule
Action Rules forConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy
static class
ConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy.Notification
Notification is a simple struct carrying the notification info.-
Nested classes/interfaces inherited from class com.tangosol.net.ConfigurableQuorumPolicy.MembershipQuorumPolicy
ConfigurableQuorumPolicy.MembershipQuorumPolicy.QuorumListener, ConfigurableQuorumPolicy.MembershipQuorumPolicy.QuorumRule
-
Nested classes/interfaces inherited from class com.tangosol.net.ConfigurableQuorumPolicy
ConfigurableQuorumPolicy.ClusterQuorumPolicy, ConfigurableQuorumPolicy.MembershipQuorumPolicy, ConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy, ConfigurableQuorumPolicy.ProxyQuorumPolicy
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Field Summary
Fields Modifier and Type Field Description protected AddressProvider
m_apRecovery
The recovery address-provider.protected boolean
m_fDynamic
If set to true, indicates a dynamic active recovery strategy.protected long
m_ldtLastReport
The last time disallowed actions were reported.static int
MASK_DISTRIBUTION
Bitmask used to encode a distribution action.protected static int
MASK_LAST
The highest used bitmask value.static int
MASK_READ
Bitmask used to encode a read action.static int
MASK_RECOVER
Bitmask used to encode a recover action.static int
MASK_RESTORE
Bitmask used to encode a partition restore action.static int
MASK_WRITE
Bitmask used to encode a write action.-
Fields inherited from class com.tangosol.net.ConfigurableQuorumPolicy.MembershipQuorumPolicy
m_aRules, m_ruleCurrent, m_service, m_setLeaving
-
-
Constructor Summary
Constructors Constructor Description PartitionedCacheQuorumPolicy(ConfigurableQuorumPolicy.MembershipQuorumPolicy.QuorumRule[] aRule, AddressProvider provider)
Construct a PartitionedCacheQuorumPolicy with the specified rule.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static int
calculateMinimumNodeCount(Set<Member> setMembers)
Given a set of Member objects, calculate the minimum number of nodes on a single machine.protected int
calculateMinThreshold(int cLast, float flPct)
Calculate the minimum number of storage enabled nodes necessary to proceed with the service recovery.protected List<ConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy.Notification>
checkRecoveryMembership(PartitionedService.PartitionRecoveryAction action)
Check if the recovery is allowed for the current membership.protected String
getActionName(int nMask)
Return the string description of the given rule mask.protected Set
getOwnershipMemberSet()
Return the set of ownership-enabled members in the associated PartitionedService.int
getPolicyPopulation()
Calculate and return the current size of the member set that contributes to the quorum for this policy domain.PartitionedService
getService()
Return the associated PartitionedService.protected PartitionSet
getStalePartitions(PartitionedService.PartitionRecoveryAction action, PartitionSet partsRecover, PartitionSet partsMissing)
Return staled partition set.String
getStatusDescription()
Return a String that describes the current Quorum state.boolean
isAllowed(Service service, Action action)
Evaluate if the specified action is currently allowed by this policy.protected void
reportDisallowedAction(int nMaskDisallowed, List<ConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy.Notification> listReasons)
Report all disallowed actions if the quorum rule has changed.protected static String
reportLastOwnership(PartitionSet parts, com.tangosol.net.internal.QuorumInfo info)
Report the machine names in the "last good" membership that owned the specified partitions.protected void
updateCurrentRule()
Update the currently applicable quorum rule, possibly changing it to reflect growth or shrinkage of the membership size.-
Methods inherited from class com.tangosol.net.ConfigurableQuorumPolicy.MembershipQuorumPolicy
configure, getCurrentRule, getLeavingMembers, getQuorumRules, getRule, init, instantiateMemberListener, setCurrentRule, setQuorumRules, setService, toString
-
Methods inherited from class com.tangosol.net.ConfigurableQuorumPolicy
instantiateClusterPolicy, instantiatePartitionedCachePolicy, instantiateProxyPolicy
-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
-
-
-
Field Detail
-
MASK_DISTRIBUTION
public static final int MASK_DISTRIBUTION
Bitmask used to encode a distribution action.- See Also:
- Constant Field Values
-
MASK_RESTORE
public static final int MASK_RESTORE
Bitmask used to encode a partition restore action.- See Also:
- Constant Field Values
-
MASK_READ
public static final int MASK_READ
Bitmask used to encode a read action.- See Also:
- Constant Field Values
-
MASK_WRITE
public static final int MASK_WRITE
Bitmask used to encode a write action.- See Also:
- Constant Field Values
-
MASK_RECOVER
public static final int MASK_RECOVER
Bitmask used to encode a recover action.- See Also:
- Constant Field Values
-
MASK_LAST
protected static final int MASK_LAST
The highest used bitmask value.- See Also:
- Constant Field Values
-
m_apRecovery
protected AddressProvider m_apRecovery
The recovery address-provider.
-
m_ldtLastReport
protected long m_ldtLastReport
The last time disallowed actions were reported.
-
m_fDynamic
protected boolean m_fDynamic
If set to true, indicates a dynamic active recovery strategy.
-
-
Constructor Detail
-
PartitionedCacheQuorumPolicy
public PartitionedCacheQuorumPolicy(ConfigurableQuorumPolicy.MembershipQuorumPolicy.QuorumRule[] aRule, AddressProvider provider)
Construct a PartitionedCacheQuorumPolicy with the specified rule.- Parameters:
aRule
- the quorum ruleprovider
- the recovery address-provider
-
-
Method Detail
-
getOwnershipMemberSet
protected Set getOwnershipMemberSet()
Return the set of ownership-enabled members in the associated PartitionedService.- Returns:
- the set of ownership-enabled members
-
getService
public PartitionedService getService()
Return the associated PartitionedService.- Overrides:
getService
in classConfigurableQuorumPolicy.MembershipQuorumPolicy
- Returns:
- the associated PartitionedService
-
checkRecoveryMembership
protected List<ConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy.Notification> checkRecoveryMembership(PartitionedService.PartitionRecoveryAction action)
Check if the recovery is allowed for the current membership.
If the address provider is specified, it means that all the recovery addresses are represented by the ownership-enabled members.
For dynamic active persistence strategy it means that:- Global partition (partition 0) is recoverable.
- All machines, derived from the global partition, are present.
- All other partitions are accessible / recoverable across the service members.
- The number of members is larger than the threshold, which is calculated as a factor of the "last well-formed" member set size
- Returns:
- null if the recovery is allowed; otherwise a list of rejection reasons
-
getStalePartitions
protected PartitionSet getStalePartitions(PartitionedService.PartitionRecoveryAction action, PartitionSet partsRecover, PartitionSet partsMissing)
Return staled partition set.- Parameters:
action
- the recovery actionpartsRecover
- the partitions to be recoveredpartsMissing
- the partitions that are missing- Returns:
- the staled partitions
-
calculateMinThreshold
protected int calculateMinThreshold(int cLast, float flPct)
Calculate the minimum number of storage enabled nodes necessary to proceed with the service recovery.- Parameters:
cLast
- the "last well-formed" member set sizeflPct
- the percentage of "last well-formed" member set size- Returns:
- the number of nodes necessary for the recovery to commence; the default implementation calculates it as "2/3" of the last "well-formed" member set size.
-
reportLastOwnership
protected static String reportLastOwnership(PartitionSet parts, com.tangosol.net.internal.QuorumInfo info)
Report the machine names in the "last good" membership that owned the specified partitions.- Parameters:
parts
- the partitions to reportinfo
- the QuorumInfo containing the "last good" membership data- Returns:
- the human readable string with the machine names
-
calculateMinimumNodeCount
protected static int calculateMinimumNodeCount(Set<Member> setMembers)
Given a set of Member objects, calculate the minimum number of nodes on a single machine.- Parameters:
setMembers
- the member set- Returns:
- the minimum number of nodes for a machine
-
getStatusDescription
public String getStatusDescription()
Return a String that describes the current Quorum state.- Specified by:
getStatusDescription
in classConfigurableQuorumPolicy
- Returns:
- a String describing the allowed actions in the current state
-
getPolicyPopulation
public int getPolicyPopulation()
Calculate and return the current size of the member set that contributes to the quorum for this policy domain.Note: The quorum for PartitionedService is determined by the ownership-enabled members only.
- Overrides:
getPolicyPopulation
in classConfigurableQuorumPolicy.MembershipQuorumPolicy
- Returns:
- the current size
-
isAllowed
public boolean isAllowed(Service service, Action action)
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.
- 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
-
updateCurrentRule
protected void updateCurrentRule()
Description copied from class:ConfigurableQuorumPolicy.MembershipQuorumPolicy
Update the currently applicable quorum rule, possibly changing it to reflect growth or shrinkage of the membership size.- Overrides:
updateCurrentRule
in classConfigurableQuorumPolicy.MembershipQuorumPolicy
-
reportDisallowedAction
protected void reportDisallowedAction(int nMaskDisallowed, List<ConfigurableQuorumPolicy.PartitionedCacheQuorumPolicy.Notification> listReasons)
Report all disallowed actions if the quorum rule has changed.- Parameters:
nMaskDisallowed
- a mask of the disallowed actionlistReasons
- (optional) a list of rejection reasons
-
getActionName
protected String getActionName(int nMask)
Return the string description of the given rule mask.- Parameters:
nMask
- the bitmask- Returns:
- the string description of the given rule mask
-
-