Package com.tangosol.net.partition
Class MirroringAssignmentStrategy
- java.lang.Object
-
- com.tangosol.net.partition.SimpleAssignmentStrategy
-
- com.tangosol.net.partition.MirroringAssignmentStrategy
-
- All Implemented Interfaces:
PartitionAssignmentStrategy
,SimpleStrategyMBean
public class MirroringAssignmentStrategy extends SimpleAssignmentStrategy
A PartitionAssignmentStrategy used by a service to attempt to co-locate the primary ownership of partitions on the same members as another service. This strategy does not guarantee that partitions will be co-located, but will make a best-effort attempt.- Since:
- Coherence 3.7.1
- Author:
- rhl 2011.06.29
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.net.partition.SimpleAssignmentStrategy
SimpleAssignmentStrategy.AnalysisContext, SimpleAssignmentStrategy.BackupStrength, SimpleAssignmentStrategy.JMXPartitionStats, SimpleAssignmentStrategy.LoadCalculator, SimpleAssignmentStrategy.SimpleLoadCalculator
-
Nested classes/interfaces inherited from interface com.tangosol.net.partition.SimpleStrategyMBean
SimpleStrategyMBean.HAStatus
-
-
Field Summary
Fields Modifier and Type Field Description protected PartitionedService
m_service
The associated service that this strategy attempts to co-locate partitions with.protected String
m_sService
The name of the associated service.-
Fields inherited from class com.tangosol.net.partition.SimpleAssignmentStrategy
m_cPlanCompletionDelay, m_ctxLast, m_fRefresh, m_manager, m_mapSuggestLast, m_setOwnersLast, m_statsPartition, MEMBERID_COMPARATOR, MSG_NO_PENDING, MSG_NO_RESULT
-
Fields inherited from interface com.tangosol.net.partition.SimpleStrategyMBean
NOTIFY_LOST
-
-
Constructor Summary
Constructors Constructor Description MirroringAssignmentStrategy(String sService)
Construct a MirroringAssignmentStrategy to be associated the specified service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected long
analyzeDistribution(SimpleAssignmentStrategy.AnalysisContext ctx)
Analyze the distribution and suggest the resulting distribution to distribution manager.protected PartitionedService
bindService(String sService)
Bind this assignment strategy to the specified partitioned service, and return the bound service.PartitionedService
getAssociatedService()
Return the associated service.String
getDescription()
Return a human-readable description of the state of the partition assignment.PartitionedService
getService()
Return the partitioned service for which this assignment strategy controls the distribution.void
init(DistributionManager manager)
Initialize the PartitionAssignmentStrategy and bind it to the specified DistributionManager.protected boolean
isRefinementNeeded(SimpleAssignmentStrategy.AnalysisContext ctx, PartitionedService serviceThis, PartitionedService serviceThat)
Return true iff the partition assignments sync'd from the specified associated service should be further refined/balanced by the local assignment strategy.protected void
setAssociatedService(PartitionedService service)
Set the associated service.protected void
syncAssignments(SimpleAssignmentStrategy.AnalysisContext ctx, PartitionedService serviceThat)
Update the analysis context to reflect the partition assignments of the specified associated service.protected boolean
validateAssociatedService(PartitionedService service)
Validate that the distribution for the specified service is compatible with this service.-
Methods inherited from class com.tangosol.net.partition.SimpleAssignmentStrategy
analyze, analyzeDistribution, analyzeOrphans, chainComparators, chainComparators, checkBackupBalance, checkBackupOverloaded, checkBackupStrong, checkEndangered, checkLeaving, checkPrimaryBalance, checkSimpleDistribution, collectScheduledDistributions, doBalancePrimary, emitLossNotification, filterArray, filterArray, filterSort, filterSort, getAveragePartitionSizeKB, getAverageStorageSizeKB, getBackupCount, getCoordinatorId, getFairShareBackup, getFairSharePrimary, getHAStatus, getHAStatusCode, getHATarget, getLastAnalysisContext, getLastAnalysisTime, getLastOwnershipMembers, getManager, getMaxLoadNodeId, getMaxPartitionSizeKB, getMaxStorageSizeKB, getMember, getMemberJoinDelay, getPartitionCount, getRemainingDistributionCount, getServiceMachineCount, getServiceNodeCount, getServiceRackCount, getServiceSiteCount, getStrategyName, getSuggestionCompletionDelay, getSuggestionDelay, getUnownedPartitions, getVariance, instantiateAnalysisContext, instantiateLoadCalculator, makeMBeanName, primeDistribution, registerMBean, reportScheduledDistributions, setLastAnalysisContext, setLastOwnershipMembers, splitByOwner, toString, unregisterMBean, updateCompositeStats, validateBackups
-
-
-
-
Field Detail
-
m_service
protected PartitionedService m_service
The associated service that this strategy attempts to co-locate partitions with. May be null.
-
m_sService
protected String m_sService
The name of the associated service.
-
-
Constructor Detail
-
MirroringAssignmentStrategy
public MirroringAssignmentStrategy(String sService)
Construct a MirroringAssignmentStrategy to be associated the specified service.- Parameters:
sService
- the name of the associated service
-
-
Method Detail
-
getService
public PartitionedService getService()
Return the partitioned service for which this assignment strategy controls the distribution.- Returns:
- the partitioned service controlled by this assignment strategy
-
setAssociatedService
protected void setAssociatedService(PartitionedService service)
Set the associated service.- Parameters:
service
- the associated service
-
getAssociatedService
public PartitionedService getAssociatedService()
Return the associated service.- Returns:
- the associated service
-
validateAssociatedService
protected boolean validateAssociatedService(PartitionedService service)
Validate that the distribution for the specified service is compatible with this service.- Parameters:
service
- the service to validate- Returns:
- true iff the specified service is compatible
-
syncAssignments
protected void syncAssignments(SimpleAssignmentStrategy.AnalysisContext ctx, PartitionedService serviceThat)
Update the analysis context to reflect the partition assignments of the specified associated service.- Parameters:
ctx
- the analysis contextserviceThat
- the associated service whose partition assignments to sync
-
bindService
protected PartitionedService bindService(String sService)
Bind this assignment strategy to the specified partitioned service, and return the bound service.- Parameters:
sService
- the name of the service to bind- Returns:
- the partitioned service
-
isRefinementNeeded
protected boolean isRefinementNeeded(SimpleAssignmentStrategy.AnalysisContext ctx, PartitionedService serviceThis, PartitionedService serviceThat)
Return true iff the partition assignments sync'd from the specified associated service should be further refined/balanced by the local assignment strategy.- Parameters:
ctx
- the analysis contextserviceThis
- the local serviceserviceThat
- the associated service (may be null if unbound)- Returns:
- true iff the partition assignments should be further refined
-
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
- Overrides:
init
in classSimpleAssignmentStrategy
- Parameters:
manager
- the DistributionManager that this strategy is bound to
-
getDescription
public String getDescription()
Return a human-readable description of the state of the partition assignment.- Specified by:
getDescription
in interfacePartitionAssignmentStrategy
- Overrides:
getDescription
in classSimpleAssignmentStrategy
- Returns:
- a human-readable description
-
analyzeDistribution
protected long analyzeDistribution(SimpleAssignmentStrategy.AnalysisContext ctx)
Analyze the distribution and suggest the resulting distribution to distribution manager.- Overrides:
analyzeDistribution
in classSimpleAssignmentStrategy
- Parameters:
ctx
- the analysis context- Returns:
- the time interval before the next desired analysis, or -1
-
-