Class SimpleAssignmentStrategy
- java.lang.Object
-
- com.tangosol.net.partition.SimpleAssignmentStrategy
-
- All Implemented Interfaces:
PartitionAssignmentStrategy
,SimpleStrategyMBean
- Direct Known Subclasses:
MirroringAssignmentStrategy
public class SimpleAssignmentStrategy extends Object implements PartitionAssignmentStrategy, SimpleStrategyMBean
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.
- Since:
- Coherence 3.7
- Author:
- rhl 2010.11.08
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description 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.protected class
SimpleAssignmentStrategy.JMXPartitionStats
A class that calculate MBean attribute values from last sampled PartitionStatsstatic 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).-
Nested classes/interfaces inherited from interface com.tangosol.net.partition.SimpleStrategyMBean
SimpleStrategyMBean.HAStatus
-
-
Field Summary
Fields Modifier and Type Field Description protected long
m_cPlanCompletionDelay
The amount of time in ms to delay the analysis after a distribution suggestion has been made and before it is carried out.protected SimpleAssignmentStrategy.AnalysisContext
m_ctxLast
The last analysis context.protected boolean
m_fRefresh
True if JMXPartitionStats should be updated.protected DistributionManager
m_manager
The DistributionManager.protected Map<Ownership,PartitionSet>
m_mapSuggestLast
The Map containing the last distribution suggested by this strategy.protected Set
m_setOwnersLast
The Set of ownership-enabled members at the time of the last analysis.protected SimpleAssignmentStrategy.JMXPartitionStats
m_statsPartition
The JMXPartitionStats that hold the last updated jmx attributes.protected static Comparator
MEMBERID_COMPARATOR
Comparator used to provide arbitrary (equals-compatible) comparisons between members.protected static String
MSG_NO_PENDING
The message returned by SimpleStrategyMBean when all suggested distributions have completed and none are in-progress or scheduled.protected static String
MSG_NO_RESULT
The message returned by SimpleStrategyMBean when the distribution coordinator has not done its first analysis yet.-
Fields inherited from interface com.tangosol.net.partition.SimpleStrategyMBean
NOTIFY_LOST
-
-
Constructor Summary
Constructors Constructor Description SimpleAssignmentStrategy()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected long
analyze(SimpleAssignmentStrategy.AnalysisContext ctx)
Analyze the distribution using the specified analysis context.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 and suggest the resulting distribution to distribution manager.void
analyzeOrphans(Map<Member,PartitionSet> mapConstraints)
Analyze and suggest the assignment of orphaned partitions (partitions without an active primary or backup owner) subject to the specified constraints.protected static Comparator
chainComparators(Comparator comp1, Comparator comp2)
Helper method to return a Comparator chaining the specified comparators.protected static Comparator
chainComparators(Comparator comp1, Comparator comp2, 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
checkBackupOverloaded(SimpleAssignmentStrategy.AnalysisContext ctx)
Check if 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 boolean
checkSimpleDistribution(SimpleAssignmentStrategy.AnalysisContext ctx)
Analyze the distribution for the special two-server case using the specified analysis context.protected Map<Member,PartitionSet[]>
collectScheduledDistributions()
Collect the scheduled partition distributions, grouped by the primary owner and storage index.protected int
doBalancePrimary(SimpleAssignmentStrategy.AnalysisContext ctx, Member memberFrom, PartitionSet parts, Member[] aMembersTarget)
Do balancing transfers for primary distribution.protected void
emitLossNotification(PartitionSet partsLost)
Emit a partition loss notification for given partitions.protected static int
filterArray(Object[] ao, int cElems, Filter filter)
Apply the specified filter to the specified array elements.protected static int
filterArray(Object[] ao, Filter filter)
Apply the specified filter to the elements of the specified array.protected static int
filterSort(Object[] ao, int cElems, Comparator comparator, Filter filter)
Filter the specified array elements and sort any matching elements using the specified comparator.protected static int
filterSort(Object[] ao, Comparator comparator, Filter filter)
Filter the elements in the specified array and sort any matching elements using the specified comparator.long
getAveragePartitionSizeKB()
Get the average partition storage size.long
getAverageStorageSizeKB()
Get the average node storage size.int
getBackupCount()
Get the configured number of backups.int
getCoordinatorId()
Get the node id of the ownership distribution coordinator.String
getDescription()
Return a human-readable description of the state of the partition assignment.int
getFairShareBackup()
Get the number of backup partitions per storage-enabled service member that this strategy will currently attempt to maintain.int
getFairSharePrimary()
Get the number of primary partitions per storage-enabled service member that this strategy will currently attempt to maintain.String
getHAStatus()
The High Availability status for the service.int
getHAStatusCode()
The High Availability status for the service as an integer.String
getHATarget()
The High Availability status that this strategy attempts to achieve.SimpleAssignmentStrategy.AnalysisContext
getLastAnalysisContext()
Return the last AnalysisContext.Date
getLastAnalysisTime()
Get the last time a partition distribution analysis was performed.Set
getLastOwnershipMembers()
Return the set of ownership-enabled members present when the analysis was last considered.DistributionManager
getManager()
Return the DistributionManager.int
getMaxLoadNodeId()
Get the node id with the maximum storage size.long
getMaxPartitionSizeKB()
Get the maximum partition storage size.long
getMaxStorageSizeKB()
Get maximum node storage size.protected Member
getMember(int nMemberId)
Return the PartitionedService Member with the specified mini-id.protected long
getMemberJoinDelay()
Return the amount of time in ms to delay the analysis after a member has joined.int
getPartitionCount()
Get the configured number of partitions for the service.int
getRemainingDistributionCount()
Get the number of distributions (partition transfers) that remain to be completed before the service achieves the goals set by this strategy.int
getServiceMachineCount()
Get the number of machines that host storage-enabled nodes running this service.int
getServiceNodeCount()
Get the number of storage-enabled nodes running this service.int
getServiceRackCount()
Get the number of racks that host storage-enabled nodes running this service.int
getServiceSiteCount()
Get the number of sites that host storage-enabled nodes running this service.String
getStrategyName()
Get name of the PartitionAssignmentStrategy in use.protected long
getSuggestionCompletionDelay()
Return the amount of time in ms to delay the analysis after a distribution suggestion has been made and before it is carried out.protected long
getSuggestionDelay()
Return the amount of time in ms to delay the analysis.protected PartitionSet
getUnownedPartitions(PartitionSet parts, int nMember)
Calculate a subset of the PartitionSet consisting of partitions that are not owned (primary or backup) by the specified member.protected int
getVariance(SimpleAssignmentStrategy.AnalysisContext ctx, boolean fPrimary)
Return the maximum load variance in the partition assignments represented by the analysis context.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.protected String
makeMBeanName(PartitionedService service)
Create a name for the MBean representing this strategy.protected void
primeDistribution(SimpleAssignmentStrategy.AnalysisContext ctx)
Optimize the distribution with minimum backup fan-out by distributing the partitions among first two strong members.protected void
registerMBean()
Register an MBean representing this SimpleAssignmentStrategy.String
reportScheduledDistributions(boolean fVerbose)
Report partitions that storage-enabled members are waiting to receive or still need to send in order to achieve distribution goal set by the strategy.protected void
setLastAnalysisContext(SimpleAssignmentStrategy.AnalysisContext ctx)
Set the last AnalysisContext.protected void
setLastOwnershipMembers(Set setOwners)
Record the set of ownership-enabled members present when the analysis was last considered.protected SortedMap<Integer,PartitionSet>
splitByOwner(PartitionSet parts)
Split the partition set scheduled for distribution by the current primary owner (all transfers originate from the primary owner).String
toString()
protected void
unregisterMBean()
Unregister the MBean representing this SimpleAssignmentStrategy.protected SimpleAssignmentStrategy.JMXPartitionStats
updateCompositeStats()
Return a JMXPartitionStats that contains calculated MBean Attributes, updated periodically.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
-
MEMBERID_COMPARATOR
protected static final Comparator MEMBERID_COMPARATOR
Comparator used to provide arbitrary (equals-compatible) comparisons between members.
-
MSG_NO_RESULT
protected static final String MSG_NO_RESULT
The message returned by SimpleStrategyMBean when the distribution coordinator has not done its first analysis yet.- See Also:
- Constant Field Values
-
MSG_NO_PENDING
protected static final String MSG_NO_PENDING
The message returned by SimpleStrategyMBean when all suggested distributions have completed and none are in-progress or scheduled.- See Also:
- Constant Field Values
-
m_manager
protected DistributionManager m_manager
The DistributionManager.
-
m_ctxLast
protected SimpleAssignmentStrategy.AnalysisContext m_ctxLast
The last analysis context.
-
m_setOwnersLast
protected Set m_setOwnersLast
The Set of ownership-enabled members at the time of the last analysis.
-
m_mapSuggestLast
protected Map<Ownership,PartitionSet> m_mapSuggestLast
The Map containing the last distribution suggested by this strategy.
-
m_statsPartition
protected SimpleAssignmentStrategy.JMXPartitionStats m_statsPartition
The JMXPartitionStats that hold the last updated jmx attributes.
-
m_fRefresh
protected boolean m_fRefresh
True if JMXPartitionStats should be updated.
-
m_cPlanCompletionDelay
protected long m_cPlanCompletionDelay
The amount of time in ms to delay the analysis after a distribution suggestion has been made and before it is carried out.
-
-
Method Detail
-
getManager
public DistributionManager getManager()
Return the DistributionManager.- Returns:
- the DistributionManager
-
getLastAnalysisContext
public SimpleAssignmentStrategy.AnalysisContext getLastAnalysisContext()
Return the last AnalysisContext.- Returns:
- the last AnalysisContext
-
setLastAnalysisContext
protected void setLastAnalysisContext(SimpleAssignmentStrategy.AnalysisContext ctx)
Set the last AnalysisContext.- Parameters:
ctx
- the AnalysisContext
-
getLastOwnershipMembers
public Set getLastOwnershipMembers()
Return the set of ownership-enabled members present when the analysis was last considered.- Returns:
- the set of ownership-enabled members when analysis was last considered
-
setLastOwnershipMembers
protected void setLastOwnershipMembers(Set setOwners)
Record the set of ownership-enabled members present when the analysis was last considered.- Parameters:
setOwners
- the set of ownership-enabled members
-
getMemberJoinDelay
protected long getMemberJoinDelay()
Return the amount of time in ms to delay the analysis after a member has joined. This delay could be used to "dampen" the reactivity of the strategy to membership changes.- Returns:
- the amount of time in ms to delay the analysis after a member joins
-
getSuggestionDelay
protected long getSuggestionDelay()
Return the amount of time in ms to delay the analysis.- Returns:
- the amount of time in ms to delay the analysis
-
getSuggestionCompletionDelay
protected long getSuggestionCompletionDelay()
Return the amount of time in ms to delay the analysis after a distribution suggestion has been made and before it is carried out. This delay could be used to "dampen" the volatility of the strategy by allowing sufficient time for in-flight transfers to complete prior to considering further recommendations.- Returns:
- the amount of time in ms to delay the analysis after a suggestion is made
-
init
public void init(DistributionManager manager)
Initialize the PartitionAssignmentStrategy and bind it to the specified DistributionManager. This method is called only on the distribution coordinator, prior its first distributionanalysis
.- Specified by:
init
in interfacePartitionAssignmentStrategy
- Parameters:
manager
- the DistributionManager that this strategy is bound to
-
analyzeOrphans
public void analyzeOrphans(Map<Member,PartitionSet> mapConstraints)
Analyze and suggest the assignment of orphaned partitions (partitions without an active primary or backup owner) subject to the specified constraints. For each partition, the supplied constraints specify the set of members which are eligible to be assigned the ownership.The strategy must provide suggestions for all orphaned partitions which are consistent with the supplied constraints. Failure to provide a complete set of valid suggestions may result in the loss of partition data.
- Specified by:
analyzeOrphans
in interfacePartitionAssignmentStrategy
- Parameters:
mapConstraints
- the map of assignment constraints associating members with the set of partitions that they could be assigned ownership of
-
analyzeDistribution
public long analyzeDistribution()
Analyze the distribution and return the desired time interval before the next distribution analysis. This method may or may not make distribution suggestions through the distribution manager. The strategy can influence (but not guarantee) the frequency with which it is analyzed by returning the desired interval before the next call, or -1 if the strategy has no preference and will rely on the PartitionedService to decide.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.
- Specified by:
analyzeDistribution
in interfacePartitionAssignmentStrategy
- Returns:
- the time interval before the next desired analysis, or -1
-
analyzeDistribution
protected long analyzeDistribution(SimpleAssignmentStrategy.AnalysisContext ctx)
Analyze the distribution and suggest the resulting distribution to distribution manager.- Parameters:
ctx
- the analysis context- Returns:
- the time interval before the next desired analysis, or -1
-
primeDistribution
protected void primeDistribution(SimpleAssignmentStrategy.AnalysisContext ctx)
Optimize the distribution with minimum backup fan-out by distributing the partitions among first two strong members.- Parameters:
ctx
- the analysis context
-
analyze
protected long analyze(SimpleAssignmentStrategy.AnalysisContext ctx)
Analyze the distribution using the specified analysis context.- Parameters:
ctx
- the analysis context- Returns:
- the time interval before the next desired analysis, or -1
-
checkSimpleDistribution
protected boolean checkSimpleDistribution(SimpleAssignmentStrategy.AnalysisContext ctx)
Analyze the distribution for the special two-server case using the specified analysis context.- Parameters:
ctx
- the analysis context- Returns:
- true if the simple distribution is in effect
-
getDescription
public String getDescription()
Return a human-readable description of the state of the partition assignment.- Specified by:
getDescription
in interfacePartitionAssignmentStrategy
- Returns:
- a human-readable description
-
checkLeaving
protected void checkLeaving(SimpleAssignmentStrategy.AnalysisContext ctx)
Check for any service members that are leaving, and adjust the distribution plan accordingly.Partitions owned by leaving members must be transferred to other members before the departing members are able to shutdown.
- Parameters:
ctx
- the AnalysisContext
-
validateBackups
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.- Parameters:
ctx
- the AnalysisContext
-
checkPrimaryBalance
protected void checkPrimaryBalance(SimpleAssignmentStrategy.AnalysisContext ctx)
Check the distribution to ensure that primary the partition load is balanced.- Parameters:
ctx
- the analysis context
-
doBalancePrimary
protected int doBalancePrimary(SimpleAssignmentStrategy.AnalysisContext ctx, Member memberFrom, PartitionSet parts, Member[] aMembersTarget)
Do balancing transfers for primary distribution.- Parameters:
ctx
- the analysis contextmemberFrom
- the member to transfer partitions fromparts
- the set of partitions from which to transferaMembersTarget
- the (unordered) array of members- Returns:
- the number of changes (transfers) that were made
-
checkEndangered
protected void checkEndangered(SimpleAssignmentStrategy.AnalysisContext ctx)
Check the distribution to ensure that backups are created for any "endangered" partitions.A partition is "endangered" if it is incompletely backed up (e.g. some backup copies do not exist).
- Parameters:
ctx
- the analysis context
-
checkBackupStrong
protected int checkBackupStrong(SimpleAssignmentStrategy.AnalysisContext ctx)
Check that the backups are strong.- Parameters:
ctx
- the analysis context- Returns:
- the number of changes (transfers) that were made
-
checkBackupBalance
protected int checkBackupBalance(SimpleAssignmentStrategy.AnalysisContext ctx)
Check that the distribution of backup partitions is balanced.- Parameters:
ctx
- the analysis context- Returns:
- the number of changes (transfers) that were made
-
checkBackupOverloaded
protected int checkBackupOverloaded(SimpleAssignmentStrategy.AnalysisContext ctx)
Check if the distribution of backup partitions is balanced. If not, disturb the distribution by moving a partition from the overloaded member to another member that retains partition strength.- Parameters:
ctx
- the analysis context- Returns:
- the number of unbalanced partitions that need to be transferred
-
getMember
protected Member getMember(int nMemberId)
Return the PartitionedService Member with the specified mini-id.- Parameters:
nMemberId
- the mini-id- Returns:
- the PartitionedService Member with the specified mini-id, or null
-
getVariance
protected int getVariance(SimpleAssignmentStrategy.AnalysisContext ctx, boolean fPrimary)
Return the maximum load variance in the partition assignments represented by the analysis context. The maximum variance is the difference in load between the 'lightest' and 'heaviest' members.- Parameters:
ctx
- the analysis contextfPrimary
- true iff the "primary" load variance should be computed- Returns:
- the maximum variance
-
chainComparators
protected static Comparator chainComparators(Comparator comp1, Comparator comp2)
Helper method to return a Comparator chaining the specified comparators.- Parameters:
comp1
- the first comparatorcomp2
- the second comparator- Returns:
- a chained comparator
-
chainComparators
protected static Comparator chainComparators(Comparator comp1, Comparator comp2, Comparator comp3)
Helper method to return a Comparator chaining the specified comparators.- Parameters:
comp1
- the first comparatorcomp2
- the second comparatorcomp3
- the third comparator- Returns:
- a chained comparator
-
filterSort
protected static int filterSort(Object[] ao, Comparator comparator, Filter filter)
Filter the elements in the specified array and sort any matching elements using the specified comparator. All matching results will be compacted to the front of the array. The order of results not matching the filter is undefined.- Parameters:
ao
- the object array to sort and filtercomparator
- the comparator to order the elementsfilter
- the filter to use to filter the results- Returns:
- the number of elements matching the specified filter
-
filterSort
protected static int filterSort(Object[] ao, int cElems, Comparator comparator, Filter filter)
Filter the specified array elements and sort any matching elements using the specified comparator. All matching results will be compacted to the front of the array. The order of results not matching the filter is undefined.- Parameters:
ao
- the object array to sort and filtercElems
- the number of elements to filter and sortcomparator
- the comparator to order the elementsfilter
- the filter to use to filter the results- Returns:
- the number of elements matching the specified filter
-
filterArray
protected static int filterArray(Object[] ao, Filter filter)
Apply the specified filter to the elements of the specified array. All matching results will be compacted to the front of the array in a "stable" manner. The order of results not matching the filter may not be preserved.- Parameters:
ao
- the object array to apply the filter tofilter
- the filter to apply- Returns:
- the number of elements matching the specified filter
-
filterArray
protected static int filterArray(Object[] ao, int cElems, Filter filter)
Apply the specified filter to the specified array elements. All matching results will be compacted to the front of the array in a "stable" manner. The order of results not matching the filter may not be preserved.- Parameters:
ao
- the object array to apply the filter tocElems
- the number of elements to filterfilter
- the filter to apply- Returns:
- the number of elements matching the specified filter
-
getPartitionCount
public int getPartitionCount()
Get the configured number of partitions for the service.- Specified by:
getPartitionCount
in interfaceSimpleStrategyMBean
- Returns:
- the partition count
-
getBackupCount
public int getBackupCount()
Get the configured number of backups.- Specified by:
getBackupCount
in interfaceSimpleStrategyMBean
- Returns:
- the backup count
-
getServiceNodeCount
public int getServiceNodeCount()
Get the number of storage-enabled nodes running this service.- Specified by:
getServiceNodeCount
in interfaceSimpleStrategyMBean
- Returns:
- the number of storage-enabled nodes
-
getServiceMachineCount
public int getServiceMachineCount()
Get the number of machines that host storage-enabled nodes running this service.- Specified by:
getServiceMachineCount
in interfaceSimpleStrategyMBean
- Returns:
- the number of machines with storage-enabled nodes
-
getServiceRackCount
public int getServiceRackCount()
Get the number of racks that host storage-enabled nodes running this service.- Specified by:
getServiceRackCount
in interfaceSimpleStrategyMBean
- Returns:
- the number of racks with storage-enabled nodes
-
getServiceSiteCount
public int getServiceSiteCount()
Get the number of sites that host storage-enabled nodes running this service.- Specified by:
getServiceSiteCount
in interfaceSimpleStrategyMBean
- Returns:
- the number of sites with storage-enabled nodes
-
getHAStatus
public String getHAStatus()
The High Availability status for the service.- Specified by:
getHAStatus
in interfaceSimpleStrategyMBean
- Returns:
- one of the following values: ENDANGERED, NODE-SAFE, MACHINE-SAFE, RACK-SAFE, SITE-SAFE
-
getHAStatusCode
public int getHAStatusCode()
The High Availability status for the service as an integer.Below is an example of how to map a HA Status integer to a string:
HAStatus.values()[getHAStatusCode()].name()
- Specified by:
getHAStatusCode
in interfaceSimpleStrategyMBean
- Returns:
- integer representation of
SimpleStrategyMBean.HAStatus
-
getHATarget
public String getHATarget()
The High Availability status that this strategy attempts to achieve. Values are the same as for HAStatus attribute.- Specified by:
getHATarget
in interfaceSimpleStrategyMBean
- Returns:
- the target High Availability status
-
getFairShareBackup
public int getFairShareBackup()
Get the number of backup partitions per storage-enabled service member that this strategy will currently attempt to maintain.- Specified by:
getFairShareBackup
in interfaceSimpleStrategyMBean
- Returns:
- the number of backup partitions per storage-enabled member
-
getFairSharePrimary
public int getFairSharePrimary()
Get the number of primary partitions per storage-enabled service member that this strategy will currently attempt to maintain.- Specified by:
getFairSharePrimary
in interfaceSimpleStrategyMBean
- Returns:
- the number of primary partitions per storage-enabled member
-
getStrategyName
public String getStrategyName()
Get name of the PartitionAssignmentStrategy in use.- Specified by:
getStrategyName
in interfaceSimpleStrategyMBean
- Returns:
- partitioning strategy name
-
getLastAnalysisTime
public Date getLastAnalysisTime()
Get the last time a partition distribution analysis was performed.- Specified by:
getLastAnalysisTime
in interfaceSimpleStrategyMBean
- Returns:
- the time of the last analysis
-
getCoordinatorId
public int getCoordinatorId()
Get the node id of the ownership distribution coordinator.- Specified by:
getCoordinatorId
in interfaceSimpleStrategyMBean
- Returns:
- current distribution coordinator node id
-
getRemainingDistributionCount
public int getRemainingDistributionCount()
Get the number of distributions (partition transfers) that remain to be completed before the service achieves the goals set by this strategy.- Specified by:
getRemainingDistributionCount
in interfaceSimpleStrategyMBean
- Returns:
- the number of remaining partition transfers
-
getAveragePartitionSizeKB
public long getAveragePartitionSizeKB()
Get the average partition storage size.- Specified by:
getAveragePartitionSizeKB
in interfaceSimpleStrategyMBean
- Returns:
- the average partition storage size in kilobytes
-
getMaxPartitionSizeKB
public long getMaxPartitionSizeKB()
Get the maximum partition storage size.- Specified by:
getMaxPartitionSizeKB
in interfaceSimpleStrategyMBean
- Returns:
- the maximum partition storage size in kilobytes
-
getMaxStorageSizeKB
public long getMaxStorageSizeKB()
Get maximum node storage size.- Specified by:
getMaxStorageSizeKB
in interfaceSimpleStrategyMBean
- Returns:
- the maximum node storage size in kilobytes
-
getAverageStorageSizeKB
public long getAverageStorageSizeKB()
Get the average node storage size.- Specified by:
getAverageStorageSizeKB
in interfaceSimpleStrategyMBean
- Returns:
- the average node storage size in kilobytes
-
getMaxLoadNodeId
public int getMaxLoadNodeId()
Get the node id with the maximum storage size.- Specified by:
getMaxLoadNodeId
in interfaceSimpleStrategyMBean
- Returns:
- the node id with the maximum storage size
-
updateCompositeStats
protected SimpleAssignmentStrategy.JMXPartitionStats updateCompositeStats()
Return a JMXPartitionStats that contains calculated MBean Attributes, updated periodically.- Returns:
- JMXPartitionStats with calculated MBean Attributes
-
reportScheduledDistributions
public String reportScheduledDistributions(boolean fVerbose)
Report partitions that storage-enabled members are waiting to receive or still need to send in order to achieve distribution goal set by the strategy.- Specified by:
reportScheduledDistributions
in interfaceSimpleStrategyMBean
- Parameters:
fVerbose
- if true, the report includes partition numbers for each scheduled transfer- Returns:
- a description of scheduled distributions for the service
-
registerMBean
protected void registerMBean()
Register an MBean representing this SimpleAssignmentStrategy.This implementation creates and registers a
SimpleStrategyMBean
.
-
makeMBeanName
protected String makeMBeanName(PartitionedService service)
Create a name for the MBean representing this strategy.The name must be globally unique, but not contain the nodeId property. This allows us to re-bind the same JMX name to the MBean on a different node when the distribution coordinator migrates.
- Parameters:
service
- partitioned service that uses this strategy- Returns:
- the name for the MBean
-
unregisterMBean
protected void unregisterMBean()
Unregister the MBean representing this SimpleAssignmentStrategy.
-
emitLossNotification
protected void emitLossNotification(PartitionSet partsLost)
Emit a partition loss notification for given partitions.- Parameters:
partsLost
- the partition id that has been lost
-
collectScheduledDistributions
protected Map<Member,PartitionSet[]> collectScheduledDistributions()
Collect the scheduled partition distributions, grouped by the primary owner and storage index. A partition distribution (either primary or backup) is considered to be scheduled if the distribution has been suggested but the ownership change has not yet occurred.- Returns:
- a Map of partition sets still awaiting distribution keyed by primary owner
-
getUnownedPartitions
protected PartitionSet getUnownedPartitions(PartitionSet parts, int nMember)
Calculate a subset of the PartitionSet consisting of partitions that are not owned (primary or backup) by the specified member.- Parameters:
parts
- set of partitions to check the ownership ofnMember
- the member-id- Returns:
- the subset of partitions that are not owned by the specified member
-
splitByOwner
protected SortedMap<Integer,PartitionSet> splitByOwner(PartitionSet parts)
Split the partition set scheduled for distribution by the current primary owner (all transfers originate from the primary owner).- Parameters:
parts
- a set of partitions not yet transferred- Returns:
- the partitions scheduled for distribution, associated with their primary owners
-
instantiateLoadCalculator
public SimpleAssignmentStrategy.LoadCalculator instantiateLoadCalculator(boolean fPrimary)
Instantiate the load calculator.- Parameters:
fPrimary
- true iff the load calculator will be used for primary partition load; backup otherwise- Returns:
- a load calculator
-
instantiateAnalysisContext
public SimpleAssignmentStrategy.AnalysisContext instantiateAnalysisContext()
Factory method.- Returns:
- a new AnalysisContext
-
-