Class TcpPingInterceptor
java.lang.Object
org.apache.catalina.tribes.group.ChannelInterceptorBase
org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor
- All Implemented Interfaces:
ChannelInterceptor,TcpPingInterceptorMBean,Heartbeat,MembershipListener
Sends a ping to all members. Configure this interceptor with the TcpFailureDetector below it, and the
TcpFailureDetector will act as the membership guide.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.catalina.tribes.ChannelInterceptor
ChannelInterceptor.InterceptorEvent -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final AtomicIntegerprotected longprotected booleanprotected static final StringManagerprotected booleanprotected static final byte[]protected TcpPingInterceptor.PingThreadprotected booleanFields inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
optionFlag -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongbooleanbooleanvoidTheheartbeat()method gets invoked periodically to allow interceptors to clean up resources, time out object and perform actions that are unrelated to sending/receiving data.voidThemessageReceivedis invoked when a message is received.protected voidsendPing()protected voidsendPingMessage(Member[] members) voidsetInterval(long interval) voidsetStaticOnly(boolean staticOnly) voidsetUseThread(boolean useThread) voidstart(int svc) Starts up the channel.voidstop(int svc) Shuts down the channel.Methods inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase
fireInterceptorEvent, getChannel, getLocalMember, getMember, getMembers, getNext, getOptionFlag, getPrevious, hasMembers, memberAdded, memberDisappeared, okToProcess, sendMessage, setChannel, setNext, setOptionFlag, setPreviousMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.catalina.tribes.group.interceptors.TcpPingInterceptorMBean
getOptionFlag
-
Field Details
-
sm
-
TCP_PING_DATA
protected static final byte[] TCP_PING_DATA -
interval
protected long interval -
useThread
protected boolean useThread -
staticOnly
protected boolean staticOnly -
running
protected volatile boolean running -
thread
-
cnt
-
-
Constructor Details
-
TcpPingInterceptor
public TcpPingInterceptor()
-
-
Method Details
-
start
Description 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:
-
stop
Description 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:
-
heartbeat
public 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 interfaceChannelInterceptor- Specified by:
heartbeatin interfaceHeartbeat- Overrides:
heartbeatin classChannelInterceptorBase
-
getInterval
public long getInterval()- Specified by:
getIntervalin interfaceTcpPingInterceptorMBean
-
setInterval
public void setInterval(long interval) -
setUseThread
public void setUseThread(boolean useThread) -
setStaticOnly
public void setStaticOnly(boolean staticOnly) -
getUseThread
public boolean getUseThread()- Specified by:
getUseThreadin interfaceTcpPingInterceptorMBean
-
getStaticOnly
public boolean getStaticOnly() -
sendPing
protected void sendPing() -
sendPingMessage
-
messageReceived
Description 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 interfaceChannelInterceptor- Overrides:
messageReceivedin classChannelInterceptorBase- Parameters:
msg- ChannelMessage
-