Package org.jgroups.protocols.relay
Class RELAY3
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.relay.RELAY
-
- org.jgroups.protocols.relay.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 Summary
Fields Modifier and Type Field Description protected long
delay_site_unreachable_events
protected SiteStatus
site_status
protected Delayer<java.lang.String>
site_unreachable_delayer
protected UNICAST3
unicast
-
Fields inherited from class org.jgroups.protocols.relay.RELAY
async_relay_creation, broadcast_route_notifications, can_become_site_master, can_become_site_master_flag, config, delay_sites_down, forward_sm_time, forward_to_local_mbr, forward_to_local_mbr_time, forward_to_site_master, is_site_master, max_site_masters, members, prots_above, relayed, relayed_time, relayer, route_status_listener, site, site_config, site_master_listener, site_master_picker, site_master_picker_impl, site_masters, site_masters_ratio, sites, suppress_log_no_route, suppress_time_no_route_errors, timer, topo, view
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description RELAY3()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_triggerSiteUnreachableEvent(SiteAddress s)
protected Address
checkLocalAddress(Address dest)
void
configure()
long
delaySiteUnreachableEvents()
RELAY3
delaySiteUnreachableEvents(long t)
protected java.lang.Object
deliver(Address next_dest, Message msg, boolean dont_relay)
Sends the message to a local destination.protected java.lang.Object
deliver(Address next_dest, Message msg, boolean dont_relay, boolean dont_loopback, boolean oob)
void
destroy()
This method is called on aJChannel.close()
.java.lang.Object
down(Message msg)
A message is sent down the stack.protected boolean
handleAdminMessage(RelayHeader hdr, Message msg)
Handles SITES_UP/SITES_DOWN/TOPO_REQ/TOPO_RSP messagesprotected <T> java.lang.Object
handleRelayerStarted(Relayer r, long start, T ignored, java.lang.Throwable t)
protected void
handleRelayMessage(Message msg)
Called to handle a message received from a different site (via a bridge channel)void
handleView(View view)
void
init()
Called after a protocol has been created and before the protocol is started.protected boolean
mustBeRouted(Message msg)
Determines if a message should be routed.protected java.lang.Object
passUp(Message msg)
Sends a message up the stack.java.lang.String
printLocalTopology()
java.lang.String
printTopology(boolean all_sites)
protected java.lang.Object
process(boolean down, Message msg)
This method has all the routing logic, for both site masters and regular membersprotected 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)protected java.lang.Object
routeThen(Message msg, java.util.List<java.lang.String> sites, java.util.function.Supplier<java.lang.Object> action)
protected boolean
sameSite(SiteAddress addr)
protected void
sendMemberUnreachableTo(Address dest, Address member)
Sends a MBR-UNREACHABLE message to the sender of a unicast messageprotected void
sendResponsesForAllSites(Address dest)
protected void
sendResponseTo(Address dest, boolean all_sites)
Returns information about all members of all sites, or only the local members of a given siteprotected void
sendSiteUnreachableTo(Address dest, java.lang.String target_site)
Sends a SITE-UNREACHABLE message to the sender of the message.protected java.lang.Object
sendToLocalSiteMaster(Address sender, Message msg)
SiteStatus
siteStatus()
protected java.util.concurrent.CompletableFuture<Relayer>
startRelayer(Relayer3 rel, java.lang.String bridge_name)
protected void
triggerMemberUnreachableEvent(Address mbr)
protected void
triggerSiteUnreachableEvent(SiteAddress s)
java.lang.Object
up(Message msg)
A single message was received.void
up(MessageBatch batch)
Sends up a multiple messages in aMessageBatch
.-
Methods inherited from class org.jgroups.protocols.relay.RELAY
addSite, addToRelayedTime, asyncRelayCreation, asyncRelayCreation, broadcastRouteNotifications, broadcastRouteNotifications, canBecomeSiteMaster, canBecomeSiteMaster, clearNoRouteCache, config, config, copy, delaySitesDown, delaySitesDown, determineSiteMasters, down, getAvgMsgsForwardingToLocalMbr, getAvgMsgsForwardingToSM, getAvgMsgsRelaying, getBridge, getBridgeView, getConfig, getCurrentSites, getMaxSiteMasters, getNumberOfNoRouteErrors, getNumForwardedToLocalMbr, getNumForwardedToSiteMaster, getNumRelayed, getNumRoutes, getPhysicalAddress, getRoute, getRouteStatusListener, getSite, getSiteMasterPickerImpl, getSiteMastersRatio, getSites, getTimeForwardingToLocalMbr, getTimeForwardingToSM, getTimer, getTimeRelaying, incrementRelayed, isLocal, isLocalSitemaster, isSiteMaster, members, notifySiteMasterListener, parse, parseSiteConfiguration, pickSiteMaster, printRoutes, printSites, resetStats, setConfig, setMaxSiteMasters, setRouteStatusListener, setSite, setSiteMasterListener, setSiteMasterPickerImpl, setSiteMastersRatio, site, site, siteMasterPicker, siteMasters, siteNames, sitesChange, stop, topo, up, view
-
Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, toString
-
-
-
-
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
-
unicast
protected UNICAST3 unicast
-
-
Method Detail
-
siteStatus
public SiteStatus siteStatus()
-
delaySiteUnreachableEvents
public long delaySiteUnreachableEvents()
-
delaySiteUnreachableEvents
public RELAY3 delaySiteUnreachableEvents(long t)
-
configure
public void configure() 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.
-
destroy
public void destroy()
Description copied from class:Protocol
This method is called on aJChannel.close()
. Does some cleanup; after the call, the VM will terminate
-
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.
-
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.
-
up
public void up(MessageBatch batch)
Description copied from class:Protocol
Sends up a multiple messages in aMessageBatch
. 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 (callingProtocol.accept(Message)
), and - if true - callsProtocol.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. usingMessageBatch.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.
-
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 sitedest
- The address to which to send the response
-
sendResponsesForAllSites
protected void sendResponsesForAllSites(Address dest)
-
handleView
public void handleView(View view)
- Specified by:
handleView
in classRELAY
-
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 classRELAY
-
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 classRELAY
-
_triggerSiteUnreachableEvent
protected void _triggerSiteUnreachableEvent(SiteAddress s)
-
triggerMemberUnreachableEvent
protected void triggerMemberUnreachableEvent(Address mbr)
- Overrides:
triggerMemberUnreachableEvent
in classRELAY
-
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 sentsites
- 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, flagMessage.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
-
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 thetarget_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
-
-