org.apache.catalina.tribes

## Interface MembershipService

- All Known Implementing Classes:
    McastService

      public interface MembershipService

  MembershipService Interface
  The `MembershipService` interface is the membership component at the bottom layer, the IO layer (for layers see the javadoc for the `Channel` interface).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MBR_RX`
    `static int` | `MBR_TX`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `broadcast(ChannelMessage message)` Broadcasts a message to all members.
    `Member` | `findMemberByName(String name)` Get a member.
    `Channel` | `getChannel()` Return the channel that is related to this MembershipService
    `Member` | `getLocalMember(boolean incAliveTime)` Get the local member.
    `Member` | `getMember(Member mbr)` Retrieve the specified member from the membership.
    `Member[]` | `getMembers()`
    `String[]` | `getMembersByName()`
    `Properties` | `getProperties()`
    `boolean` | `hasMembers()`
    `void` | `removeMembershipListener()` Removes the membership listener.
    `void` | `setChannel(Channel channel)` Set the channel that is related to this MembershipService
    `void` | `setDomain(byte[] domain)`
    `void` | `setLocalMemberProperties(String listenHost, int listenPort, int securePort, int udpPort)` Sets the local member properties for broadcasting.
    `void` | `setMembershipListener(MembershipListener listener)` Sets the membership listener, only one listener can be added.
    `void` | `setPayload(byte[] payload)` Set a payload to be broadcasted with each membership broadcast.
    `void` | `setProperties(Properties properties)` Sets the properties for the membership service.
    `void` | `start()` Starts the membership service.
    `void` | `start(int level)` Starts the membership service.
    `void` | `stop(int level)` Starts the membership service.

- - ### Field Detail

    - #### MBR_RX

          static final int MBR_RX

      See Also:
        Constant Field Values

    - #### MBR_TX

          static final int MBR_TX

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### setProperties

          void setProperties(Properties properties)

      Sets the properties for the membership service. This must be called before the `start()` method is called. The properties are implementation specific.
      Parameters:
        `properties` - - to be used to configure the membership service.

    - #### getProperties

          Properties getProperties()

      Returns:
        the properties for the configuration used.

    - #### start

          void start()
                     throws Exception

      Starts the membership service. If a membership listeners is added the listener will start to receive membership events. Performs a start level 1 and 2
      Throws:
        `Exception` - if the service fails to start.

    - #### start

          void start(int level)
                     throws Exception

      Starts the membership service. If a membership listeners is added the listener will start to receive membership events.
      Parameters:
        `level` - - level MBR_RX starts listening for members, level MBR_TX starts broad casting the server
      Throws:
        `Exception` - if the service fails to start.
        `IllegalArgumentException` - if the level is incorrect.

    - #### stop

          void stop(int level)

      Starts the membership service. If a membership listeners is added the listener will start to receive membership events.
      Parameters:
        `level` - - level MBR_RX stops listening for members, level MBR_TX stops broad casting the server
      Throws:
        `IllegalArgumentException` - if the level is incorrect.

    - #### hasMembers

          boolean hasMembers()

      Returns:
        true if the the group contains members

    - #### getMember

          Member getMember(Member mbr)

      Retrieve the specified member from the membership.
      Parameters:
        `mbr` - The member to retrieve
      Returns:
        the member

    - #### getMembers

          Member[] getMembers()

      Returns:
        a list of all the members in the cluster.

    - #### getLocalMember

          Member getLocalMember(boolean incAliveTime)

      Get the local member.
      Parameters:
        `incAliveTime` - `true` to set the alive time on the local member
      Returns:
        the member object that defines this member

    - #### getMembersByName

          String[] getMembersByName()

      Returns:
        all members by name

    - #### findMemberByName

          Member findMemberByName(String name)

      Get a member.
      Parameters:
        `name` - The member name
      Returns:
        the member

    - #### setLocalMemberProperties

          void setLocalMemberProperties(String listenHost,
                                      int listenPort,
                                      int securePort,
                                      int udpPort)

      Sets the local member properties for broadcasting.
      Parameters:
        `listenHost` - Listen to host
        `listenPort` - Listen to port
        `securePort` - Use a secure port
        `udpPort` - Use UDP

    - #### setMembershipListener

          void setMembershipListener(MembershipListener listener)

      Sets the membership listener, only one listener can be added. If you call this method twice, the last listener will be used.
      Parameters:
        `listener` - The listener

    - #### removeMembershipListener

          void removeMembershipListener()

      Removes the membership listener.

    - #### setPayload

          void setPayload(byte[] payload)

      Set a payload to be broadcasted with each membership broadcast.
      Parameters:
        `payload` - byte[]

    - #### setDomain

          void setDomain(byte[] domain)

    - #### broadcast

          void broadcast(ChannelMessage message)
                         throws ChannelException

      Broadcasts a message to all members.
      Parameters:
        `message` - The message to broadcast
      Throws:
        `ChannelException` - Message broadcast failed

    - #### getChannel

          Channel getChannel()

      Return the channel that is related to this MembershipService
      Returns:
        Channel

    - #### setChannel

          void setChannel(Channel channel)

      Set the channel that is related to this MembershipService
      Parameters:
        `channel` - The channel

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