Class StaticMembershipProvider
java.lang.Object
org.apache.catalina.tribes.membership.MembershipProviderBase
org.apache.catalina.tribes.membership.StaticMembershipProvider
- All Implemented Interfaces:
ChannelListener, RpcCallback, Heartbeat, MembershipProvider
public class StaticMembershipProvider
extends MembershipProviderBase
implements RpcCallback, ChannelListener, Heartbeat
Provider that manages static membership for a cluster.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMessage sent between membership providers to coordinate membership state.protected classBackground thread that periodically sends ping messages to cluster members. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChannelThe channel associated with this provider.protected intSocket connection timeout in milliseconds.protected longTime in milliseconds after which a member is considered expired.protected longInterval between ping messages in milliseconds.protected RpcChannelRPC channel for sending messages.protected longRPC operation timeout in milliseconds.protected booleanWhether the ping thread is currently running.protected intSend options flag for channel messages.protected static final StringManagerString manager for this class.protected intCurrent start level bitmask.protected ArrayList<StaticMember> List of static members for this cluster.protected StaticMembershipProvider.PingThreadBackground ping thread instance.protected booleanWhether to use a background thread for pinging.Fields inherited from class MembershipProviderBase
executor, membership, membershipListener, service -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccept(Serializable msg, Member sender) Invoked by the channel to determine if the listener will process this message or not.protected voidChecks for and removes expired members.voidHeartbeat invocation for resources cleanup etcvoidinit(Properties properties) Initialize the membership provider with the specified configuration.voidleftOver(Serializable msg, Member sender) If the reply has already been sent to the requesting thread, the rpc callback can handle any data that comes in after the fact.protected voidmemberAdded(Member member) Handles the addition of a new member to the cluster.protected voidmemberAlive(Member member) Updates the alive status of a member.protected voidmemberDisappeared(Member member) Handles the disappearance of a member from the cluster.voidmessageReceived(Serializable msg, Member sender) Receive a message from the channelprotected voidping()Sends ping messages to all static members and checks for expired members.replyRequest(Serializable msg, Member sender) Allows sending a response to a received message.voidsetChannel(Channel channel) Sets the channel for this provider.voidsetStaticMembers(ArrayList<StaticMember> staticMembers) Sets the static members for this cluster.protected MembersetupMember(Member mbr) Sets up a member after it joins.voidstart(int level) Start the membership provider.protected voidstartMembership(Member[] members) Sends start messages to the given members.booleanstop(int level) Stop the membership provider.protected voidstopMembership(Member[] members) Sends stop messages to the given members.Methods inherited from class MembershipProviderBase
getMember, getMembers, hasMembers, setMembershipListener, setMembershipService
-
Field Details
-
sm
String manager for this class. -
channel
The channel associated with this provider. -
rpcChannel
RPC channel for sending messages. -
staticMembers
List of static members for this cluster. -
sendOptions
protected int sendOptionsSend options flag for channel messages. -
expirationTime
protected long expirationTimeTime in milliseconds after which a member is considered expired. -
connectTimeout
protected int connectTimeoutSocket connection timeout in milliseconds. -
rpcTimeout
protected long rpcTimeoutRPC operation timeout in milliseconds. -
startLevel
protected int startLevelCurrent start level bitmask. -
useThread
protected boolean useThreadWhether to use a background thread for pinging. -
pingInterval
protected long pingIntervalInterval between ping messages in milliseconds. -
running
protected volatile boolean runningWhether the ping thread is currently running. -
thread
Background ping thread instance.
-
-
Constructor Details
-
StaticMembershipProvider
public StaticMembershipProvider()Default constructor.
-
-
Method Details
-
init
Description copied from interface:MembershipProviderInitialize the membership provider with the specified configuration.- Specified by:
initin interfaceMembershipProvider- Overrides:
initin classMembershipProviderBase- Parameters:
properties- configuration- Throws:
Exception- if an error occurs
-
start
Description copied from interface:MembershipProviderStart the membership provider.- Specified by:
startin interfaceMembershipProvider- Parameters:
level- the readiness level- Channel.DEFAULT - will start all services
- Channel.MBR_RX_SEQ - starts the membership receiver
- Channel.MBR_TX_SEQ - starts the membership broadcaster
- Throws:
Exception- if an error occurs
-
stop
Description copied from interface:MembershipProviderStop the membership provider.- Specified by:
stopin interfaceMembershipProvider- Parameters:
level- the readiness level- Channel.DEFAULT - will stop all services
- Channel.MBR_RX_SEQ - stops the membership receiver
- Channel.MBR_TX_SEQ - stops the membership broadcaster
- Returns:
trueif successful- Throws:
Exception- if an error occurs
-
startMembership
Sends start messages to the given members.- Parameters:
members- the members to notify- Throws:
ChannelException- if sending fails
-
setupMember
-
memberAdded
Handles the addition of a new member to the cluster.- Parameters:
member- the member that was added
-
memberDisappeared
Handles the disappearance of a member from the cluster.- Parameters:
member- the member that disappeared
-
memberAlive
Updates the alive status of a member.- Parameters:
member- the member to update
-
stopMembership
Sends stop messages to the given members.- Parameters:
members- the members to notify
-
messageReceived
Description copied from interface:ChannelListenerReceive a message from the channel- Specified by:
messageReceivedin interfaceChannelListener- Parameters:
msg- Serializablesender- - the source of the message
-
accept
Description copied from interface:ChannelListenerInvoked by the channel to determine if the listener will process this message or not.- Specified by:
acceptin interfaceChannelListener- Parameters:
msg- Serializablesender- Member- Returns:
- boolean
-
replyRequest
Description copied from interface:RpcCallbackAllows sending a response to a received message.- Specified by:
replyRequestin interfaceRpcCallback- Parameters:
msg- The messagesender- Member- Returns:
- Serializable object,
nullif no reply should be sent
-
leftOver
Description copied from interface:RpcCallbackIf the reply has already been sent to the requesting thread, the rpc callback can handle any data that comes in after the fact.- Specified by:
leftOverin interfaceRpcCallback- Parameters:
msg- The messagesender- Member
-
heartbeat
-
ping
Sends ping messages to all static members and checks for expired members.- Throws:
ChannelException- if pinging fails
-
checkExpired
protected void checkExpired()Checks for and removes expired members. -
setChannel
Sets the channel for this provider.- Parameters:
channel- the channel
-
setStaticMembers
Sets the static members for this cluster.- Parameters:
staticMembers- the list of static members
-