Permalink
Browse files

If we're the only target of the VIEW multicast in castViewChange(), t…

…hen we'll (1) add the VIEW message to the xmit-table *without* sending it (using event ADD_TO_XMIT_TABLE), and then (2) install the new view directly
  • Loading branch information...
Bela Ban
Bela Ban committed Nov 24, 2011
1 parent c553452 commit 5f87d54051cc0308f2049a2f4b8a88031a37a5a3
Showing with 23 additions and 22 deletions.
  1. +23 −22 src/org/jgroups/protocols/pbcast/GMS.java
@@ -465,39 +465,40 @@ public View getNextView(Collection<Address> new_mbrs, Collection<Address> old_mb
/**
* Broadcasts the new view and digest, and waits for acks from all members in the list given as argument.
* If the list is null, we take the members who are part of new_view
- * @param new_view
- * @param digest
- * @param newMembers
*/
- public void castViewChangeWithDest(View new_view, Digest digest, JoinRsp jr, Collection<Address> newMembers) {
+ public void castViewChange(View new_view, Digest digest, JoinRsp jr, Collection<Address> newMembers) {
if(log.isTraceEnabled())
- log.trace(local_addr + ": mcasting view {" + new_view + "} (" + new_view.size() + " mbrs)\n");
-
- Message view_change_msg=new Message(); // bcast to all members
- GmsHeader hdr=new GmsHeader(GmsHeader.VIEW, new_view);
- hdr.my_digest=digest;
- view_change_msg.putHeader(this.id, hdr);
-
- List<Address> ackMembers=new ArrayList<Address>(new_view.getMembers());
- if(newMembers != null && !newMembers.isEmpty())
- ackMembers.removeAll(newMembers);
-
+ log.trace(local_addr + ": mcasting view " + new_view + " (" + new_view.size() + " mbrs)\n");
// Send down a local TMP_VIEW event. This is needed by certain layers (e.g. NAKACK) to compute correct digest
// in case client's next request (e.g. getState()) reaches us *before* our own view change multicast.
// Check NAKACK's TMP_VIEW handling for details
down_prot.up(new Event(Event.TMP_VIEW, new_view));
down_prot.down(new Event(Event.TMP_VIEW, new_view));
- // If we're the only member the VIEW is broadcast to, let's simply install the view directly, without
- // sending the VIEW multicast ! Or else N-1 members drop the multicast anyway...
+ List<Address> ackMembers=new ArrayList<Address>(new_view.getMembers());
+ if(newMembers != null && !newMembers.isEmpty())
+ ackMembers.removeAll(newMembers);
+
+ Message view_change_msg=new Message(); // bcast to all members
+ GmsHeader hdr=new GmsHeader(GmsHeader.VIEW, new_view);
+ hdr.my_digest=digest;
+ view_change_msg.putHeader(this.id, hdr);
+
+ // If we're the only member the VIEW is broadcast to, let's simply install the view directly, without
+ // sending the VIEW multicast ! Or else N-1 members drop the multicast anyway...
if(local_addr != null && ackMembers.size() == 1 && ackMembers.get(0).equals(local_addr)) {
- // System.out.println("--->> " + local_addr + ": installing view " + new_view.getViewId() + " directly");
+ // System.out.println(local_addr + ": installed view " + new_view + " directly");
+
+ // we need to add the message to the retransmit window (e.g. in NAKACK), so (1) it can be retransmitted and
+ // (2) we increment the seqno (otherwise, we'd return an incorrect digest)
+ down_prot.down(new Event(Event.ADD_TO_XMIT_TABLE, view_change_msg));
impl.handleViewChange(new_view, digest);
}
else {
if(!ackMembers.isEmpty())
ack_collector.reset(ackMembers);
+
down_prot.down(new Event(Event.MSG, view_change_msg));
try {
if(!ackMembers.isEmpty()) {
@@ -510,8 +511,8 @@ public void castViewChangeWithDest(View new_view, Digest digest, JoinRsp jr, Col
catch(TimeoutException e) {
if(log_collect_msgs && log.isWarnEnabled()) {
log.warn(local_addr + ": failed to collect all ACKs (expected=" + ack_collector.expectedAcks()
- + ") for view " + new_view.getViewId() + " after " + view_ack_collection_timeout + "ms, missing ACKs from "
- + ack_collector.printMissing());
+ + ") for view " + new_view.getViewId() + " after " + view_ack_collection_timeout +
+ "ms, missing ACKs from " + ack_collector.printMissing());
}
}
}
@@ -587,7 +588,7 @@ public void installView(View new_view, Digest digest) {
setDigest(digest);
}
- if(log.isDebugEnabled()) log.debug(local_addr + ": view is " + new_view);
+ if(log.isDebugEnabled()) log.debug(local_addr + ": installing view " + new_view);
Event view_event;
synchronized(members) {
@@ -983,7 +984,7 @@ private void sendViewAck(Address dest) {
view_ack.setFlag(Message.OOB);
GmsHeader tmphdr=new GmsHeader(GmsHeader.VIEW_ACK);
view_ack.putHeader(this.id, tmphdr);
- down_prot.down(new Event(Event.MSG, view_ack));
+ down_prot.down(new Event(Event.MSG,view_ack));
}
/* --------------------------- End of Private Methods ------------------------------- */

0 comments on commit 5f87d54

Please sign in to comment.