ChannelCoordinator (Apache Tomcat 10.1.57 API Documentation)
Description: declaration: package: org.apache.catalina.tribes.group, class: ChannelCoordinator

# Class ChannelCoordinator

java.lang.Object
org.apache.catalina.tribes.group.ChannelInterceptorBase
org.apache.catalina.tribes.group.ChannelCoordinator

All Implemented Interfaces:
  `ChannelInterceptor, Heartbeat, MembershipListener, MessageListener`

public class ChannelCoordinator extends ChannelInterceptorBase implements MessageListener
The channel coordinator object coordinates the membership service, the sender and the receiver. This is the last interceptor in the chain.

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface ChannelInterceptor

  `ChannelInterceptor.InterceptorEvent`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final StringManager`
  `sm`
  String manager for this class.

  ### Fields inherited from class ChannelInterceptorBase

  `optionFlag`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ChannelCoordinator()`
  Default constructor.
  `ChannelCoordinator(ChannelReceiver receiver, ChannelSender sender, MembershipService service)`
  Construct a ChannelCoordinator with the specified receiver, sender and membership service.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `accept(ChannelMessage msg)`
  Allows skipping processing of the specified message.
  `ChannelReceiver`
  `getClusterReceiver()`
  Returns the cluster receiver.
  `ChannelSender`
  `getClusterSender()`
  Returns the cluster sender.
  `Member`
  `getLocalMember(boolean incAlive)`
  Intercepts the `Channel.getLocalMember(boolean)` method
  `Member`
  `getMember(Member mbr)`
  Intercepts the `Channel.getMember(Member)` method
  `Member[]`
  `getMembers()`
  Intercepts the `Channel.getMembers()` method
  `MembershipService`
  `getMembershipService()`
  Returns the membership service.
  `boolean`
  `hasMembers()`
  Intercepts the `Channel.hasMembers()` method
  `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.
  `protected void`
  `internalStart(int svc)`
  Starts up the channel.
  `protected void`
  `internalStop(int svc)`
  Shuts down the channel.
  `void`
  `memberAdded(Member member)`
  A member was added to the group
  `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.
  `void`
  `sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)`
  Send a message to one or more members in the cluster
  `void`
  `setClusterReceiver(ChannelReceiver clusterReceiver)`
  Sets the cluster receiver.
  `void`
  `setClusterSender(ChannelSender clusterSender)`
  Sets the cluster sender.
  `void`
  `setMembershipService(MembershipService membershipService)`
  Sets the membership service.
  `void`
  `start(int svc)`
  Starts up the channel.
  `void`
  `stop(int svc)`
  Shuts down the channel.

  ### Methods inherited from class ChannelInterceptorBase

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

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### sm

    protected static final StringManager sm
    String manager for this class.

- ## Constructor Details

  - ### ChannelCoordinator

    public ChannelCoordinator()
    Default constructor.

  - ### ChannelCoordinator

    public ChannelCoordinator(ChannelReceiver receiver, ChannelSender sender, MembershipService service)
    Construct a ChannelCoordinator with the specified receiver, sender and membership service.
    Parameters:
      `receiver` - The channel receiver
      `sender` - The channel sender
      `service` - The membership service

- ## Method Details

  - ### sendMessage

    public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException
    Send a message to one or more members in the cluster
    Specified by:
      `sendMessage` in interface `ChannelInterceptor`
    Overrides:
      `sendMessage` in class `ChannelInterceptorBase`
    Parameters:
      `destination` - Member[] - the destinations, null or zero length means all
      `msg` - ClusterMessage - the message to send
      `payload` - TBA
    Throws:
      `ChannelException` - if a serialization error happens.
    See Also:
      - `ErrorHandler`
      - `InterceptorPayload`

  - ### start

    public void start(int svc) throws ChannelException
    Description copied from interface: `ChannelInterceptor`
    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` - 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:
      - `Channel`

  - ### stop

    public void stop(int svc) throws ChannelException
    Description copied from interface: `ChannelInterceptor`
    Shuts 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:
      `stop` in interface `ChannelInterceptor`
    Overrides:
      `stop` in class `ChannelInterceptorBase`
    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:
      - `Channel`

  - ### internalStart

    protected void internalStart(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
    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.

  - ### internalStop

    protected void internalStop(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
    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.

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

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

  - ### accept

    public boolean accept(ChannelMessage msg)
    Description copied from interface: `MessageListener`
    Allows skipping processing of the specified message.
    Specified by:
      `accept` in interface `MessageListener`
    Parameters:
      `msg` - the message
    Returns:
      `true` if the message will be processed

  - ### getClusterReceiver

    public ChannelReceiver getClusterReceiver()
    Returns the cluster receiver.
    Returns:
      the cluster receiver

  - ### getClusterSender

    public ChannelSender getClusterSender()
    Returns the cluster sender.
    Returns:
      the cluster sender

  - ### getMembershipService

    public MembershipService getMembershipService()
    Returns the membership service.
    Returns:
      the membership service

  - ### setClusterReceiver

    public void setClusterReceiver(ChannelReceiver clusterReceiver)
    Sets the cluster receiver.
    Parameters:
      `clusterReceiver` - The new cluster receiver

  - ### setClusterSender

    public void setClusterSender(ChannelSender clusterSender)
    Sets the cluster sender.
    Parameters:
      `clusterSender` - The new cluster sender

  - ### setMembershipService

    public void setMembershipService(MembershipService membershipService)
    Sets the membership service.
    Parameters:
      `membershipService` - The new membership service

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

  - ### hasMembers

    public boolean hasMembers()
    Description copied from interface: `ChannelInterceptor`
    Intercepts the `Channel.hasMembers()` method
    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 interface: `ChannelInterceptor`
    Intercepts the `Channel.getMembers()` method
    Specified by:
      `getMembers` in interface `ChannelInterceptor`
    Overrides:
      `getMembers` in class `ChannelInterceptorBase`
    Returns:
      the members
    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 - the actual member information, including stay alive
    See Also:
      - `Channel.getMember(Member)`

  - ### getLocalMember

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