Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.net.partition
Class SimpleAssignmentStrategy.AnalysisContext

java.lang.Object
  extended by com.tangosol.net.partition.SimpleAssignmentStrategy.AnalysisContext

Enclosing class:
SimpleAssignmentStrategy

protected class SimpleAssignmentStrategy.AnalysisContext
extends java.lang.Object

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.


Nested Class Summary
 class SimpleAssignmentStrategy.AnalysisContext.LoadComparator
          LoadComparator is a Comparator that can be used to compare two Member objects based on their partition load (as defined by the LoadCalculator).
 class SimpleAssignmentStrategy.AnalysisContext.NotOwnedFilter
          NotOwnedFilter is a Filter implementation used to evaluate Member objects, and selects members who are not represented in the reference ownership object.
 class SimpleAssignmentStrategy.AnalysisContext.SafetyFilter
          SafetyFilter is a Filter implementation used to evaluate Member objects, and selects members that are "strong" with respect to the reference ownership, as defined by the backup-strength.
 class SimpleAssignmentStrategy.AnalysisContext.StrengthComparator
          StrengthComparator is an Comparator that can be used to compare two Member objects based on their "distance" from a given set of members (as represented by an Ownership object).
 class SimpleAssignmentStrategy.AnalysisContext.UnderloadedFilter
          UnderloadedFilter is a Filter implementation that is used to evaluate Member objects, and selects those whose partition load is "underloaded" in comparison to the fair-share load.

 

Field Summary
protected  Ownership[] m_aOwners
          The ownership array for this analysis context.
protected  Member[] m_aOwnershipMembers
          An array of the ownership members to include in the distribution, arranged in arbitrary order.
protected  SimpleAssignmentStrategy.LoadCalculator m_calculatorBackup
          The backup LoadCalculator.
protected  SimpleAssignmentStrategy.LoadCalculator m_calculatorPrimary
          The primary LoadCalculator.
protected  int m_cBackupActual
          The number of backup storages to maintain.
protected  int m_cFairShareBackup
          The fair-share backup partition load.
protected  int m_cFairSharePrimary
          The fair-share primary partition load.
protected  java.util.Map m_mapOwnedPartitions
          The map of member ownership information for this analysis context.
protected  PartitionSet m_partsUpdated
          The set of partitions that have been updated in this analysis context; may be null.
protected  java.util.Set m_setOwnershipMembers
          The set of ownership members to include in the distribution.
protected  SimpleAssignmentStrategy.BackupStrength m_strength
          The backup strength for the resiliency of the resulting distribution.

 

Constructor Summary
SimpleAssignmentStrategy.AnalysisContext()
          Default constructor.

 

Method Summary
protected  int calculateFairShare(boolean fPrimary)
          Return the "fair share" (F) load.
protected  PartitionSet collectEndangered(PartitionSet parts)
          Return a partition set representing the subset of the specified partitions that are "endangered".
protected  PartitionSet collectWeak(PartitionSet parts)
          Return a partition set representing the subset of the specified partitions that are "weak" or "vulnerable" (as defined by the backup strength).
protected  PartitionSet ensureUpdatedPartitions()
          Ensure and return the set of updated partitions.
protected  int getActualBackupCount()
          Return the number of backups to maintain, given the actual set of ownership-enabled and leaving members.
 SimpleAssignmentStrategy.LoadCalculator getBackupLoadCalculator()
          Return the LoadCalculator used to calculate the backup partition load.
protected  SimpleAssignmentStrategy.BackupStrength getBackupStrength()
          Return the BackupStrength for this analysis context.
protected  int getFairShare(boolean fPrimary)
          Return the (primary or backup) fair-share partition load.
protected  int getMemberLoad(Member member, boolean fPrimary)
          Return the (primary or backup) partition load of the specified member.
 int getOwnedIndex(Member member, int iPartition)
          Return the storage index of the specified partition that is owned by the specified Members, or -1 if the member is not a primary or backup owner.
 PartitionSet getOwnedPartitions(Member member, int iStore)
          Return the set of partitions for which the specified member owns (or has been assigned by this analysis to own) the specified storage index.
protected  java.util.Set getOwnershipMembers()
          Return the set of members across which to distribute the partition ownership.
protected  Member[] getOwnershipMembersList()
          Return an array containing the members across which to distribute the partition ownership, arranged in arbitrary order.
protected  int getPartitionLoad(int iPartition, boolean fPrimary)
          Return the load (as defined by the appropriate load calculator) for the specified partition.
 Ownership getPartitionOwnership(int iPartition)
          Return the Ownership information (or the ownership assigned by this analysis) for the specified partition.
 SimpleAssignmentStrategy.LoadCalculator getPrimaryLoadCalculator()
          Return the LoadCalculator used to calculate the primary partition load.
