Skip to content

Commit

Permalink
- Added site_cache to RELAY2 to suppress duplicate siteUp() notificat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
belaban committed Jun 12, 2023
1 parent 1c3d6e1 commit 49a9346
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/org/jgroups/protocols/relay/RELAY2.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.function.Consumer;
import java.util.function.Supplier;

import static org.jgroups.protocols.relay.Relay2Header.SITES_UP;
import static org.jgroups.protocols.relay.Relay2Header.SITE_UNREACHABLE;

/**
Expand Down Expand Up @@ -112,11 +113,12 @@ public class RELAY2 extends Protocol {
@Property(description="Number of millis to wait for topology detection",type=AttributeType.TIME)
protected long topo_wait_time=2000;

// protocol IDs above RELAY2
protected short[] prots_above;
protected short[] prots_above; // protocol IDs above RELAY2

protected volatile RouteStatusListener route_status_listener;

protected final Set<String> site_cache=new HashSet<>(); // to prevent duplicate site-ups

/** Number of messages forwarded to the local SiteMaster */
protected final LongAdder forward_to_site_master=new LongAdder();

Expand Down Expand Up @@ -346,7 +348,6 @@ else if(site_masters_ratio > 1) {
return retval;
});
}

prots_above=getIdsAbove();
}

Expand Down Expand Up @@ -658,13 +659,19 @@ protected boolean handleAdminMessage(Relay2Header hdr, Address sender) {
Set<String> tmp_sites=hdr.getSites();
if(route_status_listener != null && tmp_sites != null) {
tmp_sites.remove(this.site);
if(hdr.type == SITES_UP) {
tmp_sites.removeAll(site_cache);
site_cache.addAll(tmp_sites);
}
if(tmp_sites.isEmpty())
return true;
String[] tmp=tmp_sites.toArray(new String[]{});
if(hdr.type == Relay2Header.SITES_UP)
route_status_listener.sitesUp(tmp);
else
else {
route_status_listener.sitesDown(tmp);
site_cache.removeAll(tmp_sites);
}
}
return true;
case Relay2Header.TOPO_REQ:
Expand Down
2 changes: 1 addition & 1 deletion tests/junit-functional/org/jgroups/tests/Relay2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ protected static RELAY2 createRELAY2(String site_name) throws UnknownHostExcepti
protected static Protocol[] createBridgeStack() throws UnknownHostException {
return new Protocol[] {
new TCP().setBindAddress(LOOPBACK),
new MPING().setMcastAddr(InetAddress.getByName("239.9.9.9")),
new LOCAL_PING(),
new MERGE3().setMaxInterval(3000).setMinInterval(1000),
new NAKACK2().useMcastXmit(false),
new UNICAST3(),
Expand Down

0 comments on commit 49a9346

Please sign in to comment.