Class RELAY

    • Field Detail

      • can_become_site_master_flag

        public static final short can_become_site_master_flag
        See Also:
        Constant Field Values
      • site

        protected java.lang.String site
      • config

        protected java.lang.String config
      • can_become_site_master

        protected boolean can_become_site_master
      • max_site_masters

        protected int max_site_masters
      • site_masters_ratio

        protected double site_masters_ratio
      • site_master_picker_impl

        protected java.lang.String site_master_picker_impl
      • async_relay_creation

        protected boolean async_relay_creation
      • delay_sites_down

        protected boolean delay_sites_down
      • suppress_time_no_route_errors

        protected long suppress_time_no_route_errors
      • is_site_master

        protected volatile boolean is_site_master
      • site_masters

        protected volatile java.util.List<Address> site_masters
      • broadcast_route_notifications

        protected volatile boolean broadcast_route_notifications
      • relayer

        protected volatile Relayer relayer
      • forward_to_site_master

        protected final java.util.concurrent.atomic.LongAdder forward_to_site_master
        Number of messages forwarded to the local SiteMaster
      • forward_sm_time

        protected final java.util.concurrent.atomic.LongAdder forward_sm_time
      • relayed

        protected final java.util.concurrent.atomic.LongAdder relayed
        Number of messages relayed by the local SiteMaster to a remote SiteMaster
      • relayed_time

        protected final java.util.concurrent.atomic.LongAdder relayed_time
        Total time spent relaying messages from the local SiteMaster to remote SiteMasters (in ns)
      • forward_to_local_mbr

        protected final java.util.concurrent.atomic.LongAdder forward_to_local_mbr
        Number of messages (received from a remote Sitemaster and) delivered by the local SiteMaster to a local node
      • forward_to_local_mbr_time

        protected final java.util.concurrent.atomic.LongAdder forward_to_local_mbr_time
      • prots_above

        protected short[] prots_above
      • view

        protected volatile View view
      • members

        protected volatile java.util.List<Address> members
      • site_master_listener

        protected java.util.function.Consumer<java.lang.Boolean> site_master_listener
        Listens for notifications about becoming site master (arg: true), or ceasing to be site master (arg: false)
      • sites

        protected final java.util.Map<java.lang.String,​RelayConfig.SiteConfig> sites
        A map containing site names (e.g. "LON") as keys and SiteConfigs as values
      • suppress_log_no_route

        protected SuppressLog<java.lang.String> suppress_log_no_route
        Log to suppress identical errors for messages to non-existing sites ('no route to site X')
    • Constructor Detail

      • RELAY

        public RELAY()
    • Method Detail

      • getNumForwardedToSiteMaster

        public long getNumForwardedToSiteMaster()
      • getTimeForwardingToSM

        public long getTimeForwardingToSM()
      • getAvgMsgsForwardingToSM

        public long getAvgMsgsForwardingToSM()
      • getNumRelayed

        public long getNumRelayed()
      • getTimeRelaying

        public long getTimeRelaying()
      • getAvgMsgsRelaying

        public long getAvgMsgsRelaying()
      • getNumForwardedToLocalMbr

        public long getNumForwardedToLocalMbr()
      • getTimeForwardingToLocalMbr

        public long getTimeForwardingToLocalMbr()
      • getAvgMsgsForwardingToLocalMbr

        public long getAvgMsgsForwardingToLocalMbr()
      • getNumberOfNoRouteErrors

        public int getNumberOfNoRouteErrors()
      • clearNoRouteCache

        public <T extends RELAY> T clearNoRouteCache()
      • getSite

        public java.lang.String getSite()
      • site

        public java.lang.String site()
      • setSite

        public <T extends RELAY> T setSite​(java.lang.String s)
      • site

        public <T extends RELAY> T site​(java.lang.String s)
      • view

        public View view()
      • members

        public java.util.List<Address> members()
      • config

        public java.lang.String config()
      • config

        public <T extends RELAY> T config​(java.lang.String cfg)
      • getConfig

        public java.lang.String getConfig()
      • setConfig

        public <T extends RELAY> T setConfig​(java.lang.String c)
      • incrementRelayed

        public void incrementRelayed()
      • addToRelayedTime

        public void addToRelayedTime​(long d)
      • siteMasters

        public java.util.List<Address> siteMasters()
      • canBecomeSiteMaster

        public boolean canBecomeSiteMaster()
      • canBecomeSiteMaster

        public <T extends RELAY> T canBecomeSiteMaster​(boolean f)
      • getMaxSiteMasters

        public int getMaxSiteMasters()
      • setMaxSiteMasters

        public <T extends RELAY> T setMaxSiteMasters​(int m)
      • getSiteMastersRatio

        public double getSiteMastersRatio()
      • setSiteMastersRatio

        public <T extends RELAY> T setSiteMastersRatio​(double r)
      • getSiteMasterPickerImpl

        public java.lang.String getSiteMasterPickerImpl()
      • setSiteMasterPickerImpl

        public <T extends RELAY> T setSiteMasterPickerImpl​(java.lang.String s)
      • asyncRelayCreation

        public boolean asyncRelayCreation()
      • asyncRelayCreation

        public <T extends RELAY> T asyncRelayCreation​(boolean flag)
      • delaySitesDown

        public boolean delaySitesDown()
      • delaySitesDown

        public <T extends RELAY> T delaySitesDown​(boolean b)
      • broadcastRouteNotifications

        public boolean broadcastRouteNotifications()
      • broadcastRouteNotifications

        public <T extends RELAY> T broadcastRouteNotifications​(boolean b)
      • setSiteMasterListener

        public <T extends RELAY> T setSiteMasterListener​(java.util.function.Consumer<java.lang.Boolean> l)
      • siteNames

        public java.util.List<java.lang.String> siteNames()
      • isSiteMaster

        public boolean isSiteMaster()
      • getSites

        public java.util.List<java.lang.String> getSites()
      • printSites

        public java.lang.String printSites()
      • getNumRoutes

        public int getNumRoutes()
      • printRoutes

        public java.lang.String printRoutes()
      • getRoute

        public Route getRoute​(java.lang.String site_name)
        Returns the route to a given site
        Parameters:
        site_name - The site name, e.g. "SFO"
        Returns:
        The route to the given site, or null if no route was found or we're not the coordinator
      • getCurrentSites

        public java.util.List<java.lang.String> getCurrentSites()
        Returns:
        A List of sites name that are currently up or null if this node is not a Site Master (i.e. isSiteMaster() returns false).
      • getBridge

        public JChannel getBridge​(java.lang.String site_name)
        Returns the bridge channel to a given site
        Parameters:
        site_name - The site name, e.g. "SFO"
        Returns:
        The JChannel to the given site, or null if no route was found or we're not the coordinator
      • getBridgeView

        public View getBridgeView​(java.lang.String cluster_name)
      • init

        public void init()
                  throws java.lang.Exception
        Description copied from class: Protocol
        Called after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent.
        Specified by:
        init in interface Lifecycle
        Overrides:
        init in class Protocol
        Throws:
        java.lang.Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the the channel constructor will throw an exception
      • configure

        public void configure()
                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • parse

        public void parse​(XmlNode node)
                   throws java.lang.Exception
        Description copied from class: Protocol
        Called by the XML parser when subelements are found in the configuration of a protocol. This allows a protocol to define protocol-specific information and to parse it
        Overrides:
        parse in class Protocol
        Throws:
        java.lang.Exception
      • down

        public java.lang.Object down​(Event evt)
        Description copied from class: Protocol
        An event is to be sent down the stack. A protocol may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the protocol may need to add a header to it (or do nothing at all) before sending it down the stack using down_prot.down().
        Overrides:
        down in class Protocol
      • up

        public java.lang.Object up​(Event evt)
        Description copied from class: Protocol
        An event was received from the protocol below. Usually the current protocol will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally, the event is either a) discarded, or b) an event is sent down the stack using down_prot.down() or c) the event (or another event) is sent up the stack using up_prot.up().
        Overrides:
        up in class Protocol
      • handleView

        public abstract void handleView​(View v)
      • handleRelayMessage

        protected abstract void handleRelayMessage​(Message msg)
      • isLocal

        protected boolean isLocal​(SiteAddress addr)
      • isLocalSitemaster

        protected boolean isLocalSitemaster​(SiteAddress addr)
      • parseSiteConfiguration

        protected void parseSiteConfiguration​(java.util.Map<java.lang.String,​RelayConfig.SiteConfig> map)
                                       throws java.lang.Exception
        Parses the configuration by reading the config file
        Throws:
        java.lang.Exception
      • copy

        protected Message copy​(Message msg)
        Copies the message, but only the headers above the current protocol (RELAY) (or RpcDispatcher related headers)
      • sitesChange

        protected void sitesChange​(boolean down,
                                   java.util.Set<java.lang.String> sites)
      • notifySiteMasterListener

        protected void notifySiteMasterListener​(boolean flag)
      • determineSiteMasters

        protected static java.util.List<Address> determineSiteMasters​(View view,
                                                                      int max_num_site_masters)
        Iterates over the list of members and adds every member if the member's rank is below max_site_masters. Skips members which cannot become site masters (can_become_site_master == false). If no site master can be found, the first member of the view will be returned (even if it has can_become_site_master == false)
      • pickSiteMaster

        protected Address pickSiteMaster​(Address sender)
        Returns a site master from site_masters
      • triggerSiteUnreachableEvent

        protected void triggerSiteUnreachableEvent​(SiteAddress remoteSite)
      • triggerMemberUnreachableEvent

        protected void triggerMemberUnreachableEvent​(Address mbr)