/** * Returns the bridge channel to a given site * @param site_name The site name, e.g. "SFO" * @return The JChannel to the given site, or null if no route was found or we're not the coordinator */ public JChannel getBridge(String site_name) { Relayer tmp=relayer; Route route=tmp != null? tmp.getRoute(site_name): null; return route != null? route.bridge() : null; }
/** * Returns the route to a given site * @param site_name The site name, e.g. "SFO" * @return The route to the given site, or null if no route was found or we're not the coordinator */ public Route getRoute(String site_name) { Relayer tmp=relayer; return tmp != null? tmp.getRoute(site_name): null; }
protected Message createMessage(Address target, Address final_destination, Address original_sender, final Message msg) { Message copy=relay.copy(msg).dest(target).src(null); RELAY2.Relay2Header hdr=new RELAY2.Relay2Header(RELAY2.Relay2Header.DATA, final_destination, original_sender); copy.putHeader(relay.getId(), hdr); return copy; } }
/** * Sends a SITE-UNREACHABLE message to the sender of the message. Because the sender is always local (we're the * relayer), no routing needs to be done * @param dest * @param target_site */ protected void sendSiteUnreachableTo(Address dest, String target_site) { Message msg=new Message(dest).setFlag(Message.Flag.OOB, Message.Flag.INTERNAL) .src(new SiteUUID((UUID)local_addr, NameCache.get(local_addr), site)) .putHeader(id,new Relay2Header(Relay2Header.SITE_UNREACHABLE,new SiteMaster(target_site),null)); down_prot.down(msg); }
public UUID copy() { return new SiteMaster(get(SITE_NAME)); }
/** Sends the message via all bridges excluding the excluded_sites bridges */ protected void sendToBridges(Address sender, final Message msg, String ... excluded_sites) { Relayer tmp=relayer; List<Route> routes=tmp != null? tmp.getRoutes(excluded_sites) : null; if(routes == null) return; for(Route route: routes) { if(log.isTraceEnabled()) log.trace(local_addr + ": relaying multicast message from " + sender + " via route " + route); try { route.send(null, sender, msg); } catch(Exception ex) { log.error(local_addr + ": failed relaying message from " + sender + " via route " + route, ex); } } }
public SiteMaster(byte[] site) { super(0, 0, null, site); setFlag(RELAY2.site_master_flag); }
public Relayer(RELAY2 relay, Log log) { this.relay=relay; this.stats=relay.statsEnabled(); this.log=log; }
public String toString() { return "SiteMaster(" + getSite() + ")"; } }
@Override public String toString() { return print(false); }
public View getBridgeView(String cluster_name) { Relayer tmp=relayer; return tmp != null? tmp.getBridgeView(cluster_name) : null; }
public String toString() { return typeToString(type) + " [dest=" + final_dest + ", sender=" + original_sender + "]"; }
public boolean equals(Object obj) { return compareTo((Address)obj) == 0; }
public List<String> siteNames() {return getSites();} public String config() {return config;}
public boolean equals(Object obj) { return compareTo((Route)obj) == 0; }
protected Route getRoute(String site) { return getRoute(site, null);}
public SiteMaster() { setFlag(RELAY2.site_master_flag); }