Class SimpleCoordinator
- java.lang.Object
-
- org.apache.catalina.tribes.group.ChannelInterceptorBase
-
- org.apache.catalina.tribes.group.interceptors.SimpleCoordinator
-
- All Implemented Interfaces:
ChannelInterceptor,Heartbeat,MembershipListener
public class SimpleCoordinator extends ChannelInterceptorBase
A dinky coordinator, just uses a sorted version of the member array.
-
-
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
Constructors Constructor Description SimpleCoordinator()Creates a new SimpleCoordinator instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MembergetCoordinator()Returns the current coordinator member (first member in the sorted view).Member[]getView()Returns the current sorted view of cluster members.booleanisCoordinator()Returns whether this member is the current coordinator.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 datavoidstart(int svc)Starts up the channel.voidstop(int svc)Shuts down the channel.protected voidviewChange(Member[] view)Override to receive view changes.-
Methods inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
fireInterceptorEvent, getChannel, getLocalMember, getMember, getMembers, getNext, getOptionFlag, getPrevious, hasMembers, heartbeat, messageReceived, okToProcess, sendMessage, setChannel, setNext, setOptionFlag, setPrevious
-
-
-
-
Method Detail
-
memberAdded
public void memberAdded(Member member)
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
public void memberDisappeared(Member member)
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:
Member.SHUTDOWN_PAYLOAD
-
viewChange
protected void viewChange(Member[] view)
Override to receive view changes.- Parameters:
view- The members array
-
start
public void start(int svc) throws ChannelExceptionDescription 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- one 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:
Channel
-
stop
public void stop(int svc) throws ChannelExceptionDescription copied from interface:ChannelInterceptorShuts down the channel. This can be called multiple times for individual services to shut down. The svc parameter can be the logical or value of any constants- Specified by:
stopin interfaceChannelInterceptor- Overrides:
stopin classChannelInterceptorBase- Parameters:
svc- one of:- Channel.DEFAULT - will shut down 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:
Channel
-
getView
public Member[] getView()
Returns the current sorted view of cluster members.- Returns:
- the current member view, or
nullif not yet established
-
getCoordinator
public Member getCoordinator()
Returns the current coordinator member (first member in the sorted view).- Returns:
- the coordinator member, or
nullif no view is established
-
isCoordinator
public boolean isCoordinator()
Returns whether this member is the current coordinator.- Returns:
trueif this member is the coordinator
-
-