protected  PartitionSet getUpdatedPartitions()
          Return the set of updated partitions; may be null.
protected  void initialize()
          Initialize the AnalysisContext.
protected  SimpleAssignmentStrategy.BackupStrength instantiateBackupStrength(java.util.Set setOwners)
          Create a backup strength to be used for distribution among the specified set of ownership members.
 SimpleAssignmentStrategy.AnalysisContext.LoadComparator instantiateLoadComparator(boolean fPrimary)
          Return a comparator for primary or backup partition load.
 Filter instantiateNotOwnedFilter(Ownership owners)
          Instantiate and return a NotOwnedFilter with the specified ownership.
 Filter instantiateOverloadedFilter(boolean fPrimary)
          Instantiate a filter that matches members with an over-load.
 Filter instantiateSafetyFilter(Ownership owners)
          Instantiate and return a SafetyFilter with the specified ownership.
 SimpleAssignmentStrategy.AnalysisContext.StrengthComparator instantiateStrengthComparator(Ownership owners)
          Instantiate a StrengthComparator for the specified reference ownership.
 Filter instantiateUnderloadedFilter(boolean fPrimary)
          Instantiate a filter that matches members with an under-load.
protected  boolean isMemberLeaving(Member member)
          Return true iff the specified member is in the process of leaving.
protected  boolean isPartitionEndangered(int iPartition)
          Return true iff the specified partition is "endangered".
protected  boolean isPartitionEndangered(Ownership owners)
          Return true iff the specified ownership is "endangered".
protected  boolean isPartitionStrong(int iPartition)
          Return true iff the ownership of the specified partition is "strong", as defined by the current BackupStrength.
protected  boolean isPartitionStrong(Ownership owners)
          Return true iff the specified ownership is "strong", as defined by the current BackupStrength.
protected  boolean isStrong(Member member1, Member member2)
          Return true iff the specified members are mutually "strong", as defined by the backup strength.
protected  boolean isStrong(Member member, Ownership owners)
          Return true iff the specified member is "strong" with respect to the specified ownership, as defined by the backup strength.
protected  boolean isStrongPossible(java.util.Set setOwners, java.util.Map mapSplit)
          Return true iff a "strong" balanced distribution is achievable for the specified set of members, split among a set of categories (e.g. machine, rack, site).
protected  boolean isTransferStrong(int iPartition, int iStore, Member member)
          Return true iff the specified partition transfer would result in a "strong" ownership, as defined by the current BackupStrength.
protected  java.lang.String reportState()
          Debugging method.
protected  boolean suggestDistribution()
          Suggest any distribution that may have been collected by this analysis context to the DistributionManager.
protected  void transitionPartition(int iPartition, int iStore, Member memberFrom, Member memberTo)
          Update the analysis context to reflect the suggested transfer of the specified number of primary partitions between the specified members.

 

Field Detail

m_calculatorPrimary

protected SimpleAssignmentStrategy.LoadCalculator m_calculatorPrimary
The primary LoadCalculator.

m_calculatorBackup

protected SimpleAssignmentStrategy.LoadCalculator m_calculatorBackup
The backup LoadCalculator.

m_mapOwnedPartitions

protected java.util.Map m_mapOwnedPartitions
The map of member ownership information for this analysis context.

m_aOwners

protected Ownership[] m_aOwners
The ownership array for this analysis context.

m_partsUpdated

protected PartitionSet m_partsUpdated
The set of partitions that have been updated in this analysis context; may be null.

m_strength

protected SimpleAssignmentStrategy.BackupStrength m_strength
The backup strength for the resiliency of the resulting distribution.

m_cBackupActual

protected int m_cBackupActual
The number of backup storages to maintain.

Note: this may differ from the configured backup count if there is an inadequate number of ownership members to sustain the configured backup count.


m_cFairSharePrimary

protected int m_cFairSharePrimary
The fair-share primary partition load.

m_cFairShareBackup

protected int m_cFairShareBackup
The fair-share backup partition load.

m_setOwnershipMembers

protected java.util.Set m_setOwnershipMembers
The set of ownership members to include in the distribution.

Note: this set does not include members that are leaving


m_aOwnershipMembers

protected Member[] m_aOwnershipMembers
An array of the ownership members to include in the distribution, arranged in arbitrary order. This array could be used for algorithms peforming in-place sorting of the members.

Note: this list does not include members that are leaving

Constructor Detail

SimpleAssignmentStrategy.AnalysisContext

public SimpleAssignmentStrategy.AnalysisContext()
Default constructor.

Method Detail

getUpdatedPartitions

protected PartitionSet getUpdatedPartitions()
Return the set of updated partitions; may be null.
Returns:
the set of updated partitions, or null

