|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.net.partition.SimpleAssignmentStrategy
public class SimpleAssignmentStrategy
SimpleAssignmentStrategy is a PartitionAssignmentStrategy that attempts to balance the partition distribution based on the number of primary and backup partitions owned. The SimpleAssignmentStrategy will attempt to ensure machine-safety, but only if a balanced "safe" distribution is achievable.
The SimpleAssignmentStrategy is an extensible implementation of the internal distribution algorithm that was available prior to Coherence 3.7.
Nested Class Summary | |
---|---|
protected class |
SimpleAssignmentStrategy.AnalysisContext AnalysisContext holds the working view of the partition ownership that is used throughout the analysis and is used to reflect changes made during this analysis. |
protected static class |
SimpleAssignmentStrategy.BackupStrength BackupStrength represents a level of "strength" or "resiliency" between the primary and backup owners of a partition. |
static interface |
SimpleAssignmentStrategy.LoadCalculator LoadCalculator is used to calculate the scalar load (expressed as an integer) of a partition (or set of partitions). |
static class |
SimpleAssignmentStrategy.SimpleLoadCalculator SimpleLoadCalculator defines a "count-based" load (e.g. the load of each partition is defined to be 1). |
Field Summary | |
---|---|
protected SimpleAssignmentStrategy.AnalysisContext |
m_ctxLast The last analysis context. |
protected DistributionManager |
m_manager The DistributionManager. |
protected static java.util.Comparator |
MEMBERID_COMPARATOR Comparator used to provide arbitrary (equals-compatible) comparisons between members. |
Constructor Summary | |
---|---|
SimpleAssignmentStrategy() Default constructor. |
Method Summary | |
---|---|
long |
analyzeDistribution() Analyze the distribution and return the desired time interval before the next distribution analysis. |
protected long |
analyzeDistribution(SimpleAssignmentStrategy.AnalysisContext ctx) Analyze the distribution using the specified analysis context. |
protected static java.util.Comparator |
chainComparators(java.util.Comparator comp1, java.util.Comparator comp2, java.util.Comparator comp3) Helper method to return a Comparator chaining the specified comparators. |
protected int |
checkBackupBalance(SimpleAssignmentStrategy.AnalysisContext ctx) Check that the distribution of backup partitions is balanced. |
protected int |
checkBackupStrong(SimpleAssignmentStrategy.AnalysisContext ctx) Check that the backups are strong. |
protected void |
checkEndangered(SimpleAssignmentStrategy.AnalysisContext ctx) Check the distribution to ensure that backups are created for any "endangered" partitions. |
protected void |
checkLeaving(SimpleAssignmentStrategy.AnalysisContext ctx) Check for any service members that are leaving, and adjust the distribution plan accordingly. |
protected void |
checkPrimaryBalance(SimpleAssignmentStrategy.AnalysisContext ctx) Check the distribution to ensure that primary the partition load is balanced. |
protected static Ownership |
cloneOwnership(Ownership owners, int iStore) Clone the specified ownership for the purpose of enacting a transfer of the specified storage index. |
protected int |
doBalancePrimary(SimpleAssignmentStrategy.AnalysisContext ctx, Member memberFrom, PartitionSet parts, Member[] aMembersTarget) Do balancing transfers for primary distribution. |
protected static int |
filterArray(java.lang.Object[] ao, Filter filter) Apply the specified filter to the elements of the specified array. |
protected static int |
filterSort(java.lang.Object[] ao, java.util.Comparator comparator, Filter filter) Filter the elements in the specified array and sort any matching elements using the specified comparator. |
protected int |
getBackupCount() Return the configured backup count. |
java.lang.String |
getDescription() Return a human-readable description of the state of the partition assignment. |
SimpleAssignmentStrategy.AnalysisContext |
getLastAnalysisContext() Return the last AnalysisContext. |
DistributionManager |
getManager() Return the DistributionManager. |
protected Member |
getMember(int nMemberId) Return the PartitionedService Member with the specified mini-id. |
protected int |
getPartitionCount() Return the partition count. |
void |
init(DistributionManager manager) Initialize the PartitionAssignmentStrategy and bind it to the specified DistributionManager. |
SimpleAssignmentStrategy.AnalysisContext |
instantiateAnalysisContext() Factory method. |
SimpleAssignmentStrategy.LoadCalculator |
instantiateLoadCalculator(boolean fPrimary) Instantiate the load calculator. |
void |
setLastAnalysisContext(SimpleAssignmentStrategy.AnalysisContext ctx) Set the last AnalysisContext. |
java.lang.String |
toString() |
protected void |
validateBackups(SimpleAssignmentStrategy.AnalysisContext ctx) Check if there are enough ownership members to maintain the configured backup count, reducing the number of backups otherwise. |
Field Detail |
---|
protected static final java.util.Comparator MEMBERID_COMPARATOR
protected DistributionManager m_manager
protected SimpleAssignmentStrategy.AnalysisContext m_ctxLast
Constructor Detail |
---|
public SimpleAssignmentStrategy()
Method Detail |
---|
public DistributionManager getManager()
public SimpleAssignmentStrategy.AnalysisContext getLastAnalysisContext()
public void setLastAnalysisContext(SimpleAssignmentStrategy.AnalysisContext ctx)
ctx
- the AnalysisContextpublic void init(DistributionManager manager)
init
in interface PartitionAssignmentStrategy
manager
- the DistributionManager that this strategy is bound topublic long analyzeDistribution()
As a result of failover, partitions may become 'endangered', meaning that the necessary number of backups do not exist. Failure to suggest a distribution recovery plan for those partitions may result in the partition remaining in the endangered state. Additionally, ownership-enabled service members that are in the process of shutting down will wait until all owned partitions are transferred out. Failure to suggest a distribution plan may delay the exit of these leaving members.
The statistics and ownership information exposed by the DistributionManager will not mutate for the duration of this method call.
analyzeDistribution
in interface PartitionAssignmentStrategy
protected long analyzeDistribution(SimpleAssignmentStrategy.AnalysisContext ctx)
ctx
- the analysis contextanalyzeDistribution()
public java.lang.String getDescription()
getDescription
in interface PartitionAssignmentStrategy
public java.lang.String toString()
protected void checkLeaving(SimpleAssignmentStrategy.AnalysisContext ctx)
Partitions owned by leaving members must be transferred to other members before the departing members are able to shutdown.
ctx
- the AnalysisContextprotected void validateBackups(SimpleAssignmentStrategy.AnalysisContext ctx)
ctx
- the AnalysisContextprotected void checkPrimaryBalance(SimpleAssignmentStrategy.AnalysisContext ctx)
ctx
- the analysis contextprotected int doBalancePrimary(SimpleAssignmentStrategy.AnalysisContext ctx, Member memberFrom, PartitionSet parts, Member[] aMembersTarget)
ctx
- the analysis contextmemberFrom
- the member to transfer partitions fromparts
- the set of partitions from which to transferaMembersTarget
- the (unordered) array of membersprotected void checkEndangered(SimpleAssignmentStrategy.AnalysisContext ctx)
A partition is "endangered" if it is incompletely backed up (e.g. some backup copies do not exist).
ctx
- the analysis contextprotected int checkBackupStrong(SimpleAssignmentStrategy.AnalysisContext ctx)
ctx
- the analysis contextprotected int checkBackupBalance(SimpleAssignmentStrategy.AnalysisContext ctx)
ctx
- the analysis contextprotected int getPartitionCount()
protected int getBackupCount()
protected Member getMember(int nMemberId)
nMemberId
- the mini-idprotected static Ownership cloneOwnership(Ownership owners, int iStore)
owners
- the ownership to cloneiStore
- the storage indexprotected static java.util.Comparator chainComparators(java.util.Comparator comp1, java.util.Comparator comp2, java.util.Comparator comp3)
comp1
- the first comparatorcomp2
- the second comparatorcomp3
- the third comparatorprotected static int filterSort(java.lang.Object[] ao, java.util.Comparator comparator, Filter filter)
ao
- the object array to sort and filtercomparator
- the comparator to order the elementsfilter
- the filter to use to filter the resultsprotected static int filterArray(java.lang.Object[] ao, Filter filter)
ao
- the object array to apply the filter tofilter
- the filter to applypublic SimpleAssignmentStrategy.LoadCalculator instantiateLoadCalculator(boolean fPrimary)
fPrimary
- true iff the load calculator will be used for primary partition load; backup otherwisepublic SimpleAssignmentStrategy.AnalysisContext instantiateAnalysisContext()
|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |