Package org.apache.catalina.tribes.group
Class ChannelInterceptorBase
- java.lang.Object
- 
- org.apache.catalina.tribes.group.ChannelInterceptorBase
 
- 
- All Implemented Interfaces:
- ChannelInterceptor,- Heartbeat,- MembershipListener
 - Direct Known Subclasses:
- ChannelCoordinator,- DomainFilterInterceptor,- EncryptInterceptor,- FragmentationInterceptor,- GroupChannel,- GzipInterceptor,- MessageDispatchInterceptor,- NonBlockingCoordinator,- OrderInterceptor,- SimpleCoordinator,- StaticMembershipInterceptor,- TcpFailureDetector,- TcpPingInterceptor,- ThroughputInterceptor,- TwoPhaseCommitInterceptor
 
 public abstract class ChannelInterceptorBase extends java.lang.Object implements ChannelInterceptor Abstract class for the interceptor base class.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.catalina.tribes.ChannelInterceptorChannelInterceptor.InterceptorEvent
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected intoptionFlag
 - 
Constructor SummaryConstructors Constructor Description ChannelInterceptorBase()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfireInterceptorEvent(ChannelInterceptor.InterceptorEvent event)ChannelgetChannel()Return the channel that is related to this interceptorMembergetLocalMember(boolean incAlive)Return the member that represents this node.MembergetMember(Member mbr)Intercepts theChannel.getMember(Member)methodMember[]getMembers()Get all current cluster membersChannelInterceptorgetNext()Retrieve the next interceptor in the listintgetOptionFlag()An interceptor can react to a message based on a set bit on the message options.ChannelInterceptorgetPrevious()Retrieve the previous interceptor in the listbooleanhasMembers()has membersvoidheartbeat()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.voidmemberAdded(Member member)A member was added to the groupvoidmemberDisappeared(Member member)A member was removed from the group
 If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD datavoidmessageReceived(ChannelMessage msg)themessageReceivedis invoked when a message is received.booleanokToProcess(int messageFlags)voidsendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)ThesendMessagemethod is called when a message is being sent to one more destinations.voidsetChannel(Channel channel)Set the channel that is related to this interceptorvoidsetNext(ChannelInterceptor next)Set the next interceptor in the list of interceptorsvoidsetOptionFlag(int optionFlag)Sets the option flagvoidsetPrevious(ChannelInterceptor previous)Set the previous interceptor in the listvoidstart(int svc)Starts up the channel.voidstop(int svc)Shuts down the channel.
 
- 
- 
- 
Method Detail- 
okToProcesspublic boolean okToProcess(int messageFlags) 
 - 
setNextpublic final void setNext(ChannelInterceptor next) Description copied from interface:ChannelInterceptorSet the next interceptor in the list of interceptors- Specified by:
- setNextin interface- ChannelInterceptor
- Parameters:
- next- ChannelInterceptor
 
 - 
getNextpublic final ChannelInterceptor getNext() Description copied from interface:ChannelInterceptorRetrieve the next interceptor in the list- Specified by:
- getNextin interface- ChannelInterceptor
- Returns:
- ChannelInterceptor - returns the next interceptor in the list or null if no more interceptors exist
 
 - 
setPreviouspublic final void setPrevious(ChannelInterceptor previous) Description copied from interface:ChannelInterceptorSet the previous interceptor in the list- Specified by:
- setPreviousin interface- ChannelInterceptor
- Parameters:
- previous- ChannelInterceptor
 
 - 
setOptionFlagpublic void setOptionFlag(int optionFlag) Description copied from interface:ChannelInterceptorSets the option flag- Specified by:
- setOptionFlagin interface- ChannelInterceptor
- Parameters:
- optionFlag- int
- See Also:
- ChannelInterceptor.getOptionFlag()
 
 - 
getPreviouspublic final ChannelInterceptor getPrevious() Description copied from interface:ChannelInterceptorRetrieve the previous interceptor in the list- Specified by:
- getPreviousin interface- ChannelInterceptor
- Returns:
- ChannelInterceptor - returns the previous interceptor in the list or null if no more interceptors exist
 
 - 
