Skip to content

Commit

Permalink
ns
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Jun 28, 2023
1 parent 11126d0 commit 150b930
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
43 changes: 29 additions & 14 deletions src/org/jgroups/protocols/relay/RELAY2.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class RELAY2 extends Protocol {
protected static final short TOPO_ID=560; // defined in jg-protocol-ids.xml

/* ------------------------------------------ Properties ---------------------------------------------- */
@Property(description="Name of the site (needs to be defined in the configuration)",writable=false)
@Property(description="Name of the site; must be defined in the configuration",writable=false)
protected String site;

@Property(description="Name of the relay configuration",writable=false)
Expand Down Expand Up @@ -433,35 +433,39 @@ public Object down(Message msg) {
if(local_addr instanceof ExtendedUUID)
((ExtendedUUID)sender).addContents((ExtendedUUID)local_addr);

/*if(target instanceof SiteMaster) {
if(!is_site_master)
forwardToSiteMaster(sender, target, msg);
else {
if(target.getSite() == null) // send to *all* site masters
sendToBridges(msg);
// deli
}
return null;
}*/

// target is in the same site; we can deliver the message in our local cluster
if(target.getSite().equals(site)) {
if(site.equals(target.getSite())) {
// we're the target or we're the site master and need to forward the message to a member of the local cluster
if(local_addr.equals(target) || (target instanceof SiteMaster && is_site_master)) {
// we cannot simply pass msg down, as the transport doesn't know how to send a message to a (e.g.) SiteMaster
forwardTo(local_addr, target, sender, msg, false);
}
else
else // forward to another member of the local cluster
deliverLocally(target, sender, msg);
return null;
}

// forward to the site master unless we're the site master (then route the message directly)
if(!is_site_master) {
long start=stats? System.nanoTime() : 0;
Address site_master=pickSiteMaster(sender);
if(site_master == null)
throw new IllegalStateException("site master is null");
forwardTo(site_master, target, sender, msg, max_site_masters == 1);
if(stats) {
forward_sm_time.add(System.nanoTime() - start);
forward_to_site_master.increment();
}
}
if(!is_site_master)
forwardToSiteMaster(sender, target, msg);
else
route(target, sender, msg);
return null;
}



public Object up(Event evt) {
if(evt.getType() == Event.VIEW_CHANGE)
handleView(evt.getArg());
Expand Down Expand Up @@ -793,6 +797,17 @@ protected void forwardTo(Address next_dest, SiteAddress final_dest, Address orig
down_prot.down(copy);
}

protected void forwardToSiteMaster(Address sender, SiteAddress final_dest, Message msg) {
long start=stats? System.nanoTime() : 0;
Address site_master=pickSiteMaster(sender);
if(site_master == null)
throw new IllegalStateException("site master is null");
forwardTo(site_master, final_dest, sender, msg, max_site_masters == 1);
if(stats) {
forward_sm_time.add(System.nanoTime() - start);
forward_to_site_master.increment();
}
}

protected void deliverLocally(SiteAddress dest, SiteAddress sender, Message msg) {
Address local_dest;
Expand Down
2 changes: 1 addition & 1 deletion src/org/jgroups/protocols/relay/Topology.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Topology refresh() {
*/
@ManagedOperation(description="Fetches information (site, address, IP address) from all members of a given site")
public Topology refresh(String site) {
Address dest=site != null? new SiteMaster(site) : null;
Address dest=new SiteMaster(site); // sent to all site masters if site == null
Message topo_req=new EmptyMessage(dest).putHeader(RELAY2.TOPO_ID, new TopoHeader(TopoHeader.REQ));
relay.down(topo_req);
return this;
Expand Down

0 comments on commit 150b930

Please sign in to comment.