TcpFailureDetector (Apache Tomcat 8.5.57 API Documentation)

org.apache.catalina.tribes.group.interceptors

## Class TcpFailureDetector

- java.lang.Object
- - org.apache.catalina.tribes.group.ChannelInterceptorBase
  - - org.apache.catalina.tribes.group.interceptors.TcpFailureDetector

- All Implemented Interfaces:
    ChannelInterceptor, TcpFailureDetectorMBean, Heartbeat, MembershipListener

      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

  Version:
    1.0

- - ### Nested Class Summary

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

      `ChannelInterceptor.InterceptorEvent`

  - ### Field Summary

    Fields
    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`

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

      `optionFlag`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TcpFailureDetector()`

  - ### Method Summary

    Methods
    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()`

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

      `fireInterceptorEvent, getChannel, getNext, getOptionFlag, getPrevious, okToProcess, setChannel, setNext, setOptionFlag, setPrevious, start, stop`

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

      `getOptionFlag`

- - ### Field Detail

    - #### sm

          protected static final StringManager sm

    - #### TCP_FAIL_DETECT

          protected static final byte[] TCP_FAIL_DETECT

    - #### connectTimeout

          protected long connectTimeout

    - #### performSendTest

          protected boolean performSendTest

    - #### performReadTest

          protected boolean performReadTest

    - #### readTestTimeout

          protected long readTestTimeout

    - #### membership

          protected Membership membership

    - #### removeSuspects

          protected final HashMap<Member,Long> removeSuspects

    - #### addSuspects

          protected final HashMap<Member,Long> addSuspects

    - #### removeSuspectsTimeout

          protected int removeSuspectsTimeout

  - ### Constructor Detail

    - #### TcpFailureDetector

          public TcpFailureDetector()

  - ### Method Detail

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

    - #### memberAdded

          public void memberAdded(Member member)

      Description copied from interface: `MembershipListener`
      A member was added to the group
      Specified by:
        `memberAdded` in interface `MembershipListener`
      Overrides:
        `memberAdded` in class `ChannelInterceptorBase`
      Parameters:
        `member` - Member - the member that was added

    - #### memberDisappeared

          public void memberDisappeared(Member member)

      Description copied from interface: `MembershipListener`
      A member was removed from the group
      If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD data
      Specified by:
        `memberDisappeared` in interface `MembershipListener`
      Overrides:
        `memberDisappeared` in class `ChannelInterceptorBase`
      Parameters:
        `member` - Member
      See Also:
        `Member.SHUTDOWN_PAYLOAD`

    - #### hasMembers

          public boolean hasMembers()

      Description copied from class: `ChannelInterceptorBase`
      has members
      Specified by:
        `hasMembers` in interface `ChannelInterceptor`
      Overrides:
        `hasMembers` in class `ChannelInterceptorBase`
      Returns:
        boolean - if the channel has members in its membership group
      See Also:
        `Channel.hasMembers()`

    - #### getMembers

          public Member[] getMembers()

      Description copied from class: `ChannelInterceptorBase`
      Get all current cluster members
      Specified by:
        `getMembers` in interface `ChannelInterceptor`
      Overrides:
        `getMembers` in class `ChannelInterceptorBase`
      Returns:
        all members or empty array
      See Also:
        `Channel.getMembers()`

    - #### getMember

          public Member getMember(Member mbr)

      Description copied from interface: `ChannelInterceptor`
      Intercepts the `Channel.getMember(Member)` method
      Specified by:
        `getMember` in interface `ChannelInterceptor`
      Overrides:
        `getMember` in class `ChannelInterceptorBase`
      Parameters:
        `mbr` - Member
      Returns:
        Member
      See Also:
        `Channel.getMember(Member)`

    - #### getLocalMember

          public Member getLocalMember(boolean incAlive)

      Description copied from class: `ChannelInterceptorBase`
      Return the member that represents this node.
      Specified by:
        `getLocalMember` in interface `ChannelInterceptor`
      Overrides:
        `getLocalMember` in class `ChannelInterceptorBase`
      Parameters:
        `incAlive` - boolean
      Returns:
        Member
      See Also:
        `Channel.getLocalMember(boolean)`

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

    - #### checkMembers

          public void checkMembers(boolean checkAll)

      Specified by:
        `checkMembers` in interface `TcpFailureDetectorMBean`

    - #### performForcedCheck

          protected void performForcedCheck()

    - #### performBasicCheck

          protected void performBasicCheck()

    - #### setupMembership

          protected void setupMembership()

    - #### memberAlive

          protected boolean memberAlive(Member mbr)

    - #### memberAlive

          protected boolean memberAlive(Member mbr,
                            byte[] msgData,
                            boolean sendTest,
                            boolean readTest,
                            long readTimeout,
                            long conTimeout,
                            int optionFlag)

    - #### getReadTestTimeout

          public long getReadTestTimeout()

      Specified by:
        `getReadTestTimeout` in interface `TcpFailureDetectorMBean`

    - #### getPerformSendTest

          public boolean getPerformSendTest()

      Specified by:
        `getPerformSendTest` in interface `TcpFailureDetectorMBean`

    - #### getPerformReadTest

          public boolean getPerformReadTest()

      Specified by:
        `getPerformReadTest` in interface `TcpFailureDetectorMBean`

    - #### getConnectTimeout

          public long getConnectTimeout()

      Specified by:
        `getConnectTimeout` in interface `TcpFailureDetectorMBean`

    - #### getRemoveSuspectsTimeout

          public int getRemoveSuspectsTimeout()

      Specified by:
        `getRemoveSuspectsTimeout` in interface `TcpFailureDetectorMBean`

    - #### setPerformReadTest

          public void setPerformReadTest(boolean performReadTest)

      Specified by:
        `setPerformReadTest` in interface `TcpFailureDetectorMBean`

    - #### setPerformSendTest

          public void setPerformSendTest(boolean performSendTest)

      Specified by:
        `setPerformSendTest` in interface `TcpFailureDetectorMBean`

    - #### setReadTestTimeout

          public void setReadTestTimeout(long readTestTimeout)

      Specified by:
        `setReadTestTimeout` in interface `TcpFailureDetectorMBean`

    - #### setConnectTimeout

          public void setConnectTimeout(long connectTimeout)

      Specified by:
        `setConnectTimeout` in interface `TcpFailureDetectorMBean`

    - #### setRemoveSuspectsTimeout

          public void setRemoveSuspectsTimeout(int removeSuspectsTimeout)

      Specified by:
        `setRemoveSuspectsTimeout` in interface `TcpFailureDetectorMBean`

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