public class TcpFailureDetector extends ChannelInterceptorBase implements TcpFailureDetectorMBean
Title: A perfect failure detector
Description: 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.
1. It intercepts memberDisappeared events
2. It catches send errors
ChannelInterceptor.InterceptorEvent| Modifier and Type | Field and Description |
|---|---|
protected HashMap<Member,Long> |
addSuspects |
protected long |
connectTimeout |
protected Membership |
membership |
protected boolean |
performReadTest |
protected boolean |
performSendTest |
protected long |
readTestTimeout |
protected HashMap<Member,Long> |
removeSuspects |
protected int |
removeSuspectsTimeout |
protected static StringManager |
sm |
protected static byte[] |
TCP_FAIL_DETECT |
optionFlag| Constructor and Description |
|---|
TcpFailureDetector() |
| Modifier and Type | Method and Description |
|---|---|
void |
checkMembers(boolean checkAll) |
long |
getConnectTimeout() |
Member |
getLocalMember(boolean incAlive)
Return the member that represents this node.
|
Member |
getMember(Member mbr)
Intercepts the
Channel.getMember(Member) method |
Member[] |
getMembers()
Get all current cluster members
|
boolean |
getPerformReadTest() |
boolean |
getPerformSendTest() |
long |
getReadTestTimeout() |
int |
getRemoveSuspectsTimeout() |
boolean |
hasMembers()
has members
|
void |
heartbeat()
The
heartbeat() 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 group
|
protected 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 data |
void |
messageReceived(ChannelMessage msg)
the
messageReceived is invoked when a message is received. |
protected void |
performBasicCheck() |
protected void |
performForcedCheck() |
void |
sendMessage(Member[] destination,
ChannelMessage msg,
InterceptorPayload payload)
The
sendMessage 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 |
setupMembership() |
fireInterceptorEvent, getChannel, getNext, getOptionFlag, getPrevious, okToProcess, setChannel, setNext, setOptionFlag, setPrevious, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetOptionFlagprotected static final StringManager sm
protected static final byte[] TCP_FAIL_DETECT
protected long connectTimeout
protected boolean performSendTest
protected boolean performReadTest
protected long readTestTimeout
protected Membership membership
protected int removeSuspectsTimeout
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException
ChannelInterceptorsendMessage 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
invoking getNext().sendMessage(destination,msg,payload)getNext().sendMessage(destination,msg,payload)sendMessage in interface ChannelInterceptorsendMessage in class ChannelInterceptorBasedestination - 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 nullChannelException - if a serialization error happens.ErrorHandler,
InterceptorPayloadpublic void messageReceived(ChannelMessage msg)
ChannelInterceptormessageReceived is invoked when a message is received.
ChannelMessage.getAddress() is the sender, or the reply-to address
if it has been overwritten.messageReceived in interface ChannelInterceptormessageReceived in class ChannelInterceptorBasemsg - ChannelMessagepublic void memberAdded(Member member)
MembershipListenermemberAdded in interface MembershipListenermemberAdded in class ChannelInterceptorBasemember - Member - the member that was addedpublic void memberDisappeared(Member member)
MembershipListenermemberDisappeared in interface MembershipListenermemberDisappeared in class ChannelInterceptorBasemember - MemberMember.SHUTDOWN_PAYLOADpublic boolean hasMembers()
ChannelInterceptorBasehasMembers in interface ChannelInterceptorhasMembers in class ChannelInterceptorBaseChannel.hasMembers()public Member[] getMembers()
ChannelInterceptorBasegetMembers in interface ChannelInterceptorgetMembers in class ChannelInterceptorBaseChannel.getMembers()public Member getMember(Member mbr)
ChannelInterceptorChannel.getMember(Member) methodgetMember in interface ChannelInterceptorgetMember in class ChannelInterceptorBasembr - MemberChannel.getMember(Member)public Member getLocalMember(boolean incAlive)
ChannelInterceptorBasegetLocalMember in interface ChannelInterceptorgetLocalMember in class ChannelInterceptorBaseincAlive - booleanChannel.getLocalMember(boolean)public void heartbeat()
ChannelInterceptorheartbeat() method gets invoked periodically
to allow interceptors to clean up resources, time out object and
perform actions that are unrelated to sending/receiving data.heartbeat in interface ChannelInterceptorheartbeat in interface Heartbeatheartbeat in class ChannelInterceptorBasepublic void checkMembers(boolean checkAll)
checkMembers in interface TcpFailureDetectorMBeanprotected void performForcedCheck()
protected void performBasicCheck()
protected void setupMembership()
protected boolean memberAlive(Member mbr)
protected boolean memberAlive(Member mbr, byte[] msgData, boolean sendTest, boolean readTest, long readTimeout, long conTimeout, int optionFlag)
public long getReadTestTimeout()
getReadTestTimeout in interface TcpFailureDetectorMBeanpublic boolean getPerformSendTest()
getPerformSendTest in interface TcpFailureDetectorMBeanpublic boolean getPerformReadTest()
getPerformReadTest in interface TcpFailureDetectorMBeanpublic long getConnectTimeout()
getConnectTimeout in interface TcpFailureDetectorMBeanpublic int getRemoveSuspectsTimeout()
getRemoveSuspectsTimeout in interface TcpFailureDetectorMBeanpublic void setPerformReadTest(boolean performReadTest)
setPerformReadTest in interface TcpFailureDetectorMBeanpublic void setPerformSendTest(boolean performSendTest)
setPerformSendTest in interface TcpFailureDetectorMBeanpublic void setReadTestTimeout(long readTestTimeout)
setReadTestTimeout in interface TcpFailureDetectorMBeanpublic void setConnectTimeout(long connectTimeout)
setConnectTimeout in interface TcpFailureDetectorMBeanpublic void setRemoveSuspectsTimeout(int removeSuspectsTimeout)
setRemoveSuspectsTimeout in interface TcpFailureDetectorMBeanCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.