Class 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
    • 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 context
        serviceThat - 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 context
        serviceThis - the local service
        serviceThat - 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 distribution analysis.
        Specified by:
        init in interface PartitionAssignmentStrategy
        Overrides:
        init in class SimpleAssignmentStrategy
        Parameters:
        manager - the DistributionManager that this strategy is bound to