Class TcpFailureDetector
java.lang.Object
org.apache.catalina.tribes.group.ChannelInterceptorBase
org.apache.catalina.tribes.group.interceptors.TcpFailureDetector
- All Implemented Interfaces:
- ChannelInterceptor,- TcpFailureDetectorMBean,- Heartbeat,- MembershipListener
The TcpFailureDetector is a useful interceptor that adds reliability to the
 membership layer.
 
If the network is busy, or the system is busy so that the membership receiver thread is not getting enough time to update its table, members can be "timed out" This failure detector will intercept the memberDisappeared message(unless its a true shutdown message) and connect to the member using TCP.
The TcpFailureDetector works in two ways:
- It intercepts memberDisappeared events
- It catches send errors
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.apache.catalina.tribes.ChannelInterceptorChannelInterceptor.InterceptorEvent
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected longprotected Membershipprotected booleanprotected booleanprotected longprotected intprotected static final StringManagerprotected static final byte[]Fields inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBaseoptionFlag
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidcheckMembers(boolean checkAll) longgetLocalMember(boolean incAlive) Return the member that represents this node.Intercepts theChannel.getMember(Member)methodMember[]Get all current cluster membersbooleanbooleanlongintbooleanhas membersvoidTheheartbeat()method gets invoked periodically to allow interceptors to clean up resources, time out object and perform actions that are unrelated to sending/receiving data.voidmemberAdded(Member member) A member was added to the groupprotected booleanmemberAlive(Member mbr) protected booleanmemberAlive(Member mbr, byte[] msgData, boolean sendTest, boolean readTest, long readTimeout, long conTimeout, int optionFlag) voidmemberDisappeared(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.protected voidprotected voidvoidsendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) ThesendMessagemethod is called when a message is being sent to one more destinations.voidsetConnectTimeout(long connectTimeout) voidsetPerformReadTest(boolean performReadTest) voidsetPerformSendTest(boolean performSendTest) voidsetReadTestTimeout(long readTestTimeout) voidsetRemoveSuspectsTimeout(int removeSuspectsTimeout) protected voidMethods inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBasefireInterceptorEvent, getChannel, getNext, getOptionFlag, getPrevious, okToProcess, setChannel, setNext, setOptionFlag, setPrevious, start, stopMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.catalina.tribes.group.interceptors.TcpFailureDetectorMBeangetOptionFlag
- 
Field Details- 
sm
- 
TCP_FAIL_DETECTprotected static final byte[] TCP_FAIL_DETECT
- 
connectTimeoutprotected long connectTimeout
- 
performSendTestprotected boolean performSendTest
- 
performReadTestprotected boolean performReadTest
- 
readTestTimeoutprotected long readTestTimeout
- 
membership
- 
removeSuspects
- 
addSuspects
- 
removeSuspectsTimeoutprotected int removeSuspectsTimeout
 
- 
- 
Constructor Details- 
TcpFailureDetectorpublic TcpFailureDetector()
 
- 
- 
Method Details- 
sendMessagepublic void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException Description copied from interface:ChannelInterceptorThesendMessagemethod is called when a message is being sent to one more destinations. The interceptor can modify any of the parameters and then pass on the message down the stack by invokinggetNext().sendMessage(destination,msg,payload)
 Alternatively the interceptor can stop the message from being sent by not invokinggetNext().sendMessage(destination,msg,payload)
 If the message is to be sent asynchronous the application can be notified of completion and errors by passing in an error handler attached to a payload object.
 The ChannelMessage.getAddress contains Channel.getLocalMember, and can be overwritten to simulate a message sent from another node.- Specified by:
- sendMessagein interface- ChannelInterceptor
- Overrides:
- sendMessagein class- ChannelInterceptorBase
- Parameters:
- destination- Member[] - the destination for this message
- msg- ChannelMessage - the message to be sent
- payload- InterceptorPayload - the payload, carrying an error handler and future useful data, can be null
- Throws:
- ChannelException- if a serialization error happens.
- See Also:
 
- 
messageReceivedDescription 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 interface- ChannelInterceptor
- Overrides:
- messageReceivedin class- ChannelInterceptorBase
- Parameters:
- msg- ChannelMessage
 
