Class RELAY

java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.relay.RELAY
All Implemented Interfaces:
Lifecycle
Direct Known Subclasses:
RELAY2, RELAY3

public abstract class RELAY extends Protocol
Common superclass for RELAY2 and RELAY3
Since:
5.2.17
  • Field Details

    • can_become_site_master_flag

      public static final short can_become_site_master_flag
      See Also:
    • site

      protected String site
    • config

      protected 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 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 List<Address> site_masters
    • broadcast_route_notifications

      protected volatile boolean broadcast_route_notifications
    • relayer

      protected volatile Relayer relayer
    • topo

      protected final Topology topo
    • forward_to_site_master

      protected final LongAdder forward_to_site_master
      Number of messages forwarded to the local SiteMaster
    • forward_sm_time

      protected final LongAdder forward_sm_time
    • relayed

      protected final LongAdder relayed
      Number of messages relayed by the local SiteMaster to a remote SiteMaster
    • relayed_time

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

      protected final 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 LongAdder forward_to_local_mbr_time
    • prots_above

      protected short[] prots_above
    • timer

      protected TimeScheduler timer
    • site_master_picker

      protected SiteMasterPicker site_master_picker
    • view

      protected volatile View view
    • members

      protected volatile List<Address> members
    • route_status_listener

      protected volatile RouteStatusListener route_status_listener
    • site_master_listener

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

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

      protected RelayConfig.SiteConfig site_config
    • suppress_log_no_route

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

    • RELAY

      public RELAY()
  • Method Details

    • 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 String getSite()
    • site

      public String site()
    • setSite

      public <T extends RELAY> T setSite(String s)
    • site

      public <T extends RELAY> T site(String s)
    • topo

      public Topology topo()
    • view

      public View view()
    • members

      public List<Address> members()
    • config

      public String config()
    • config

      public <T extends RELAY> T config(String cfg)
    • getConfig

      public String getConfig()
    • setConfig

      public <T extends RELAY> T setConfig(String c)
    • getTimer

      public TimeScheduler getTimer()
    • incrementRelayed

      public void incrementRelayed()
    • addToRelayedTime

      public void addToRelayedTime(long d)
    • siteMasters

      public 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 String getSiteMasterPickerImpl()
    • setSiteMasterPickerImpl

      public <T extends RELAY> T setSiteMasterPickerImpl(String s)
    • siteMasterPicker

      public <T extends RELAY> T siteMasterPicker(SiteMasterPicker 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)
    • getRouteStatusListener

      public RouteStatusListener getRouteStatusListener()
    • setRouteStatusListener

      public void setRouteStatusListener(RouteStatusListener l)
    • setSiteMasterListener

      public <T extends RELAY> T setSiteMasterListener(Consumer<Boolean> l)
    • addSite

      public <T extends RELAY> T addSite(String n, RelayConfig.SiteConfig cfg)
    • siteNames

      public List<String> siteNames()
    • isSiteMaster

      public boolean isSiteMaster()
    • getSites

      public List<String> getSites()
    • printSites

      public String printSites()
    • getNumRoutes

      public int getNumRoutes()
    • printRoutes

      public String printRoutes()
    • getRoute

      public Route getRoute(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 List<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(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(String cluster_name)
    • resetStats

      public void resetStats()
      Overrides:
      resetStats in class Protocol
    • init

      public void init() throws 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:
      Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the the channel constructor will throw an exception
    • stop

      public void stop()
      Description copied from class: Protocol
      Called on a JChannel.disconnect(); stops work (e.g. by closing multicast socket). Will be called from top to bottom.
      Specified by:
      stop in interface Lifecycle
      Overrides:
      stop in class Protocol
    • configure

      public void configure() throws Exception
      Throws:
      Exception
    • parse

      public void parse(XmlNode node) throws 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:
      Exception
    • down

      public 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 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(Map<String,RelayConfig.SiteConfig> map) throws Exception
      Parses the configuration by reading the config file
      Throws:
      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, Set<String> sites)
    • notifySiteMasterListener

      protected void notifySiteMasterListener(boolean flag)
    • getPhysicalAddress

      protected PhysicalAddress getPhysicalAddress(Address mbr)
    • determineSiteMasters

      protected static 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)