Permalink
Browse files

View between creation of request and registration with view handler d…

…oesn't cause requests to hang or time out (https://issues.jboss.org/browse/JGRP-1428)
  • Loading branch information...
1 parent dfc3aa3 commit 429ff8dfd70f64306019b28acc13bc51c6576651 Bela Ban committed Feb 27, 2012
@@ -192,13 +192,14 @@ public void suspect(Address suspected_member) {
* </ul>
*/
public void viewChange(View new_view) {
- List<Address> mbrs=new_view != null? new_view.getMembers() : null;
+ if(new_view == null || requests == null || requests.isEmpty())
+ return;
+
+ List<Address> mbrs=new_view.getMembers();
if(mbrs == null)
return;
boolean changed=false;
- if(requests == null || requests.isEmpty())
- return;
lock.lock();
try {
@@ -57,6 +57,8 @@
/** The address of this group member */
protected Address local_addr=null;
+ protected volatile View view;
+
protected boolean started=false;
private final MyProbeHandler probe_handler=new MyProbeHandler(requests);
@@ -144,8 +146,11 @@ public void sendRequest(long id, Collection<Address> dest_mbrs, Message msg, Rsp
msg.putHeader(this.id, hdr);
- if(coll != null)
+ if(coll != null) {
addEntry(hdr.id, coll);
+ // make sure no view is received before we add ourself as a view handler (https://issues.jboss.org/browse/JGRP-1428)
+ coll.viewChange(view);
+ }
if(options.getAnycasting()) {
for(Address mbr: dest_mbrs) {
@@ -179,8 +184,11 @@ public void sendUnicastRequest(long id, Address target, Message msg, RspCollecto
Header hdr=new Header(Header.REQ, id, (coll != null), this.id);
msg.putHeader(this.id, hdr);
- if(coll != null)
+ if(coll != null) {
addEntry(hdr.id, coll);
+ // make sure no view is received before we add ourself as a view handler (https://issues.jboss.org/browse/JGRP-1428)
+ coll.viewChange(view);
+ }
transport.down(new Event(Event.MSG, msg));
}
@@ -287,11 +295,12 @@ public void receiveSuspect(Address mbr) {
public void receiveView(View new_view) {
// ArrayList copy;
// copy so we don't run into bug #761804 - Bela June 27 2003
- // copy=new ArrayList(requests.values()); // removed because ConcurrentReaderHashMap can tolerate concurrent mods (bela May 8 2006)
+ // copy=new ArrayList(requests.values()); // removed because ConcurrentHashMap can tolerate concurrent mods (bela May 8 2006)
for(RspCollector coll: requests.values()) {
if(coll != null)
coll.viewChange(new_view);
}
+ view=new_view;
}
@@ -44,32 +44,30 @@ protected void tearDown() throws Exception {
dests.clear();
}
- @Test(groups=Global.FUNCTIONAL)
+
+
+
public void testMessageTimeout() throws Exception {
_testMessageTimeout(true);
}
- @Test(groups=Global.FUNCTIONAL)
public void testMessageReception() throws Exception {
_testMessageReception(true);
_testMessageReception(false);
}
- @Test(groups=Global.FUNCTIONAL)
public void testMessageReceptionWithViewChange() throws Exception {
_testMessageReceptionWithViewChange(true);
_testMessageReceptionWithViewChange(false);
}
- @Test(groups=Global.FUNCTIONAL)
public void testMessageReceptionWithViewChangeMemberLeft() throws Exception {
_testMessageReceptionWithViewChangeMemberLeft(true);
_testMessageReceptionWithViewChangeMemberLeft(false);
}
- @Test(groups=Global.FUNCTIONAL)
public void testGetFirstWithResponseFilter() throws Exception {
Object[] responses={new Message(null, a1, new Long(1)),
new Message(null, a2, new Long(2)),
@@ -103,7 +101,6 @@ public boolean needMoreResponses() {
}
- @Test(groups=Global.FUNCTIONAL)
public void testGetAllWithResponseFilter() throws Exception {
Object[] responses={new Message(null, a1, new Long(1)),
new Message(null, a2, new Long(2)),

0 comments on commit 429ff8d

Please sign in to comment.