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
public class ChannelCoordinator extends ChannelInterceptorBase implements 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 Modifier and Type Field Description protected static StringManager
sm
-
Fields inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
optionFlag
-
-
Constructor Summary
Constructors Constructor Description ChannelCoordinator()
ChannelCoordinator(ChannelReceiver receiver, ChannelSender sender, MembershipService service)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(ChannelMessage msg)
ChannelReceiver
getClusterReceiver()
ChannelSender
getClusterSender()
Member
getLocalMember(boolean incAlive)
Return the member that represents this node.Member
getMember(Member mbr)
Intercepts theChannel.getMember(Member)
methodMember[]
getMembers()
Get all current cluster membersMembershipService
getMembershipService()
boolean
hasMembers()
has membersvoid
heartbeat()
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
messageReceived(ChannelMessage msg)
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 Detail
-
sm
protected static final StringManager sm
-
-
Constructor Detail
-
ChannelCoordinator
public ChannelCoordinator()
-
ChannelCoordinator
public ChannelCoordinator(ChannelReceiver receiver, ChannelSender sender, MembershipService service)
-
-
Method Detail
-
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:
ErrorHandler
,InterceptorPayload
-
start
public void start(int svc) throws ChannelException
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
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.- See Also:
Channel
-
stop
public void stop(int svc) throws ChannelException
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
DEFAULT - will shutdown all services
MBR_RX_SEQ - stops the membership receiver
MBR_TX_SEQ - stops the membership broadcaster
SND_TX_SEQ - stops the replication transmitter
SND_RX_SEQ - stops the replication receiver- Throws:
ChannelException
- if a startup error occurs or the service is already started.- See Also:
Channel
-
internalStart
protected void internalStart(int svc) throws ChannelException
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
protected void internalStop(int svc) throws ChannelException
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
public void memberAdded(Member member)
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
public void memberDisappeared(Member member)
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:
Member.SHUTDOWN_PAYLOAD
-
messageReceived
public void messageReceived(ChannelMessage msg)
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
public boolean accept(ChannelMessage msg)
- Specified by:
accept
in interfaceMessageListener
-
getClusterReceiver
public ChannelReceiver getClusterReceiver()
-
getClusterSender
public ChannelSender getClusterSender()
-
getMembershipService
public MembershipService getMembershipService()
-
setClusterReceiver
public void setClusterReceiver(ChannelReceiver clusterReceiver)
-
setClusterSender
public void setClusterSender(ChannelSender clusterSender)
-
setMembershipService
public void setMembershipService(MembershipService membershipService)
-
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()
has members- Specified by:
hasMembers
in interfaceChannelInterceptor
- Overrides:
hasMembers
in classChannelInterceptorBase
- Returns:
- boolean - if the channel has members in its membership group
- See Also:
Channel.hasMembers()
-
getMembers
public Member[] getMembers()
Get all current cluster members- Specified by:
getMembers
in interfaceChannelInterceptor
- Overrides:
getMembers
in classChannelInterceptorBase
- Returns:
- all members or empty array
- See Also:
Channel.getMembers()
-
getMember
public Member getMember(Member mbr)
Description copied from interface:ChannelInterceptor
Intercepts theChannel.getMember(Member)
method- Specified by:
getMember
in interfaceChannelInterceptor
- Overrides:
getMember
in classChannelInterceptorBase
- Parameters:
mbr
- Member- Returns:
- Member
- See Also:
Channel.getMember(Member)
-
getLocalMember
public Member getLocalMember(boolean incAlive)
Return the member that represents this node.- Specified by:
getLocalMember
in interfaceChannelInterceptor
- Overrides:
getLocalMember
in classChannelInterceptorBase
- Parameters:
incAlive
- boolean- Returns:
- Member
- See Also:
Channel.getLocalMember(boolean)
-
-