Class Relayer


  • public class Relayer
    extends java.lang.Object
    Maintains bridges and routing table. Does the routing of outgoing messages and dispatches incoming messages to the right members.

    A Relayer cannot be reused once it is stopped, but a new Relayer instance must be created.

    Since:
    3.2
    Author:
    Bela Ban
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  Relayer.Bridge  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Queue<Relayer.Bridge> bridges
      The bridges which are used to connect to different sites
      protected boolean done
      Flag set when stop() is called.
      protected Log log  
      protected RELAY2 relay  
      protected java.util.concurrent.ConcurrentMap<java.lang.String,​java.util.List<Route>> routes
      The routing table.
      protected boolean stats  
    • Constructor Summary

      Constructors 
      Constructor Description
      Relayer​(RELAY2 relay, Log log)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean done()  
      protected View getBridgeView​(java.lang.String cluster_name)  
      protected Route getRoute​(java.lang.String site)  
      protected Route getRoute​(java.lang.String site, Address sender)  
      protected java.util.List<Route> getRoutes​(java.lang.String... excluded_sites)  
      protected java.util.List<java.lang.String> getSiteNames()  
      protected static boolean isExcluded​(Route route, java.lang.String... excluded_sites)  
      java.lang.String printRoutes()  
      void start​(java.util.List<RelayConfig.BridgeConfig> bridge_configs, java.lang.String bridge_name, java.lang.String my_site_id)
      Creates all bridges from site_config and connects them (joining the bridge clusters)
      void stop()
      Disconnects and destroys all bridges
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • routes

        protected java.util.concurrent.ConcurrentMap<java.lang.String,​java.util.List<Route>> routes
        The routing table. Site IDs are the keys (e.g. "sfo", and list of routes are the values
      • bridges

        protected final java.util.Queue<Relayer.Bridge> bridges
        The bridges which are used to connect to different sites
      • log

        protected final Log log
      • relay

        protected final RELAY2 relay
      • done

        protected volatile boolean done
        Flag set when stop() is called. Since a Relayer should not be used after stop() has been called, a new instance needs to be created
      • stats

        protected boolean stats
    • Constructor Detail

      • Relayer

        public Relayer​(RELAY2 relay,
                       Log log)
    • Method Detail

      • done

        public boolean done()
      • start

        public void start​(java.util.List<RelayConfig.BridgeConfig> bridge_configs,
                          java.lang.String bridge_name,
                          java.lang.String my_site_id)
                   throws java.lang.Throwable
        Creates all bridges from site_config and connects them (joining the bridge clusters)
        Parameters:
        bridge_configs - A list of bridge configurations
        bridge_name - The name of the local bridge channel, prefixed with '_'.
        my_site_id - The ID of this site
        Throws:
        java.lang.Throwable
      • stop

        public void stop()
        Disconnects and destroys all bridges
      • printRoutes

        public java.lang.String printRoutes()
      • getRoute

        protected Route getRoute​(java.lang.String site)
      • getRoute

        protected Route getRoute​(java.lang.String site,
                                 Address sender)
      • getSiteNames

        protected java.util.List<java.lang.String> getSiteNames()
      • getRoutes

        protected java.util.List<Route> getRoutes​(java.lang.String... excluded_sites)
      • getBridgeView

        protected View getBridgeView​(java.lang.String cluster_name)
      • isExcluded

        protected static boolean isExcluded​(Route route,
                                            java.lang.String... excluded_sites)