Package org.jgroups.protocols
Class RELAY
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.RELAY
Simple relaying protocol: RELAY is added to the top of the stack, creates a channel to a bridge cluster,
and - if coordinator - relays all multicast messages via the bridge cluster to the remote cluster.
This is not a big virtual cluster, e.g. consisting of {A,B,C,X,Y,Z}, but 2 autonomous clusters
{A,B,C} and {X,Y,Z}, bridged together by RELAY. For example, when B multicasts a message M, A (if it happens to be
the coord) relays M to X (which happens to be the other cluster's coordinator). X then re-broadcasts M, with M.src
being a ProxyUUID(X,B). This means that the sender of M in the {X,Y,Z} cluster will be X for all practical purposes,
but the original sender B is also recorded, for sending back a response.
See [1] and [2] for details.
[1] https://jira.jboss.org/browse/JGRP-747
[2] doc/design/RELAY.txt
- Since:
- 2.12
- Author:
- Bela Ban
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classstatic classprotected classprotected static classContains local and remote views, and UUID information -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JChannelThe bridge between the two local clusters, usually based on a TCP configprotected Stringprotected Stringprotected ViewThe view of the bridge cluster, usually consists of max 2 nodesprotected Addressprotected ViewThe combined view of local and remote clusterprotected longTo generate new global viewsprotected booleanprotected Addressprotected ViewThe view of the local clusterprotected booleanprotected booleanprotected ViewThe view of the remote clusterprotected Future<?> protected Stringprotected TimeScheduler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAn event is to be sent down the stack.protected voidforward(byte[] buffer, int offset, int length) Forwards the message across the TCP link to the other local clusterprotected voidforwardToCoord(Message msg) Wraps the message annd sends it to the current coordinatorprotected ViewgenerateGlobalView(View local_view, View remote_view) protected ViewgenerateGlobalView(View local_view, View remote_view, boolean merge) protected voidhandleView(View view) voidinit()Called after instance has been created (null constructor) and before protocol is started.protected ObjectinstallView(byte[] buf, int offset, int length) protected booleanDoes the payload match the 'site' ID.protected voidsendOnLocalCluster(byte[] buf, int offset, int length) protected voidsendViewOnLocalCluster(Address dest, RELAY.ViewData data, boolean use_seperate_thread) protected voidsendViewOnLocalCluster(Address dest, View remote_view, View global_view, boolean use_seperate_thread) protected voidsendViewToRemote(RELAY.ViewData view_data, boolean use_seperate_thread) voidsetRelay(boolean relay) protected voidvoidstop()This method is called on aChannel.disconnect().protected voidAn event was received from the layer below.Methods inherited from class org.jgroups.stack.Protocol
destroy, downThreadEnabled, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProperties, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getValue, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setPropertiesInternal, setProperty, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, upThreadEnabled
-
Field Details
-
site
-
bridge_props
-
bridge_name
-
relay
protected boolean relay -
present_global_views
protected boolean present_global_views -
local_addr
-
is_coord
protected volatile boolean is_coord -
coord
-
bridge
The bridge between the two local clusters, usually based on a TCP config -
local_view
The view of the local cluster -
bridge_view
The view of the bridge cluster, usually consists of max 2 nodes -
remote_view
The view of the remote cluster -
global_view
The combined view of local and remote cluster -
global_view_id
protected long global_view_idTo generate new global views -
timer
-
remote_view_fetcher_future
-
-
Constructor Details
-
RELAY
public RELAY()
-
-
Method Details
-
setRelay
public void setRelay(boolean relay) -
getLocalView
-
getBridgeView
-
getRemoteView
-
getGlobalView
-
init
Description copied from class:ProtocolCalled after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent. -
stop
public void stop()Description copied from class:ProtocolThis method is called on aChannel.disconnect(). Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed -
down
Description copied from class:ProtocolAn event is to be sent down the stack. The layer 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 layer may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_prot.down(). In case of a GET_ADDRESS event (which tries to retrieve the stack's address from one of the bottom layers), the layer may need to send a new response event back up the stack usingup_prot.up(). -
up
Description copied from class:ProtocolAn event was received from the layer below. Usually the current layer 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 usingdown_prot.down()or c) the event (or another event) is sent up the stack usingup_prot.up(). -
handleView
-
installView
-
forward
protected void forward(byte[] buffer, int offset, int length) Forwards the message across the TCP link to the other local cluster -
forwardToCoord
Wraps the message annd sends it to the current coordinator -
sendViewToRemote
-
generateGlobalView
-
generateGlobalView
-
createBridge
protected void createBridge() -
sendOnLocalCluster
protected void sendOnLocalCluster(byte[] buf, int offset, int length) -
sendViewOnLocalCluster
-
sendViewOnLocalCluster
protected void sendViewOnLocalCluster(Address dest, RELAY.ViewData data, boolean use_seperate_thread) -
isLocal
Does the payload match the 'site' ID. Checks only unicast destinations (multicast destinations return true) -
startRemoteViewFetcher
protected void startRemoteViewFetcher() -
stopRemoteViewFetcher
protected void stopRemoteViewFetcher()
-