Class ChannelInterceptorBase

    • Field Detail

      • optionFlag

        protected int optionFlag
    • Constructor Detail

      • ChannelInterceptorBase

        public ChannelInterceptorBase()
    • Method Detail

      • okToProcess

        public boolean okToProcess​(int messageFlags)
      • getNext

        public final ChannelInterceptor getNext()
        Description copied from interface: ChannelInterceptor
        Retrieve the next interceptor in the list
        Specified by:
        getNext in interface ChannelInterceptor
        Returns:
        ChannelInterceptor - returns the next interceptor in the list or null if no more interceptors exist
      • getPrevious

        public final ChannelInterceptor getPrevious()
        Description copied from interface: ChannelInterceptor
        Retrieve the previous interceptor in the list
        Specified by:
        getPrevious in interface ChannelInterceptor
        Returns:
        ChannelInterceptor - returns the previous interceptor in the list or null if no more interceptors exist
      • getOptionFlag

        public int getOptionFlag()
        Description copied from interface: ChannelInterceptor
        An 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:
        getOptionFlag in interface ChannelInterceptor
        Returns:
        int
        See Also:
        ChannelMessage.getOptions()
      • sendMessage

        public void sendMessage​(Member[] destination,
                                ChannelMessage msg,
                                InterceptorPayload payload)
                         throws ChannelException
        Description copied from interface: ChannelInterceptor
        The sendMessage 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)
        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 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
      • messageReceived

        public void messageReceived​(ChannelMessage msg)
        Description copied from interface: ChannelInterceptor
        the messageReceived 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 interface ChannelInterceptor
        Parameters:
        msg - ChannelMessage
      • heartbeat

        public void heartbeat()
        Description copied from interface: ChannelInterceptor
        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.
        Specified by:
        heartbeat in interface ChannelInterceptor
        Specified by:
        heartbeat in interface Heartbeat
      • start

        public void start​(int svc)
                   throws ChannelException
        Starts 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:
        start in 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
      • stop

        public void stop​(int svc)
                  throws ChannelException
        Shuts 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:
        stop in 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
      • setChannel

        public void setChannel​(Channel channel)
        Set the channel that is related to this interceptor
        Specified by:
        setChannel in interface ChannelInterceptor
        Parameters:
        channel - The channel