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
  • Field Details

    • site_status

      protected final SiteStatus site_status
    • delay_site_unreachable_events

      protected long delay_site_unreachable_events
    • site_unreachable_delayer

      protected Delayer<String> site_unreachable_delayer
    • unicast

      protected UNICAST3 unicast
  • Constructor Details

    • RELAY3

      public RELAY3()
  • Method Details

    • siteStatus

      public SiteStatus siteStatus()
    • delaySiteUnreachableEvents

      public long delaySiteUnreachableEvents()
    • delaySiteUnreachableEvents

      public RELAY3 delaySiteUnreachableEvents(long t)
    • configure

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

      public void destroy()
      Description copied from class: Protocol
      This method is called on a JChannel.close(). Does some cleanup; after the call, the VM will terminate
      Specified by:
      destroy in interface Lifecycle
      Overrides:
      destroy in class Protocol
    • printTopology

      public String printTopology(boolean all_sites)
    • printLocalTopology

      public String printLocalTopology()
    • down

      public 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 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:
      dest - The address to which to send the response
      all_sites - When true, return information about all sites (1 msg/site), otherwise only about this site
    • sendResponsesForAllSites

      protected void sendResponsesForAllSites(Address dest)
    • handleView

      public void handleView(View view)
      Specified by:
      handleView in class RELAY
    • handleRelayerStarted

      protected <T> Object handleRelayerStarted(Relayer r, long start, T ignored, 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)
      Overrides:
      triggerSiteUnreachableEvent in class RELAY
    • _triggerSiteUnreachableEvent

      protected void _triggerSiteUnreachableEvent(SiteAddress s)
    • triggerMemberUnreachableEvent

      protected void triggerMemberUnreachableEvent(Address mbr)
      Overrides:
      triggerMemberUnreachableEvent in class RELAY
    • routeThen

      protected Object routeThen(Message msg, List<String> sites, Supplier<Object> action)
    • process

      protected 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 Object route(Message msg, Collection<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 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 Object deliver(Address next_dest, Message msg, boolean dont_relay, boolean dont_loopback, boolean oob)
    • sendToLocalSiteMaster

      protected Object sendToLocalSiteMaster(Address sender, Message msg)
    • passUp

      protected 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, 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 CompletableFuture<Relayer> startRelayer(Relayer3 rel, String bridge_name)