Skip to content

Commit

Permalink
Removed 'to' from Bridge/BridgeConfig (JGRP-1506)
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed May 16, 2023
1 parent 2885eaa commit 4a9dfac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
8 changes: 3 additions & 5 deletions src/org/jgroups/protocols/relay/Relayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void start(RelayConfig.SiteConfig site_cfg, String bridge_name, final Str
// Add configured bridges
List<RelayConfig.BridgeConfig> bridge_configs=site_cfg.getBridges();
for(RelayConfig.BridgeConfig cfg: bridge_configs) {
Bridge bridge=new Bridge(cfg.createChannel(), cfg.getClusterName(), cfg.getTo(), bridge_name,
Bridge bridge=new Bridge(cfg.createChannel(), cfg.getClusterName(), bridge_name,
() -> new SiteUUID(UUID.randomUUID(), null, my_site_id));
bridges.add(bridge);
}
Expand Down Expand Up @@ -186,17 +186,15 @@ protected static boolean isExcluded(Route route, String... excluded_sites) {
protected class Bridge implements Receiver {
protected JChannel channel;
protected String cluster_name;
protected String to;
protected View view;

protected Bridge(final JChannel ch, final String cluster_name, String to, String channel_name,
protected Bridge(final JChannel ch, final String cluster_name, String channel_name,
AddressGenerator addr_generator) throws Exception {
this.channel=ch;
channel.setName(channel_name);
channel.setReceiver(this);
channel.addAddressGenerator(addr_generator);
this.cluster_name=cluster_name;
this.to=to;
}

protected void start() throws Exception {
Expand Down Expand Up @@ -284,7 +282,7 @@ public void viewAccepted(View new_view) {

@Override
public String toString() {
return String.format("bridge to %s [cluster: %s]", to, cluster_name);
return String.format("bridge %s", cluster_name);
}

protected boolean contains(List<Route> routes, Address addr) {
Expand Down
23 changes: 6 additions & 17 deletions src/org/jgroups/protocols/relay/config/RelayConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ protected static void parseBridges(SiteConfig site_config, XmlNode root) throws
continue;
String name=attrs.get("name");
String config=attrs.get("config");
String to=attrs.get("to");
if(to == null) // "to" overrides site-name (when given)
to=site_config.getName();
BridgeConfig bridge_config=new PropertiesBridgeConfig(name, to, config);
BridgeConfig bridge_config=new PropertiesBridgeConfig(name, config);
site_config.addBridge(bridge_config);
}
}
Expand Down Expand Up @@ -158,27 +155,23 @@ public String toString() {

public abstract static class BridgeConfig {
protected String cluster_name;
protected String to; // the site to/from which this bridge forwards/receives messages

protected BridgeConfig(String cluster_name, String to) {
protected BridgeConfig(String cluster_name) {
this.cluster_name=cluster_name;
this.to=to;
}

public String getClusterName() {return cluster_name;}
public BridgeConfig setClusterName(String s) {cluster_name=s; return this;}
public String getTo() {return to;}
public BridgeConfig setTo(String s) {to=s; return this;}
public abstract JChannel createChannel() throws Exception;

public String toString() {return String.format("to=%s, cluster=%s", to, cluster_name);}
public String toString() {return String.format("bridge %s", cluster_name);}
}

public static class PropertiesBridgeConfig extends BridgeConfig {
protected final String config;

public PropertiesBridgeConfig(String cluster_name, String to, String config) {
super(cluster_name, to);
public PropertiesBridgeConfig(String cluster_name, String config) {
super(cluster_name);
this.config=Util.substituteVariable(config);
}

Expand All @@ -191,11 +184,7 @@ public static class ProgrammaticBridgeConfig extends BridgeConfig {
protected Protocol[] protocols;

public ProgrammaticBridgeConfig(String cluster_name, Protocol[] prots) {
this(cluster_name, cluster_name, prots);
}

public ProgrammaticBridgeConfig(String cluster_name, String to, Protocol[] prots) {
super(cluster_name, to);
super(cluster_name);
this.protocols=prots;
}

Expand Down

0 comments on commit 4a9dfac

Please sign in to comment.