Class RELAY3

  • All Implemented Interfaces:
    Lifecycle

    public class RELAY3
    extends RELAY
    Provides relaying of messages between autonomous sites.
    Design: ./doc/design/RELAY2.txt and at https://github.com/belaban/JGroups/blob/master/doc/design/RELAY2.txt.
    JIRA: https://issues.redhat.com/browse/JGRP-1433
    Since:
    3.2
    Author:
    Bela Ban
    • Field Detail

      • site_status

        protected final SiteStatus site_status
      • delay_site_unreachable_events

        protected long delay_site_unreachable_events
      • site_unreachable_delayer

        protected Delayer<java.lang.String> site_unreachable_delayer
    • Constructor Detail

      • RELAY3

        public RELAY3()
    • Method Detail

      • delaySiteUnreachableEvents

        public long delaySiteUnreachableEvents()
      • delaySiteUnreachableEvents

        public RELAY3 delaySiteUnreachableEvents​(long t)
      • configure

        public void configure()
                       throws java.lang.Exception
        Overrides:
        configure in class RELAY
        Throws:
        java.lang.Exception
      • 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 RELAY
        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
      • printTopology

        public java.lang.String printTopology​(boolean all_sites)
      • printLocalTopology

        public java.lang.String printLocalTopology()
      • down

        public java.lang.Object down​(Message msg)
        Description copied from class: Protocol
        A message is sent down the stack. Protocols may examine the message and do something (e.g. add a header) with it, before passing it down.
        Overrides:
        down in class Protocol
      • up

        public java.lang.Object up​(Message msg)
        Description copied from class: Protocol
        A single message was received. Protocols may examine the message and do something (e.g. add a header) with it before passing it up.
        Overrides:
        up in class Protocol
      • up

        public void up​(MessageBatch batch)
        Description copied from class: Protocol
        Sends up a multiple messages in a MessageBatch. The sender of the batch is always the same, and so is the destination (null == multicast messages). Messages in a batch can be OOB messages, regular messages, or mixed messages, although the transport itself will create initial MessageBatches that contain only either OOB or regular messages.

        The default processing below sends messages up the stack individually, based on a matching criteria (calling Protocol.accept(Message)), and - if true - calls Protocol.up(org.jgroups.Event) for that message and removes the message. If the batch is not empty, it is passed up, or else it is dropped.

        Subclasses should check if there are any messages destined for them (e.g. using MessageBatch.iterator(Predicate)), then possibly remove and process them and finally pass the batch up to the next protocol. Protocols can also modify messages in place, e.g. ENCRYPT could decrypt all encrypted messages in the batch, not remove them, and pass the batch up when done.

        Overrides:
        up in class Protocol
        Parameters:
        batch - The message batch
      • sendResponseTo

        protected void sendResponseTo​(Address dest,
                                      boolean all_sites)
        Returns information about all members of all sites, or only the local members of a given site
        Parameters:
        all_sites - When true, return information about all sites (1 msg/site), otherwise only about this site
        dest - The address to which to send the response
      • sendResponsesForAllSites

        protected void sendResponsesForAllSites​(Address dest)
      • handleRelayerStarted

        protected <T> java.lang.Object handleRelayerStarted​(Relayer r,
                                                            long start,
                                                            T ignored,
                                                            java.lang.Throwable t)
      • handleRelayMessage

        protected void handleRelayMessage​(Message msg)
        Called to handle a message received from a different site (via a bridge channel)
        Specified by:
        handleRelayMessage in class RELAY
      • handleAdminMessage

        protected boolean handleAdminMessage​(RelayHeader hdr,
                                             Message msg)
        Handles SITES_UP/SITES_DOWN/TOPO_REQ/TOPO_RSP messages
      • _triggerSiteUnreachableEvent

        protected void _triggerSiteUnreachableEvent​(SiteAddress s)
      • routeThen

        protected java.lang.Object routeThen​(Message msg,
                                             java.util.List<java.lang.String> sites,
                                             java.util.function.Supplier<java.lang.Object> action)
      • process

        protected java.lang.Object process​(boolean down,
                                           Message msg)
        This method has all the routing logic, for both site masters and regular members
      • mustBeRouted

        protected boolean mustBeRouted​(Message msg)
        Determines if a message should be routed. If NO_RELAY is set, then the message won't be routed. If we have multiple site masters, and this site master is picked to route the message, then return true, else return false. JIRA: https://issues.redhat.com/browse/JGRP-2696
      • route

        protected java.lang.Object route​(Message msg,
                                         java.util.Collection<java.lang.String> sites)
        Sends a message to the given sites, or all sites (excluding the local site)
        Parameters:
        msg - The message to be sent
        sites - The sites to send the message to. If null, msg will be sent to all sites listed in the routing table, excepting the local site
      • deliver

        protected java.lang.Object deliver​(Address next_dest,
                                           Message msg,
                                           boolean dont_relay)
        Sends the message to a local destination.
        Parameters:
        next_dest - The destination. If null, the message will be delivered to all members of the local cluster. In this case, flag Message.Flag.NO_RELAY will be set, so that the resulting multicast is not forwarded to other sites.
        msg - The message to deliver
      • deliver

        protected java.lang.Object deliver​(Address next_dest,
                                           Message msg,
                                           boolean dont_relay,
                                           boolean dont_loopback,
                                           boolean oob)
      • sendToLocalSiteMaster

        protected java.lang.Object sendToLocalSiteMaster​(Address sender,
                                                         Message msg)
      • passUp

        protected java.lang.Object passUp​(Message msg)
        Sends a message up the stack. If there's a header, msg.dest is set to the header's final destination and msg.src to te header's original sender
        Parameters:
        msg - The message to be sent up
      • checkLocalAddress

        protected Address checkLocalAddress​(Address dest)
      • sameSite

        protected boolean sameSite​(SiteAddress addr)
      • sendSiteUnreachableTo

        protected void sendSiteUnreachableTo​(Address dest,
                                             java.lang.String target_site)
        Sends a SITE-UNREACHABLE message to the sender of the message.
        Parameters:
        dest - The node who is trying to send a message to the target_site
        target_site - The remote site's name.
      • sendMemberUnreachableTo

        protected void sendMemberUnreachableTo​(Address dest,
                                               Address member)
        Sends a MBR-UNREACHABLE message to the sender of a unicast message
        Parameters:
        dest - The node who original sent the unicast message. Must never be null
      • startRelayer

        protected java.util.concurrent.CompletableFuture<Relayer> startRelayer​(Relayer3 rel,
                                                                               java.lang.String bridge_name)