getOptionFlagpublic int getOptionFlag() Description copied from interface:ChannelInterceptorAn interceptor can react to a message based on a set bit on the message options.
 When a message is sent, the options can be retrieved from ChannelMessage.getOptions() and if the bit is set, this interceptor will react to it.
 A simple evaluation if an interceptor should react to the message would be:
 boolean react = (getOptionFlag() == (getOptionFlag() & ChannelMessage.getOptions()));
 The default option is 0, meaning there is no way for the application to trigger the interceptor. The interceptor itself will decide.- Specified by:
- getOptionFlagin interface- ChannelInterceptor
- Returns:
- int
- See Also:
- ChannelMessage.getOptions()
 
 - 
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
- 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:
- ErrorHandler,- InterceptorPayload
 
 - 
messageReceivedpublic void messageReceived(ChannelMessage msg) 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 interface- ChannelInterceptor
- Parameters:
- msg- ChannelMessage
 
 - 
memberAddedpublic void memberAdded(Member member) Description copied from interface:MembershipListenerA member was added to the group- Specified by:
- memberAddedin interface- MembershipListener
- Parameters:
- member- Member - the member that was added
 
 - 
memberDisappearedpublic void memberDisappeared(Member member) Description 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
- Parameters:
- member- Member
- See Also:
- Member.SHUTDOWN_PAYLOAD
 
 - 
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
 
 - 
hasMemberspublic boolean hasMembers() has members- Specified by:
- hasMembersin interface- ChannelInterceptor
- Returns:
- boolean - if the channel has members in its membership group
- See Also:
- Channel.hasMembers()
 
 - 
getMemberspublic Member[] getMembers() Get all current cluster members- Specified by:
- getMembersin interface- ChannelInterceptor
- Returns:
- all members or empty array
- See Also:
- Channel.getMembers()
 
 - 
getMemberpublic Member getMember(Member mbr) Description copied from interface:ChannelInterceptorIntercepts theChannel.getMember(Member)method- Specified by:
- getMemberin interface- ChannelInterceptor
- Parameters:
- mbr- Member
- Returns:
- Member
- See Also:
- Channel.getMember(Member)
 
 - 
getLocalMemberpublic Member getLocalMember(boolean incAlive) Return the member that represents this node.- Specified by:
- getLocalMemberin interface- ChannelInterceptor
- Parameters:
- incAlive- boolean
- Returns:
- Member
- See Also:
- Channel.getLocalMember(boolean)
 
 - 
startpublic void start(int svc) throws ChannelExceptionStarts 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 interface- ChannelInterceptor
- Parameters:
- svc- int value of
 DEFAULT - will start all services
 MBR_RX_SEQ - starts the membership receiver
 MBR_TX_SEQ - starts the membership broadcaster
 SND_TX_SEQ - starts the replication transmitter
 SND_RX_SEQ - starts the replication receiver
- Throws:
- ChannelException- if a startup error occurs or the service is already started.
- See Also:
- Channel
 
 - 
stoppublic void stop(int svc) throws ChannelExceptionShuts down the channel. This can be called multiple times for individual services to shutdown The svc parameter can be the logical or value of any constants- Specified by:
- stopin interface- ChannelInterceptor
- Parameters:
- svc- int value of
 DEFAULT - will shutdown all services
 MBR_RX_SEQ - stops the membership receiver
 MBR_TX_SEQ - stops the membership broadcaster
 SND_TX_SEQ - stops the replication transmitter
 SND_RX_SEQ - stops the replication receiver
- Throws:
- ChannelException- if a startup error occurs or the service is already started.
- See Also:
- Channel
 
 - 
fireInterceptorEventpublic void fireInterceptorEvent(ChannelInterceptor.InterceptorEvent event) - Specified by:
- fireInterceptorEventin interface- ChannelInterceptor
 
 - 
getChannelpublic Channel getChannel() Return the channel that is related to this interceptor- Specified by:
- getChannelin interface- ChannelInterceptor
- Returns:
- Channel
 
 - 
setChannelpublic void setChannel(Channel channel) Set the channel that is related to this interceptor- Specified by:
- setChannelin interface- ChannelInterceptor
- Parameters:
- channel- The channel
 
 
- 
 
-