Skip to content

Commit

Permalink
Removed handling of SUSPECT event and using TMP_VIEW instead (https:/…
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed May 14, 2012
1 parent d1f58dd commit 7422d94
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/org/jgroups/protocols/SEQUENCER.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public Object down(Event evt) {

seqno_lock.lock();
try {
long next_seqno=seqno +1;
long next_seqno=seqno;
if(is_coord) {
SequencerHeader hdr=new SequencerHeader(SequencerHeader.BCAST, local_addr, next_seqno);
msg.putHeader(this.id, hdr);
Expand All @@ -124,7 +124,7 @@ public Object down(Event evt) {
forwardToCoord(marshalled_msg, next_seqno);
}
}
seqno=next_seqno;
seqno++;
}
finally {
seqno_lock.unlock();
Expand All @@ -135,6 +135,10 @@ public Object down(Event evt) {
handleViewChange((View)evt.getArg());
break;

case Event.TMP_VIEW:
handleTmpView((View)evt.getArg());
break;

case Event.SET_LOCAL_ADDRESS:
local_addr=(Address)evt.getArg();
break;
Expand Down Expand Up @@ -186,8 +190,8 @@ public Object up(Event evt) {
handleViewChange((View)evt.getArg());
return retval;

case Event.SUSPECT:
handleSuspect((Address)evt.getArg());
case Event.TMP_VIEW:
handleTmpView((View)evt.getArg());
break;
}

Expand Down Expand Up @@ -219,27 +223,20 @@ protected void handleViewChange(View v) {
}
}

protected void handleSuspect(Address suspected_mbr) {
boolean coord_changed=false;

if(suspected_mbr == null)
return;
// If we're becoming coordinator, we need to handle TMP_VIEW as
// an immediate change of view. See JGRP-1452.
private void handleTmpView(View v) {
List<Address> mbrs=v.getMembers();
if(mbrs.isEmpty()) return;

synchronized(this) {
List<Address> non_suspected_mbrs=new ArrayList<Address>(members);
non_suspected_mbrs.remove(suspected_mbr);
if(!non_suspected_mbrs.isEmpty()) {
Address prev_coord=coord;
coord=non_suspected_mbrs.get(0);
is_coord=local_addr != null && local_addr.equals(coord);
coord_changed=prev_coord != null && !prev_coord.equals(coord);
}
}
if(coord_changed) {
resendMessagesInForwardTable(); // maybe optimize in the future: broadcast directly if coord
Address new_coord=mbrs.iterator().next();
if (!new_coord.equals(coord) && local_addr != null && local_addr.equals(new_coord)) {
handleViewChange(v);
}
}


/**
* Sends all messages currently in forward_table to the new coordinator (changing the dest field).
* This needs to be done, so the underlying reliable unicast protocol (e.g. UNICAST) adds these messages
Expand Down

0 comments on commit 7422d94

Please sign in to comment.