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
FieldsFields inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
optionFlag -
Constructor Summary
ConstructorsConstructorDescriptionChannelCoordinator(ChannelReceiver receiver, ChannelSender sender, MembershipService service) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccept(ChannelMessage msg) Allows skipping processing of the specified message.getLocalMember(boolean incAlive) Intercepts theChannel.getLocalMember(boolean)methodIntercepts theChannel.getMember(Member)methodMember[]Intercepts theChannel.getMembers()methodbooleanIntercepts theChannel.hasMembers()methodvoidTheheartbeat()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 voidinternalStart(int svc) Starts up the channel.protected voidinternalStop(int svc) Shuts down the channel.voidmemberAdded(Member member) A member was added to the groupvoidmemberDisappeared(Member member) A member was removed from the group
If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD datavoidthemessageReceivedis invoked when a message is received.voidsendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) Send a message to one or more members in the clustervoidsetClusterReceiver(ChannelReceiver clusterReceiver) voidsetClusterSender(ChannelSender clusterSender) voidsetMembershipService(MembershipService membershipService) voidstart(int svc) Starts up the channel.voidstop(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:
sendMessagein interfaceChannelInterceptor- Overrides:
sendMessagein 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:ChannelInterceptorStarts 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:
startin interfaceChannelInterceptor- Overrides:
startin 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:ChannelInterceptorShuts 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:
stopin interfaceChannelInterceptor- Overrides:
stopin 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:MembershipListenerA member was added to the group- Specified by:
memberAddedin interfaceMembershipListener- Overrides:
memberAddedin classChannelInterceptorBase- Parameters:
member- Member - the member that was added
-
memberDisappeared
Description copied from interface:MembershipListenerA member was removed from the group
If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD data- Specified by:
memberDisappearedin interfaceMembershipListener- Overrides:
memberDisappearedin classChannelInterceptorBase- Parameters:
member- Member- See Also:
-
messageReceived
Description copied from interface:ChannelInterceptorthemessageReceivedis invoked when a message is received.ChannelMessage.getAddress()is the sender, or the reply-to address if it has been overwritten.- Specified by:
messageReceivedin interfaceChannelInterceptor- Specified by:
messageReceivedin interfaceMessageListener- Overrides:
messageReceivedin classChannelInterceptorBase- Parameters:
msg- ChannelMessage
-
accept
Description copied from interface:MessageListenerAllows skipping processing of the specified message.- Specified by:
acceptin interfaceMessageListener- Parameters:
msg- the message- Returns:
trueif the message will be processed
-
getClusterReceiver
-
getClusterSender
-
getMembershipService
-
setClusterReceiver
-
setClusterSender
-
setMembershipService
-
heartbeat
public void heartbeat()Description copied from interface:ChannelInterceptorTheheartbeat()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:
heartbeatin interfaceChannelInterceptor- Specified by:
heartbeatin interfaceHeartbeat- Overrides:
heartbeatin classChannelInterceptorBase
-
hasMembers
public boolean hasMembers()Description copied from interface:ChannelInterceptorIntercepts theChannel.hasMembers()method- Specified by:
hasMembersin interfaceChannelInterceptor- Overrides:
hasMembersin classChannelInterceptorBase- Returns:
- boolean - if the channel has members in its membership group
- See Also:
-
getMembers
Description copied from interface:ChannelInterceptorIntercepts theChannel.getMembers()method- Specified by:
getMembersin interfaceChannelInterceptor- Overrides:
getMembersin classChannelInterceptorBase- Returns:
- the members
- See Also:
-
getMember
Description copied from interface:ChannelInterceptorIntercepts theChannel.getMember(Member)method- Specified by:
getMemberin interfaceChannelInterceptor- Overrides:
getMemberin classChannelInterceptorBase- Parameters:
mbr- Member- Returns:
- Member - the actual member information, including stay alive
- See Also:
-
getLocalMember
Description copied from interface:ChannelInterceptorIntercepts theChannel.getLocalMember(boolean)method- Specified by:
getLocalMemberin interfaceChannelInterceptor- Overrides:
getLocalMemberin classChannelInterceptorBase- Parameters:
incAlive- boolean- Returns:
- the member that represents this node
- See Also:
-