Package org.jgroups.protocols.relay
Class RELAY
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.relay.RELAY
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
async_relay_creation
protected boolean
broadcast_route_notifications
protected boolean
can_become_site_master
static short
can_become_site_master_flag
protected java.lang.String
config
protected boolean
delay_sites_down
protected java.util.concurrent.atomic.LongAdder
forward_sm_time
protected java.util.concurrent.atomic.LongAdder
forward_to_local_mbr
Number of messages (received from a remote Sitemaster and) delivered by the local SiteMaster to a local nodeprotected java.util.concurrent.atomic.LongAdder
forward_to_local_mbr_time
protected java.util.concurrent.atomic.LongAdder
forward_to_site_master
Number of messages forwarded to the local SiteMasterprotected boolean
is_site_master
protected int
max_site_masters
protected java.util.List<Address>
members
protected short[]
prots_above
protected java.util.concurrent.atomic.LongAdder
relayed
Number of messages relayed by the local SiteMaster to a remote SiteMasterprotected java.util.concurrent.atomic.LongAdder
relayed_time
Total time spent relaying messages from the local SiteMaster to remote SiteMasters (in ns)protected Relayer
relayer
protected RouteStatusListener
route_status_listener
protected java.lang.String
site
protected RelayConfig.SiteConfig
site_config
protected java.util.function.Consumer<java.lang.Boolean>
site_master_listener
Listens for notifications about becoming site master (arg: true), or ceasing to be site master (arg: false)protected SiteMasterPicker
site_master_picker
protected java.lang.String
site_master_picker_impl
protected java.util.List<Address>
site_masters
protected double
site_masters_ratio
protected java.util.Map<java.lang.String,RelayConfig.SiteConfig>
sites
A map containing site names (e.g.protected SuppressLog<java.lang.String>
suppress_log_no_route
Log to suppress identical errors for messages to non-existing sites ('no route to site X')protected long
suppress_time_no_route_errors
protected TimeScheduler
timer
protected Topology
topo
protected View
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 RELAY()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T extends RELAY>
TaddSite(java.lang.String n, RelayConfig.SiteConfig cfg)
void
addToRelayedTime(long d)
boolean
asyncRelayCreation()
<T extends RELAY>
TasyncRelayCreation(boolean flag)
boolean
broadcastRouteNotifications()
<T extends RELAY>
TbroadcastRouteNotifications(boolean b)
boolean
canBecomeSiteMaster()
<T extends RELAY>
TcanBecomeSiteMaster(boolean f)
<T extends RELAY>
TclearNoRouteCache()
java.lang.String
config()
<T extends RELAY>
Tconfig(java.lang.String cfg)
void
configure()
protected Message
copy(Message msg)
Copies the message, but only the headers above the current protocol (RELAY) (or RpcDispatcher related headers)boolean
delaySitesDown()
<T extends RELAY>
TdelaySitesDown(boolean b)
protected static java.util.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.java.lang.Object
down(Event evt)
An event is to be sent down the stack.long
getAvgMsgsForwardingToLocalMbr()
long
getAvgMsgsForwardingToSM()
long
getAvgMsgsRelaying()
JChannel
getBridge(java.lang.String site_name)
Returns the bridge channel to a given siteView
getBridgeView(java.lang.String cluster_name)
java.lang.String
getConfig()
java.util.List<java.lang.String>
getCurrentSites()
int
getMaxSiteMasters()
int
getNumberOfNoRouteErrors()
long
getNumForwardedToLocalMbr()
long
getNumForwardedToSiteMaster()
long
getNumRelayed()
int
getNumRoutes()
protected PhysicalAddress
getPhysicalAddress(Address mbr)
Route
getRoute(java.lang.String site_name)
Returns the route to a given siteRouteStatusListener
getRouteStatusListener()
java.lang.String
getSite()
java.lang.String
getSiteMasterPickerImpl()
double
getSiteMastersRatio()
java.util.List<java.lang.String>
getSites()
long
getTimeForwardingToLocalMbr()
long
getTimeForwardingToSM()
TimeScheduler
getTimer()
long
getTimeRelaying()
protected abstract void
handleRelayMessage(Message msg)
abstract void
handleView(View v)
void
incrementRelayed()
void
init()
Called after a protocol has been created and before the protocol is started.protected boolean
isLocal(SiteAddress addr)
protected boolean
isLocalSitemaster(SiteAddress addr)
boolean
isSiteMaster()
java.util.List<Address>
members()
protected void
notifySiteMasterListener(boolean flag)
void
parse(XmlNode node)
Called by the XML parser when subelements are found in the configuration of a protocol.protected void
parseSiteConfiguration(java.util.Map<java.lang.String,RelayConfig.SiteConfig> map)
Parses the configuration by reading the config fileprotected Address
pickSiteMaster(Address sender)
Returns a site master from site_mastersjava.lang.String
printRoutes()
java.lang.String
printSites()
void
resetStats()
<T extends RELAY>
TsetConfig(java.lang.String c)
<T extends RELAY>
TsetMaxSiteMasters(int m)
void
setRouteStatusListener(RouteStatusListener l)
<T extends RELAY>
TsetSite(java.lang.String s)
<T extends RELAY>
TsetSiteMasterListener(java.util.function.Consumer<java.lang.Boolean> l)
<T extends RELAY>
TsetSiteMasterPickerImpl(java.lang.String s)
<T extends RELAY>
TsetSiteMastersRatio(double r)
java.lang.String
site()
<T extends RELAY>
Tsite(java.lang.String s)
<T extends RELAY>
TsiteMasterPicker(SiteMasterPicker s)
java.util.List<Address>
siteMasters()
java.util.List<java.lang.String>
siteNames()
protected void
sitesChange(boolean down, java.util.Set<java.lang.String> sites)
void
stop()
Called on aJChannel.disconnect()
; stops work (e.g.Topology
topo()
protected void
triggerMemberUnreachableEvent(Address mbr)
protected void
triggerSiteUnreachableEvent(SiteAddress remoteSite)
java.lang.Object
up(Event evt)
An event was received from the protocol below.View
view()
-
Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, 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, up, up
-
-
-
-
Field Detail
-
can_become_site_master_flag
public static final short can_become_site_master_flag
- See Also:
- Constant Field Values
-
site
protected java.lang.String site
-
config
protected java.lang.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 java.lang.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 java.util.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 java.util.concurrent.atomic.LongAdder forward_to_site_master
Number of messages forwarded to the local SiteMaster
-
forward_sm_time
protected final java.util.concurrent.atomic.LongAdder forward_sm_time
-
relayed
protected final java.util.concurrent.atomic.LongAdder relayed
Number of messages relayed by the local SiteMaster to a remote SiteMaster
-
relayed_time
protected final java.util.concurrent.atomic.LongAdder relayed_time
Total time spent relaying messages from the local SiteMaster to remote SiteMasters (in ns)
-
forward_to_local_mbr
protected final java.util.concurrent.atomic.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 java.util.concurrent.atomic.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 java.util.List<Address> members
-
route_status_listener
protected volatile RouteStatusListener route_status_listener
-
site_master_listener
protected java.util.function.Consumer<java.lang.Boolean> site_master_listener
Listens for notifications about becoming site master (arg: true), or ceasing to be site master (arg: false)
-
sites
protected final java.util.Map<java.lang.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<java.lang.String> suppress_log_no_route
Log to suppress identical errors for messages to non-existing sites ('no route to site X')
-
-
Method Detail
-
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 java.lang.String getSite()
-
site
public java.lang.String site()
-
setSite
public <T extends RELAY> T setSite(java.lang.String s)
-
site
public <T extends RELAY> T site(java.lang.String s)
-
topo
public Topology topo()
-
view
public View view()
-
members
public java.util.List<Address> members()
-
config
public java.lang.String config()
-
config
public <T extends RELAY> T config(java.lang.String cfg)
-
getConfig
public java.lang.String getConfig()
-
setConfig
public <T extends RELAY> T setConfig(java.lang.String c)
-
getTimer
public TimeScheduler getTimer()
-
incrementRelayed
public void incrementRelayed()
-
addToRelayedTime
public void addToRelayedTime(long d)
-
siteMasters
public java.util.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 java.lang.String getSiteMasterPickerImpl()
-
setSiteMasterPickerImpl
public <T extends RELAY> T setSiteMasterPickerImpl(java.lang.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(java.util.function.Consumer<java.lang.Boolean> l)
-
addSite
public <T extends RELAY> T addSite(java.lang.String n, RelayConfig.SiteConfig cfg)
-
siteNames
public java.util.List<java.lang.String> siteNames()
-
isSiteMaster
public boolean isSiteMaster()
-
getSites
public java.util.List<java.lang.String> getSites()
-
printSites
public java.lang.String printSites()
-
getNumRoutes
public int getNumRoutes()
-
printRoutes
public java.lang.String printRoutes()
-
getRoute
public Route getRoute(java.lang.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 java.util.List<java.lang.String> getCurrentSites()
- Returns:
- A
List
of sites name that are currently up ornull
if this node is not a Site Master (i.e.isSiteMaster()
returns false).
-
getBridge
public JChannel getBridge(java.lang.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(java.lang.String cluster_name)
-
resetStats
public void resetStats()
- Overrides:
resetStats
in classProtocol
-
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.
-
stop
public void stop()
Description copied from class:Protocol
Called on aJChannel.disconnect()
; stops work (e.g. by closing multicast socket). Will be called from top to bottom.
-
configure
public void configure() throws java.lang.Exception
- Throws:
java.lang.Exception
-
parse
public void parse(XmlNode node) throws java.lang.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
-
down
public java.lang.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 usingdown_prot.down()
.
-
up
public java.lang.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 usingdown_prot.down()
or c) the event (or another event) is sent up the stack usingup_prot.up()
.
-
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(java.util.Map<java.lang.String,RelayConfig.SiteConfig> map) throws java.lang.Exception
Parses the configuration by reading the config file- Throws:
java.lang.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, java.util.Set<java.lang.String> sites)
-
notifySiteMasterListener
protected void notifySiteMasterListener(boolean flag)
-
getPhysicalAddress
protected PhysicalAddress getPhysicalAddress(Address mbr)
-
determineSiteMasters
protected static java.util.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)
-
-