Skip to content

Commit

Permalink
ns
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Oct 2, 2023
1 parent e2a8090 commit 8de08cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/org/jgroups/protocols/relay/Route.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void send(Address final_destination, Address original_sender, final Messa

public void send(Address final_destination, Address original_sender, final Message msg, Collection<String> visited_sites) {
if(log.isTraceEnabled())
log.trace("routing message to " + final_destination + " via " + site_master);
log.trace("%s: routing message to %s via %s", bridge.address(), final_destination, site_master);
long start=stats? System.nanoTime() : 0;
try {
Message copy=createMessage(site_master, final_destination, original_sender, msg, visited_sites);
Expand Down
24 changes: 16 additions & 8 deletions tests/junit-functional/org/jgroups/tests/RelayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ public void testFragmentation(Class<? extends RELAY> cl) throws Exception {
/** Tests state transfer between sites: from C:nyc to A:lon */
public void testStateTransfer(Class<? extends RELAY> cl) throws Exception {
createSymmetricNetwork(cl, ch -> new MyReceiver<>().rawMsgs(true));
MyReceiver<Message> r_a=(MyReceiver<Message>)a.getReceiver();
MyReceiver<Message> r_c=(MyReceiver<Message>)c.getReceiver();
MyReceiver<Message> r_a=getReceiver(a);
MyReceiver<Message> r_c=getReceiver(c);
boolean relay2=cl.equals(RELAY2.class);

// set state in C:
Expand Down Expand Up @@ -764,10 +764,9 @@ public void testMulticastWithMultipleSiteMasters(Class<? extends RELAY> cl) thro
/** A sends a message M to SiteMaster("nyc") (C), but C fails before receiving M. A retransmits and eventually
* the new site master of "nyc" (D) will receive and process M */
public void testFailover(Class<? extends RELAY> cl) throws Exception {
createSymmetricNetwork(cl, ch -> new MyReceiver<>().rawMsgs(true).verbose(true));
createSymmetricNetwork(cl, ch -> new MyReceiver<>().rawMsgs(true).verbose(true).name(ch.name()));
Util.close(f,e);

((MyReceiver<?>)d.getReceiver()).name("D");
DROP drop=new DROP(); // drops unicast message from A:lon -> C:nyc (site master)
drop.addDownFilter(msg -> msg.src() != null && msg.src().equals(a.getAddress())
&& msg.dest() != null && msg.dest().isSiteMaster());
Expand All @@ -785,10 +784,9 @@ public void testFailover(Class<? extends RELAY> cl) throws Exception {

/** Same as above, but now DROP is added to the bridge stack between "lon" and "nyc" */
public void testFailover2(Class<? extends RELAY> cl) throws Exception {
createSymmetricNetwork(cl, ch -> new MyReceiver<>().rawMsgs(true).verbose(true));
createSymmetricNetwork(cl, ch -> new MyReceiver<>().rawMsgs(true).verbose(true).name(ch.getName()));
Util.close(f,e);

((MyReceiver<?>)d.getReceiver()).name("D");
DROP drop=new DROP(); // drops unicast message from _A:lon -> _C:nyc (site master)
RELAY relay_a=a.getProtocolStack().findProtocol(RELAY.class);
JChannel bridge=relay_a.getBridge(NYC);
Expand All @@ -807,12 +805,22 @@ public void testFailover2(Class<? extends RELAY> cl) throws Exception {
}

/** B:lon sends M to SiteMaster("nyc") (C). Before forwarding M to the local site master (A), A fails.
* B now assume the site master role and forwards M to C:nyc
* B now becomes site master and forwards M to C:nyc
*/
public void testFailover3(Class<? extends RELAY> cl) throws Exception {
createSymmetricNetwork(cl, ch -> new MyReceiver<>().rawMsgs(true).verbose(true));
createSymmetricNetwork(cl, ch -> new MyReceiver<>().rawMsgs(true).verbose(true).name(ch.name()));
Util.close(f, e);

MyReceiver<Message> r=getReceiver(c);
DROP drop=new DROP().addDownFilter(m -> m.dest() != null && m.dest().equals(a.address()));
b.getProtocolStack().insertProtocol(drop, ProtocolStack.Position.BELOW, RELAY.class);
b.send(new SiteMaster("nyc"), "hello");

Util.close(a);
Util.waitUntil(3000, 500,
() -> ((RELAY)b.getProtocolStack().findProtocol(RELAY.class)).isSiteMaster());
drop.clearDownFilters();
Util.waitUntil(2000, 200, () -> r.size() == 1);

}

Expand Down

0 comments on commit 8de08cd

Please sign in to comment.