getBackupStrength

protected SimpleAssignmentStrategy.BackupStrength getBackupStrength()
Return the BackupStrength for this analysis context. The backup strength determines the degree of resiliency that the resulting distribution will ensure (e.g. machine-safe, rack-safe, site-safe).
Returns:
the backup strength

getOwnershipMembers

protected java.util.Set getOwnershipMembers()
Return the set of members across which to distribute the partition ownership.

Note: The set of ownership members does not include any members that may be in the process of leaving

Returns:
the set of (non-leaving) ownership enabled members

getOwnershipMembersList

protected Member[] getOwnershipMembersList()
Return an array containing the members across which to distribute the partition ownership, arranged in arbitrary order.

Note: The array does not include any members that may be in the process of leaving

Returns:
an array contianing the (non-leaving) ownership enabled members

getPrimaryLoadCalculator

public SimpleAssignmentStrategy.LoadCalculator getPrimaryLoadCalculator()
Return the LoadCalculator used to calculate the primary partition load.
Returns:
the primary partition load calculator

getBackupLoadCalculator

public SimpleAssignmentStrategy.LoadCalculator getBackupLoadCalculator()
Return the LoadCalculator used to calculate the backup partition load.
Returns:
the backup partition load calculator

getActualBackupCount

protected int getActualBackupCount()
Return the number of backups to maintain, given the actual set of ownership-enabled and leaving members.
Returns:
the number of backups to maintain

initialize

protected void initialize()
Initialize the AnalysisContext.

getFairShare

protected int getFairShare(boolean fPrimary)
Return the (primary or backup) fair-share partition load.
Parameters:
fPrimary - true iff the primary fair-share should be returned
Returns:
the fair-share partition load

calculateFairShare

protected int calculateFairShare(boolean fPrimary)
Return the "fair share" (F) load. It is a ceiling for the load on a for fully balance distribution. The fairness goal is to achieve such a state that the load for all members is between F-L and F, where L is typically the minimum of partition load values.
Parameters:
fPrimary - true for the primary fair-share, or false for backup
Returns:
the fair share

isMemberLeaving

protected boolean isMemberLeaving(Member member)
Return true iff the specified member is in the process of leaving.
Parameters:
member - the member
Returns:
true iff the specified member is in the process of leaving

instantiateBackupStrength

protected SimpleAssignmentStrategy.BackupStrength instantiateBackupStrength(java.util.Set setOwners)
Create a backup strength to be used for distribution among the specified set of ownership members.
Parameters:
setOwners - the ownership members
Returns:
the backup strength

isStrongPossible

protected boolean isStrongPossible(java.util.Set setOwners,
                                   java.util.Map mapSplit)
Return true iff a "strong" balanced distribution is achievable for the specified set of members, split among a set of categories (e.g. machine, rack, site).
Parameters:
setOwners - the set of ownership members
mapSplit - the map of members, associated by their category
Returns:
true iff a "strong" balanced distribution is achievable

isPartitionStrong

protected boolean isPartitionStrong(int iPartition)
Return true iff the ownership of the specified partition is "strong", as defined by the current BackupStrength.
Parameters:
iPartition - the partition
Returns:
true iff the specified partition is strong

isPartitionStrong

protected boolean isPartitionStrong(Ownership owners)
Return true iff the specified ownership is "strong", as defined by the current BackupStrength.
Parameters:
owners - the ownership
Returns:
true iff the specified ownership is strong

isTransferStrong

protected boolean isTransferStrong(int iPartition,
                                   int iStore,
                                   Member member)
Return true iff the specified partition transfer would result in a "strong" ownership, as defined by the current BackupStrength.
Parameters:
iPartition - the partition to transfer
iStore - the storage index to transfer
member - the member receiving the transfer
Returns:
true iff the specified partition transfer is strong

isStrong

protected boolean isStrong(Member member1,
                           Member member2)
Return true iff the specified members are mutually "strong", as defined by the backup strength.
Parameters:
member1 - the first member to compare
member2 - the second member to compare
Returns:
true iff the specified members are mutually strong

isStrong

protected boolean isStrong(Member member,
                           Ownership owners)
Return true iff the specified member is "strong" with respect to the specified ownership, as defined by the backup strength.
Parameters:
member - the member
owners - the ownership
Returns:
true iff the member is "strong" with respect to the ownership

collectWeak

protected PartitionSet collectWeak(PartitionSet parts)
Return a partition set representing the subset of the specified partitions that are "weak" or "vulnerable" (as defined by the backup strength).
Parameters:
parts - the partition set to collect
Returns:
a partition set containing the weak partitions

isPartitionEndangered

