Class TcpFailureDetector
- All Implemented Interfaces:
ChannelInterceptor
,TcpFailureDetectorMBean
,Heartbeat
,MembershipListener
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 Summary
Nested classes/interfaces inherited from interface org.apache.catalina.tribes.ChannelInterceptor
ChannelInterceptor.InterceptorEvent
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
protected Membership
protected boolean
protected boolean
protected long
protected int
protected static final StringManager
protected static final byte[]
Fields inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
optionFlag
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkMembers
(boolean checkAll) long
getLocalMember
(boolean incAlive) Intercepts theChannel.getLocalMember(boolean)
methodIntercepts theChannel.getMember(Member)
methodMember[]
Intercepts theChannel.getMembers()
methodboolean
boolean
long
int
boolean
Intercepts theChannel.hasMembers()
methodvoid
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.void
memberAdded
(Member member) A member was added to the groupprotected boolean
memberAlive
(Member mbr) protected boolean
memberAlive
(Member mbr, byte[] msgData, boolean sendTest, boolean readTest, long readTimeout, long conTimeout, int optionFlag) void
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
ThemessageReceived
is invoked when a message is received.protected void
protected void
void
sendMessage
(Member[] destination, ChannelMessage msg, InterceptorPayload payload) ThesendMessage
method is called when a message is being sent to one more destinations.void
setConnectTimeout
(long connectTimeout) void
setPerformReadTest
(boolean performReadTest) void
setPerformSendTest
(boolean performSendTest) void
setReadTestTimeout
(long readTestTimeout) void
setRemoveSuspectsTimeout
(int removeSuspectsTimeout) protected void
Methods inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
fireInterceptorEvent, getChannel, getNext, getOptionFlag, getPrevious, okToProcess, setChannel, setNext, setOptionFlag, setPrevious, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.catalina.tribes.group.interceptors.TcpFailureDetectorMBean
getOptionFlag
-
Field Details
-
sm
-
TCP_FAIL_DETECT
protected static final byte[] TCP_FAIL_DETECT -
connectTimeout
protected long connectTimeout -
performSendTest
protected boolean performSendTest -
performReadTest
protected boolean performReadTest -
readTestTimeout
protected long readTestTimeout -
membership
-
removeSuspects
-
addSuspects
-
removeSuspectsTimeout
protected int removeSuspectsTimeout
-
-
Constructor Details
-
TcpFailureDetector
public TcpFailureDetector()
-
-
Method Details
-
sendMessage
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException Description copied from interface:ChannelInterceptor
ThesendMessage
method 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 invoking
getNext().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:
sendMessage
in interfaceChannelInterceptor
- Overrides:
sendMessage
in classChannelInterceptorBase
- Parameters:
destination
- Member[] - the destination for this messagemsg
- ChannelMessage - the message to be sentpayload
- InterceptorPayload - the payload, carrying an error handler and future useful data, can be null- Throws:
ChannelException
- if a serialization error happens.- See Also:
-
messageReceived
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
- Overrides:
messageReceived
in classChannelInterceptorBase
- Parameters:
msg
- ChannelMessage
-
memberAdded
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
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:
-
hasMembers
public boolean hasMembers()Description copied from interface:ChannelInterceptor
Intercepts theChannel.hasMembers()
method- Specified by:
hasMembers
in interfaceChannelInterceptor
- Overrides:
hasMembers
in classChannelInterceptorBase
- Returns:
- boolean - if the channel has members in its membership group
- See Also:
-
getMembers
Description copied from interface:ChannelInterceptor
Intercepts theChannel.getMembers()
method- Specified by:
getMembers
in interfaceChannelInterceptor
- Overrides:
getMembers
in classChannelInterceptorBase
- Returns:
- the members
- See Also:
-
getMember
Description copied from interface:ChannelInterceptor
Intercepts theChannel.getMember(Member)
method- Specified by:
getMember
in interfaceChannelInterceptor
- Overrides:
getMember
in classChannelInterceptorBase
- Parameters:
mbr
- Member- Returns:
- Member - the actual member information, including stay alive
- See Also:
-
getLocalMember
Description copied from interface:ChannelInterceptor
Intercepts theChannel.getLocalMember(boolean)
method- Specified by:
getLocalMember
in interfaceChannelInterceptor
- Overrides:
getLocalMember
in classChannelInterceptorBase
- Parameters:
incAlive
- boolean- Returns:
- the member that represents this node
- See Also:
-
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
-
checkMembers
public void checkMembers(boolean checkAll) - Specified by:
checkMembers
in interfaceTcpFailureDetectorMBean
-
performForcedCheck
protected void performForcedCheck() -
performBasicCheck
protected void performBasicCheck() -
setupMembership
protected void setupMembership() -
memberAlive
-
memberAlive
protected boolean memberAlive(Member mbr, byte[] msgData, boolean sendTest, boolean readTest, long readTimeout, long conTimeout, int optionFlag) -
getReadTestTimeout
public long getReadTestTimeout()- Specified by:
getReadTestTimeout
in interfaceTcpFailureDetectorMBean
-
getPerformSendTest
public boolean getPerformSendTest()- Specified by:
getPerformSendTest
in interfaceTcpFailureDetectorMBean
-
getPerformReadTest
public boolean getPerformReadTest()- Specified by:
getPerformReadTest
in interfaceTcpFailureDetectorMBean
-
getConnectTimeout
public long getConnectTimeout()- Specified by:
getConnectTimeout
in interfaceTcpFailureDetectorMBean
-
getRemoveSuspectsTimeout
public int getRemoveSuspectsTimeout()- Specified by:
getRemoveSuspectsTimeout
in interfaceTcpFailureDetectorMBean
-
setPerformReadTest
public void setPerformReadTest(boolean performReadTest) - Specified by:
setPerformReadTest
in interfaceTcpFailureDetectorMBean
-
setPerformSendTest
public void setPerformSendTest(boolean performSendTest) - Specified by:
setPerformSendTest
in interfaceTcpFailureDetectorMBean
-
setReadTestTimeout
public void setReadTestTimeout(long readTestTimeout) - Specified by:
setReadTestTimeout
in interfaceTcpFailureDetectorMBean
-
setConnectTimeout
public void setConnectTimeout(long connectTimeout) - Specified by:
setConnectTimeout
in interfaceTcpFailureDetectorMBean
-
setRemoveSuspectsTimeout
public void setRemoveSuspectsTimeout(int removeSuspectsTimeout) - Specified by:
setRemoveSuspectsTimeout
in interfaceTcpFailureDetectorMBean
-