Package org.apache.catalina.tribes.group
Class ChannelCoordinator
java.lang.Object
org.apache.catalina.tribes.group.ChannelInterceptorBase
org.apache.catalina.tribes.group.ChannelCoordinator
- All Implemented Interfaces:
ChannelInterceptor
,Heartbeat
,MembershipListener
,MessageListener
The channel coordinator object coordinates the membership service, the sender and the receiver. This is the last
interceptor in the chain.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.catalina.tribes.ChannelInterceptor
ChannelInterceptor.InterceptorEvent
-
Field Summary
Fields inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
optionFlag
-
Constructor Summary
ConstructorDescriptionChannelCoordinator
(ChannelReceiver receiver, ChannelSender sender, MembershipService service) -
Method Summary
Modifier and TypeMethodDescriptionboolean
accept
(ChannelMessage msg) Allows skipping processing of the specified message.getLocalMember
(boolean incAlive) Intercepts theChannel.getLocalMember(boolean)
methodIntercepts theChannel.getMember(Member)
methodMember[]
Intercepts theChannel.getMembers()
methodboolean
Intercepts theChannel.hasMembers()
methodvoid
Theheartbeat()
method gets invoked periodically to allow interceptors to clean up resources, time out object and perform actions that are unrelated to sending/receiving data.protected void
internalStart
(int svc) Starts up the channel.protected void
internalStop
(int svc) Shuts down the channel.void
memberAdded
(Member member) A member was added to the groupvoid
memberDisappeared
(Member member) A member was removed from the group
If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD datavoid
themessageReceived
is invoked when a message is received.void
sendMessage
(Member[] destination, ChannelMessage msg, InterceptorPayload payload) Send a message to one or more members in the clustervoid
setClusterReceiver
(ChannelReceiver clusterReceiver) void
setClusterSender
(ChannelSender clusterSender) void
setMembershipService
(MembershipService membershipService) void
start
(int svc) Starts up the channel.void
stop
(int svc) Shuts down the channel.Methods inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
fireInterceptorEvent, getChannel, getNext, getOptionFlag, getPrevious, okToProcess, setChannel, setNext, setOptionFlag, setPrevious
-
Field Details
-
sm
-
-
Constructor Details
-
ChannelCoordinator
public ChannelCoordinator() -
ChannelCoordinator
public ChannelCoordinator(ChannelReceiver receiver, ChannelSender sender, MembershipService service)
-
-
Method Details
-
sendMessage
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException Send a message to one or more members in the cluster- Specified by:
sendMessage
in interfaceChannelInterceptor
- Overrides:
sendMessage
in classChannelInterceptorBase
- Parameters:
destination
- Member[] - the destinations, null or zero length means allmsg
- ClusterMessage - the message to sendpayload
- TBA- Throws:
ChannelException
- if a serialization error happens.- See Also:
-
start
Description copied from interface:ChannelInterceptor
Starts up the channel. This can be called multiple times for individual services to start The svc parameter can be the logical or value of any constants- Specified by:
start
in interfaceChannelInterceptor
- Overrides:
start
in classChannelInterceptorBase
- Parameters:
svc
- int value of
Channel.DEFAULT - will start all services
Channel.MBR_RX_SEQ - starts the membership receiver
Channel.MBR_TX_SEQ - starts the membership broadcaster
Channel.SND_TX_SEQ - starts the replication transmitter
Channel.SND_RX_SEQ - starts the replication receiver- Throws:
ChannelException
- if a startup error occurs or the service is already started.- See Also:
-
stop
Description copied from interface:ChannelInterceptor
Shuts down the channel. This can be called multiple times for individual services to shutdown The svc parameter can be the logical or value of any constants- Specified by:
stop
in interfaceChannelInterceptor
- Overrides:
stop
in classChannelInterceptorBase
- Parameters:
svc
- int value of
Channel.DEFAULT - will shutdown all services
Channel.MBR_RX_SEQ - stops the membership receiver
Channel.MBR_TX_SEQ - stops the membership broadcaster
Channel.SND_TX_SEQ - stops the replication transmitter
Channel.SND_RX_SEQ - stops the replication receiver- Throws:
ChannelException
- if a startup error occurs or the service is already started.- See Also:
-
internalStart
Starts up the channel. This can be called multiple times for individual services to start The svc parameter can be the logical or value of any constants- Parameters:
svc
- int value of
DEFAULT - will start all services
MBR_RX_SEQ - starts the membership receiver
MBR_TX_SEQ - starts the membership broadcaster
SND_TX_SEQ - starts the replication transmitter
SND_RX_SEQ - starts the replication receiver- Throws:
ChannelException
- if a startup error occurs or the service is already started.
-
internalStop
Shuts down the channel. This can be called multiple times for individual services to shutdown The svc parameter can be the logical or value of any constants- Parameters:
svc
- int value of
DEFAULT - will shutdown all services
MBR_RX_SEQ - starts the membership receiver
MBR_TX_SEQ - starts the membership broadcaster
SND_TX_SEQ - starts the replication transmitter
SND_RX_SEQ - starts the replication receiver- Throws:
ChannelException
- if a startup error occurs or the service is already started.
-
memberAdded
Description copied from interface:MembershipListener
A member was added to the group- Specified by:
memberAdded
in interfaceMembershipListener
- Overrides:
memberAdded
in classChannelInterceptorBase
- Parameters:
member
- Member - the member that was added
-
memberDisappeared
Description copied from interface:MembershipListener
A member was removed from the group
If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD data- Specified by:
memberDisappeared
in interfaceMembershipListener
- Overrides:
memberDisappeared
in classChannelInterceptorBase
- Parameters:
member
- Member- See Also:
-
messageReceived
Description copied from interface:ChannelInterceptor
themessageReceived
is invoked when a message is received.ChannelMessage.getAddress()
is the sender, or the reply-to address if it has been overwritten.- Specified by:
messageReceived
in interfaceChannelInterceptor
- Specified by:
messageReceived
in interfaceMessageListener
- Overrides:
messageReceived
in classChannelInterceptorBase
- Parameters:
msg
- ChannelMessage
-
accept
Description copied from interface:MessageListener
Allows skipping processing of the specified message.- Specified by:
accept
in interfaceMessageListener
- Parameters:
msg
- the message- Returns:
true
if the message will be processed
-
getClusterReceiver
-
getClusterSender
-
getMembershipService
-
setClusterReceiver
-
setClusterSender
-
setMembershipService
-
heartbeat
public void heartbeat()Description copied from interface:ChannelInterceptor
Theheartbeat()
method gets invoked periodically to allow interceptors to clean up resources, time out object and perform actions that are unrelated to sending/receiving data.- Specified by:
heartbeat
in interfaceChannelInterceptor
- Specified by:
heartbeat
in interfaceHeartbeat
- Overrides:
heartbeat
in classChannelInterceptorBase
-
hasMembers
public boolean hasMembers()Description copied from interface:ChannelInterceptor
Intercepts theChannel.hasMembers()
method- Specified by:
hasMembers
in interfaceChannelInterceptor
- Overrides:
hasMembers
in classChannelInterceptorBase
- Returns:
- boolean - if the channel has members in its membership group
- See Also:
-
getMembers
Description copied from interface:ChannelInterceptor
Intercepts theChannel.getMembers()
method- Specified by:
getMembers
in interfaceChannelInterceptor
- Overrides:
getMembers
in classChannelInterceptorBase
- Returns:
- the members
- See Also:
-
getMember
Description copied from interface:ChannelInterceptor
Intercepts theChannel.getMember(Member)
method- Specified by:
getMember
in interfaceChannelInterceptor
- Overrides:
getMember
in classChannelInterceptorBase
- Parameters:
mbr
- Member- Returns:
- Member - the actual member information, including stay alive
- See Also:
-
getLocalMember
Description copied from interface:ChannelInterceptor
Intercepts theChannel.getLocalMember(boolean)
method- Specified by:
getLocalMember
in interfaceChannelInterceptor
- Overrides:
getLocalMember
in classChannelInterceptorBase
- Parameters:
incAlive
- boolean- Returns:
- the member that represents this node
- See Also:
-