- 
memberAddedDescription copied from interface:MembershipListenerA member was added to the group- Specified by:
- memberAddedin interface- MembershipListener
- Overrides:
- memberAddedin class- ChannelInterceptorBase
- Parameters:
- member- Member - the member that was added
 
- 
memberDisappearedDescription 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 interface- MembershipListener
- Overrides:
- memberDisappearedin class- ChannelInterceptorBase
- Parameters:
- member- Member
- See Also:
 
- 
hasMemberspublic boolean hasMembers()Description copied from class:ChannelInterceptorBasehas members- Specified by:
- hasMembersin interface- ChannelInterceptor
- Overrides:
- hasMembersin class- ChannelInterceptorBase
- Returns:
- boolean - if the channel has members in its membership group
- See Also:
 
- 
getMembersDescription copied from class:ChannelInterceptorBaseGet all current cluster members- Specified by:
- getMembersin interface- ChannelInterceptor
- Overrides:
- getMembersin class- ChannelInterceptorBase
- Returns:
- all members or empty array
- See Also:
 
- 
getMemberDescription copied from interface:ChannelInterceptorIntercepts theChannel.getMember(Member)method- Specified by:
- getMemberin interface- ChannelInterceptor
- Overrides:
- getMemberin class- ChannelInterceptorBase
- Parameters:
- mbr- Member
- Returns:
- Member
- See Also:
 
- 
getLocalMemberDescription copied from class:ChannelInterceptorBaseReturn the member that represents this node.- Specified by:
- getLocalMemberin interface- ChannelInterceptor
- Overrides:
- getLocalMemberin class- ChannelInterceptorBase
- Parameters:
- incAlive- boolean
- Returns:
- Member
- See Also:
 
- 
heartbeatpublic 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 interface- ChannelInterceptor
- Specified by:
- heartbeatin interface- Heartbeat
- Overrides:
- heartbeatin class- ChannelInterceptorBase
 
- 
checkMemberspublic void checkMembers(boolean checkAll) - Specified by:
- checkMembersin interface- TcpFailureDetectorMBean
 
- 
performForcedCheckprotected void performForcedCheck()
- 
performBasicCheckprotected void performBasicCheck()
- 
setupMembershipprotected void setupMembership()
- 
memberAlive
- 
memberAliveprotected boolean memberAlive(Member mbr, byte[] msgData, boolean sendTest, boolean readTest, long readTimeout, long conTimeout, int optionFlag) 
- 
getReadTestTimeoutpublic long getReadTestTimeout()- Specified by:
- getReadTestTimeoutin interface- TcpFailureDetectorMBean
 
- 
getPerformSendTestpublic boolean getPerformSendTest()- Specified by:
- getPerformSendTestin interface- TcpFailureDetectorMBean
 
- 
getPerformReadTestpublic boolean getPerformReadTest()- Specified by:
- getPerformReadTestin interface- TcpFailureDetectorMBean
 
- 
getConnectTimeoutpublic long getConnectTimeout()- Specified by:
- getConnectTimeoutin interface- TcpFailureDetectorMBean
 
- 
getRemoveSuspectsTimeoutpublic int getRemoveSuspectsTimeout()- Specified by:
- getRemoveSuspectsTimeoutin interface- TcpFailureDetectorMBean
 
- 
setPerformReadTestpublic void setPerformReadTest(boolean performReadTest) - Specified by:
- setPerformReadTestin interface- TcpFailureDetectorMBean
 
- 
setPerformSendTestpublic void setPerformSendTest(boolean performSendTest) - Specified by:
- setPerformSendTestin interface- TcpFailureDetectorMBean
 
- 
setReadTestTimeoutpublic void setReadTestTimeout(long readTestTimeout) - Specified by:
- setReadTestTimeoutin interface- TcpFailureDetectorMBean
 
- 
setConnectTimeoutpublic void setConnectTimeout(long connectTimeout) - Specified by:
- setConnectTimeoutin interface- TcpFailureDetectorMBean
 
- 
setRemoveSuspectsTimeoutpublic void setRemoveSuspectsTimeout(int removeSuspectsTimeout) - Specified by:
- setRemoveSuspectsTimeoutin interface- TcpFailureDetectorMBean
 
 
-