TcpPingInterceptor (Apache Tomcat 8.5.57 API Documentation)

org.apache.catalina.tribes.group.interceptors

## 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

      public class TcpPingInterceptor
      extends ChannelInterceptorBase
      implements TcpPingInterceptorMBean

  Sends a ping to all members. Configure this interceptor with the TcpFailureDetector below it, and the TcpFailureDetector will act as the membership guide.
  Version:
    1.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `TcpPingInterceptor.PingThread`

    - ### Nested classes/interfaces inherited from interface org.apache.catalina.tribes.ChannelInterceptor

      `ChannelInterceptor.InterceptorEvent`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static AtomicInteger` | `cnt`
    `protected long` | `interval`
    `protected boolean` | `running`
    `protected static StringManager` | `sm`
    `protected boolean` | `staticOnly`
    `protected static byte[]` | `TCP_PING_DATA`
    `protected TcpPingInterceptor.PingThread` | `thread`
    `protected boolean` | `useThread`

    - ### Fields inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBase

      `optionFlag`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TcpPingInterceptor()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getInterval()`
    `boolean` | `getStaticOnly()`
    `boolean` | `getUseThread()`
    `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` | `messageReceived(ChannelMessage msg)` the `messageReceived` is invoked when a message is received.
    `protected void` | `sendPing()`
    `protected void` | `sendPingMessage(Member[] members)`
    `void` | `setInterval(long interval)`
    `void` | `setStaticOnly(boolean staticOnly)`
    `void` | `setUseThread(boolean useThread)`
    `void` | `start(int svc)` Starts up the channel.
    `void` | `stop(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, setPrevious`

    - ### 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.TcpPingInterceptorMBean

      `getOptionFlag`

- - ### Field Detail

    - #### sm

          protected static final StringManager 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

          protected TcpPingInterceptor.PingThread thread

    - #### cnt

          protected static final AtomicInteger cnt

  - ### Constructor Detail

    - #### TcpPingInterceptor

          public TcpPingInterceptor()

  - ### Method Detail

    - #### start

          public void start(int svc)
                     throws ChannelException

      Description copied from class: `ChannelInterceptorBase`
      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`
      Overrides:
        `start` in class `ChannelInterceptorBase`
      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

      Description copied from class: `ChannelInterceptorBase`
      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`
      Overrides:
        `stop` in class `ChannelInterceptorBase`
      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`

    - #### 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`
      Overrides:
        `heartbeat` in class `ChannelInterceptorBase`

    - #### getInterval

          public long getInterval()

      Specified by:
        `getInterval` in interface `TcpPingInterceptorMBean`

    - #### setInterval

          public void setInterval(long interval)

    - #### setUseThread

          public void setUseThread(boolean useThread)

    - #### setStaticOnly

          public void setStaticOnly(boolean staticOnly)

    - #### getUseThread

          public boolean getUseThread()

      Specified by:
        `getUseThread` in interface `TcpPingInterceptorMBean`

    - #### getStaticOnly

          public boolean getStaticOnly()

    - #### sendPing

          protected void sendPing()

    - #### sendPingMessage

          protected void sendPingMessage(Member[] members)

    - #### 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`
      Overrides:
        `messageReceived` in class `ChannelInterceptorBase`
      Parameters:
        `msg` - ChannelMessage

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.