Class Merger


  • public class Merger
    extends java.lang.Object
    Handles merging. Called by CoordGmsImpl and ParticipantGmsImpl
    Author:
    Bela Ban
    • Field Detail

      • gms

        protected final GMS gms
      • log

        protected final Log log
      • merge_rsps

        protected final ResponseCollector<MergeData> merge_rsps
        For MERGE_REQ/MERGE_RSP correlation, contains MergeData elements
      • digest_collector

        protected final ResponseCollector<Digest> digest_collector
        For GET_DIGEST / DIGEST_RSP correlation
      • merge_id

        protected MergeId merge_id
      • merge_killer

        protected java.util.concurrent.Future<?> merge_killer
    • Constructor Detail

      • Merger

        public Merger​(GMS gms)
    • Method Detail

      • getMergeIdAsString

        public java.lang.String getMergeIdAsString()
      • getMergeIdHistory

        public java.lang.String getMergeIdHistory()
      • isMergeTaskRunning

        public boolean isMergeTaskRunning()
      • isMergeKillerTaskRunning

        public boolean isMergeKillerTaskRunning()
      • getMergeId

        public MergeId getMergeId()
      • isMergeInProgress

        public boolean isMergeInProgress()
      • matchMergeId

        public boolean matchMergeId​(MergeId id)
      • setMergeId

        public boolean setMergeId​(MergeId expected,
                                  MergeId new_value)
      • merge

        public void merge​(java.util.Map<Address,​View> views)
        Invoked upon receiving a MERGE event from the MERGE layer. Starts the merge protocol. See description of protocol in DESIGN.
        Parameters:
        views - A List of different views detected by the merge protocol, keyed by sender
      • handleMergeRequest

        public void handleMergeRequest​(Address sender,
                                       MergeId merge_id,
                                       java.util.Collection<? extends Address> mbrs)
        Get the view and digest and send back both (MergeData) in the form of a MERGE_RSP to the sender. If a merge is already in progress, send back a MergeData with the merge_rejected field set to true.
        Parameters:
        sender - The address of the merge leader
        merge_id - The merge ID
        mbrs - The set of members from which we expect responses. Guaranteed to be non-null
      • handleMergeResponse

        public void handleMergeResponse​(MergeData data,
                                        MergeId merge_id)
      • handleMergeView

        public void handleMergeView​(MergeData data,
                                    MergeId merge_id)
        If merge_id is not equal to this.merge_id then discard. Else cast the view/digest to all members of this group.
      • handleMergeCancelled

        public void handleMergeCancelled​(MergeId merge_id)
      • handleDigestResponse

        public void handleDigestResponse​(Address sender,
                                         Digest digest)
      • sanitizeViews

        public static void sanitizeViews​(java.util.Map<Address,​View> map)
        Removes all members from a given view which don't have us in their view (https://issues.redhat.com/browse/JGRP-1061). Example:
         A: AB
         B: AB
         C: ABC
         
        becomes
         A: AB
         B: AB
         C: C // A and B don't have C in their views
         
        Parameters:
        map - A map of members and their associated views
      • determineMergeLeader

        protected Address determineMergeLeader​(java.util.Map<Address,​View> views)
        Returns the address of the merge leader
      • determineMergeCoords

        protected static java.util.Map<Address,​java.util.Collection<Address>> determineMergeCoords​(java.util.Map<Address,​View> views)
        Needs to return a map of all subview coordinators and their views (as a collection of members). The merge policy is defined in https://issues.redhat.com/browse/JGRP-1910
      • _handleMergeRequest

        protected void _handleMergeRequest​(Address sender,
                                           MergeId merge_id,
                                           java.util.Collection<? extends Address> mbrs)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendMergeResponse

        protected void sendMergeResponse​(Address sender,
                                         View view,
                                         Digest digest,
                                         MergeId merge_id)
        Send back a response containing view and digest to sender
      • sendMergeView

        protected void sendMergeView​(java.util.Collection<Address> coords,
                                     MergeData combined_merge_data,
                                     MergeId merge_id)
        Sends the new view and digest to all subgroup coordinators. Each coord will in turn broadcast the new view and digest to all the members of its subgroup
      • sendMergeRejectedResponse

        protected void sendMergeRejectedResponse​(Address sender,
                                                 MergeId merge_id)
      • sendMergeCancelledMessage

        protected void sendMergeCancelledMessage​(java.util.Collection<Address> coords,
                                                 MergeId merge_id)
      • fetchDigestsFromAllMembersInSubPartition

        protected Digest fetchDigestsFromAllMembersInSubPartition​(View view,
                                                                  MergeId merge_id)
        Multicasts a GET_DIGEST_REQ to all members of this sub partition and waits for all responses (GET_DIGEST_RSP) or N ms.
      • fixDigests

        protected void fixDigests()
        Fetches the digests from all members and installs them again. Used only for diagnosis and support; don't use this otherwise !
      • stop

        protected void stop()
      • cancelMerge

        protected void cancelMerge​(MergeId id)
      • forceCancelMerge

        protected void forceCancelMerge()
      • startMergeKiller

        protected void startMergeKiller()
      • stopMergeKiller

        protected void stopMergeKiller()