protected boolean isPartitionEndangered(int iPartition)
Return true iff the specified partition is "endangered". A partition is "endangered" if it is incompletely backed up (e.g. some backup copies do not exist).
Parameters:
iPartition - the partition to test the endangered status
Returns:
true iff the specified partition is endangered

isPartitionEndangered

protected boolean isPartitionEndangered(Ownership owners)
Return true iff the specified ownership is "endangered". A partition is "endangered" if it is incompletely backed up (e.g. some backup copies do not exist).
Parameters:
owners - the ownership to test for endangered status
Returns:
true iff the specified partition is endangered

collectEndangered

protected PartitionSet collectEndangered(PartitionSet parts)
Return a partition set representing the subset of the specified partitions that are "endangered".
Parameters:
parts - the partition set to collect
Returns:
a partition set containing the endangered partitions

ensureUpdatedPartitions

protected PartitionSet ensureUpdatedPartitions()
Ensure and return the set of updated partitions.
Returns:
the set of updated partitions

getOwnedIndex

public int getOwnedIndex(Member member,
                         int iPartition)
Return the storage index of the specified partition that is owned by the specified Members, or -1 if the member is not a primary or backup owner.
Parameters:
member - the member
iPartition - the partition
Returns:
the owned storage index (0 for primary) of the partition, or -1

getOwnedPartitions

public PartitionSet getOwnedPartitions(Member member,
                                       int iStore)
Return the set of partitions for which the specified member owns (or has been assigned by this analysis to own) the specified storage index.
Parameters:
member - the member
iStore - the storage index
Returns:
the set of partitions owned by the member at the specified index

getPartitionOwnership

public Ownership getPartitionOwnership(int iPartition)
Return the Ownership information (or the ownership assigned by this analysis) for the specified partition.
Parameters:
iPartition - the partition to return the ownership for
Returns:
the Ownership information

getPartitionLoad

protected int getPartitionLoad(int iPartition,
                               boolean fPrimary)
Return the load (as defined by the appropriate load calculator) for the specified partition.
Parameters:
iPartition - the partition to determine the load of
fPrimary - true iff the primary load should be returned, or false for backup
Returns:
the load for the specified partition

getMemberLoad

protected int getMemberLoad(Member member,
                            boolean fPrimary)
Return the (primary or backup) partition load of the specified member.
Parameters:
member - the member to calculate the partition load for
fPrimary - true for primary partition load, else backup load
Returns:
the partition load for the specified member

transitionPartition

protected void transitionPartition(int iPartition,
                                   int iStore,
                                   Member memberFrom,
                                   Member memberTo)
Update the analysis context to reflect the suggested transfer of the specified number of primary partitions between the specified members.
Parameters:
iPartition - the partition id to transfer
iStore - the storage index to transfer
memberFrom - the member to transfer partitions from, or null if the partition storage-index was endangered
memberTo - the member to transfer partitions to, or null if the partition storage index should be endangered

suggestDistribution

protected boolean suggestDistribution()
Suggest any distribution that may have been collected by this analysis context to the DistributionManager.
Returns:
true iff a distribution was suggested

reportState

protected java.lang.String reportState()
Debugging method.
Returns:
a human-readable description of the AnalysisContext state

instantiateNotOwnedFilter

public Filter instantiateNotOwnedFilter(Ownership owners)
Instantiate and return a NotOwnedFilter with the specified ownership.
Parameters:
owners - the ownership
Returns:
a NotOwnedFilter

instantiateSafetyFilter

public Filter instantiateSafetyFilter(Ownership owners)
Instantiate and return a SafetyFilter with the specified ownership.
Parameters:
owners - the ownership
Returns:
a SafetyFilter

instantiateOverloadedFilter

public Filter instantiateOverloadedFilter(boolean fPrimary)
Instantiate a filter that matches members with an over-load.
Parameters:
fPrimary - true for primary partition load
Returns:
a filter that matches members with an over-load

instantiateUnderloadedFilter

public Filter instantiateUnderloadedFilter(boolean fPrimary)
Instantiate a filter that matches members with an under-load.
Parameters:
fPrimary - true for primary partition load
Returns:
a filter that matches members with an under-load

instantiateLoadComparator

public SimpleAssignmentStrategy.AnalysisContext.LoadComparator instantiateLoadComparator(boolean fPrimary)
Return a comparator for primary or backup partition load.
Parameters:
fPrimary - true for primary, or false for backup
Returns:
a comparator for primary or backup partition load

instantiateStrengthComparator

public SimpleAssignmentStrategy.AnalysisContext.StrengthComparator instantiateStrengthComparator(Ownership owners)
Instantiate a StrengthComparator for the specified reference ownership.
Parameters:
owners - the ownership, from which to determine member strength
Returns:
a StrengthComparator

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.