Package org.jgroups.protocols.pbcast
Class Merger
- java.lang.Object
-
- org.jgroups.protocols.pbcast.Merger
-
public class Merger extends java.lang.Object
Handles merging. Called by CoordGmsImpl and ParticipantGmsImpl- Author:
- Bela Ban
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Merger.MergeKiller
protected class
Merger.MergeTask
Starts the merge protocol (only run by the merge leader).
-
Field Summary
Fields Modifier and Type Field Description protected ResponseCollector<Digest>
digest_collector
For GET_DIGEST / DIGEST_RSP correlationprotected GMS
gms
protected Log
log
protected MergeId
merge_id
protected BoundedList<MergeId>
merge_id_history
protected java.util.concurrent.Future<?>
merge_killer
protected ResponseCollector<MergeData>
merge_rsps
For MERGE_REQ/MERGE_RSP correlation, contains MergeData elementsprotected Merger.MergeTask
merge_task
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_handleMergeRequest(Address sender, MergeId merge_id, java.util.Collection<? extends Address> mbrs)
protected void
cancelMerge(MergeId id)
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).protected Address
determineMergeLeader(java.util.Map<Address,View> views)
Returns the address of the merge leaderprotected 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.protected void
fixDigests()
Fetches the digests from all members and installs them again.protected void
forceCancelMerge()
MergeId
getMergeId()
java.lang.String
getMergeIdAsString()
java.lang.String
getMergeIdHistory()
void
handleDigestResponse(Address sender, Digest digest)
void
handleMergeCancelled(MergeId merge_id)
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.void
handleMergeResponse(MergeData data, MergeId merge_id)
void
handleMergeView(MergeData data, MergeId merge_id)
If merge_id is not equal to this.merge_id then discard.boolean
isMergeInProgress()
boolean
isMergeKillerTaskRunning()
boolean
isMergeTaskRunning()
boolean
matchMergeId(MergeId id)
void
merge(java.util.Map<Address,View> views)
Invoked upon receiving a MERGE event from the MERGE layer.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).protected void
sendMergeCancelledMessage(java.util.Collection<Address> coords, MergeId merge_id)
protected void
sendMergeRejectedResponse(Address sender, MergeId merge_id)
protected void
sendMergeResponse(Address sender, View view, Digest digest, MergeId merge_id)
Send back a response containing view and digest to senderprotected void
sendMergeView(java.util.Collection<Address> coords, MergeData combined_merge_data, MergeId merge_id)
Sends the new view and digest to all subgroup coordinators.boolean
setMergeId(MergeId expected, MergeId new_value)
protected void
startMergeKiller()
protected void
stop()
protected void
stopMergeKiller()
-
-
-
Field Detail
-
gms
protected final GMS gms
-
log
protected final Log log
-
merge_task
protected final Merger.MergeTask merge_task
-
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_id_history
protected final BoundedList<MergeId> merge_id_history
-
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)
-
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 leadermerge_id
- The merge IDmbrs
- The set of members from which we expect responses. Guaranteed to be non-null
-
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)
-
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
becomesA: 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()
-
-