# Class StaticMembershipService

java.lang.Object
org.apache.catalina.tribes.membership.MembershipServiceBase
org.apache.catalina.tribes.membership.StaticMembershipService

All Implemented Interfaces:
  `StaticMembershipServiceMBean, MembershipListener, MembershipService`

public class StaticMembershipService extends MembershipServiceBase implements StaticMembershipServiceMBean
Service that manages static membership for a cluster channel.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final StringManager`
  `sm`
  String manager for this class.
  `protected final ArrayList<StaticMember>`
  `staticMembers`
  List of static members configured for this service.

  ### Fields inherited from class MembershipServiceBase

  `channel, listener, properties`

  ### Fields inherited from interface MembershipService

  `MBR_RX, MBR_TX`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StaticMembershipService()`
  Default constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addStaticMember(StaticMember member)`
  Adds a static member to the cluster.
  `protected StaticMembershipProvider`
  `buildMembershipProvider()`
  Builds and configures the membership provider.
  `int`
  `getConnectTimeout()`
  Returns the connection timeout in milliseconds.
  `long`
  `getExpirationTime()`
  Returns the member expiration time in milliseconds.
  `Member`
  `getLocalMember(boolean incAliveTime)`
  Get the local member.
  `MembershipProvider`
  `getMembershipProvider()`
  Get the MembershipProvider
  `long`
  `getPingInterval()`
  Returns the ping interval in milliseconds.
  `long`
  `getRpcTimeout()`
  Returns the RPC timeout in milliseconds.
  `ArrayList<StaticMember>`
  `getStaticMembers()`
  Returns the list of static members.
  `boolean`
  `getUseThread()`
  Returns whether a background ping thread is in use.
  `void`
  `removeStaticMember(StaticMember member)`
  Removes a static member from the cluster.
  `void`
  `setConnectTimeout(int connectTimeout)`
  Sets the connection timeout in milliseconds.
  `protected void`
  `setDefaults(Properties properties)`
  Sets default property values.
  `void`
  `setDomain(byte[] domain)`
  Set the associated domain.
  `void`
  `setExpirationTime(long expirationTime)`
  Sets the member expiration time in milliseconds.
  `void`
  `setLocalMember(StaticMember member)`
  Sets the local member for this service.
  `void`
  `setLocalMemberProperties(String listenHost, int listenPort, int securePort, int udpPort)`
  Sets the local member properties for broadcasting.
  `void`
  `setPayload(byte[] payload)`
  Set a payload to be broadcasted with each membership broadcast.
  `void`
  `setPingInterval(long pingInterval)`
  Sets the ping interval in milliseconds.
  `void`
  `setProperties(Properties properties)`
  Sets the properties for the membership service.
  `void`
  `setRpcTimeout(long rpcTimeout)`
  Sets the RPC timeout in milliseconds.
  `void`
  `setUseThread(boolean useThread)`
  Sets whether to use a background thread for pinging.
  `void`
  `start(int level)`
  Starts the membership service.
  `void`
  `stop(int level)`
  Stops the membership service.

  ### Methods inherited from class MembershipServiceBase

  `broadcast, findMemberByName, getChannel, getMember, getMembers, getMembersByName, getProperties, hasMembers, memberAdded, memberDisappeared, removeMembershipListener, setChannel, setMembershipListener, start`

  ### Methods inherited from class Object

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

  ### Methods inherited from interface StaticMembershipServiceMBean

  `findMemberByName, getMembersByName, getProperties, hasMembers`

- ## Field Details

  - ### sm

    protected static final StringManager sm
    String manager for this class.

  - ### staticMembers

    protected final ArrayList<StaticMember> staticMembers
    List of static members configured for this service.

- ## Constructor Details

  - ### StaticMembershipService

    public StaticMembershipService()
    Default constructor.

- ## Method Details

  - ### start

    public void start(int level) throws Exception
    Description copied from interface: `MembershipService`
    Starts the membership service. If a membership listeners is added the listener will start to receive membership events.
    Specified by:
      `start` in interface `MembershipService`
    Parameters:
      `level` - - level MBR_RX starts listening for members, level MBR_TX starts broadcasting the server
    Throws:
      `Exception` - if the service fails to start.

  - ### buildMembershipProvider

    protected StaticMembershipProvider buildMembershipProvider() throws Exception
    Builds and configures the membership provider.
    Returns:
      the configured membership provider
    Throws:
      `Exception` - if initialization fails

  - ### stop

    public void stop(int level)
    Description copied from interface: `MembershipService`
    Stops the membership service. If a membership listener is added the listener will stop receiving membership events.
    Specified by:
      `stop` in interface `MembershipService`
    Parameters:
      `level` - - level MBR_RX stops listening for members, level MBR_TX stops broadcasting the server

  - ### getLocalMember

    public Member getLocalMember(boolean incAliveTime)
    Description copied from interface: `MembershipService`
    Get the local member.
    Specified by:
      `getLocalMember` in interface `MembershipService`
    Parameters:
      `incAliveTime` - `true` to set the alive time on the local member
    Returns:
      the member object that defines this member

  - ### setLocalMemberProperties

    public void setLocalMemberProperties(String listenHost, int listenPort, int securePort, int udpPort)
    Description copied from interface: `MembershipService`
    Sets the local member properties for broadcasting.
    Specified by:
      `setLocalMemberProperties` in interface `MembershipService`
    Parameters:
      `listenHost` - Listen to host
      `listenPort` - Listen to port
      `securePort` - Use a secure port
      `udpPort` - Use UDP

  - ### setPayload

    public void setPayload(byte[] payload)
    Description copied from interface: `MembershipService`
    Set a payload to be broadcasted with each membership broadcast.
    Specified by:
      `setPayload` in interface `MembershipService`
    Parameters:
      `payload` - byte[]

  - ### setDomain

    public void setDomain(byte[] domain)
    Description copied from interface: `MembershipService`
    Set the associated domain.
    Specified by:
      `setDomain` in interface `MembershipService`
    Parameters:
      `domain` - the domain

  - ### getMembershipProvider

    public MembershipProvider getMembershipProvider()
    Description copied from interface: `MembershipService`
    Get the MembershipProvider
    Specified by:
      `getMembershipProvider` in interface `MembershipService`
    Returns:
      MembershipProvider

  - ### getStaticMembers

    public ArrayList<StaticMember> getStaticMembers()
    Returns the list of static members.
    Returns:
      the static members list

  - ### addStaticMember

    public void addStaticMember(StaticMember member)
    Adds a static member to the cluster.
    Parameters:
      `member` - the member to add

  - ### removeStaticMember

    public void removeStaticMember(StaticMember member)
    Removes a static member from the cluster.
    Parameters:
      `member` - the member to remove

  - ### setLocalMember

    public void setLocalMember(StaticMember member)
    Sets the local member for this service.
    Parameters:
      `member` - the local member

  - ### getExpirationTime

    public long getExpirationTime()
    Description copied from interface: `StaticMembershipServiceMBean`
    Returns the member expiration time in milliseconds.
    Specified by:
      `getExpirationTime` in interface `StaticMembershipServiceMBean`
    Returns:
      the expiration time

  - ### setExpirationTime

    public void setExpirationTime(long expirationTime)
    Sets the member expiration time in milliseconds.
    Parameters:
      `expirationTime` - the expiration time

  - ### getConnectTimeout

    public int getConnectTimeout()
    Description copied from interface: `StaticMembershipServiceMBean`
    Returns the connection timeout in milliseconds.
    Specified by:
      `getConnectTimeout` in interface `StaticMembershipServiceMBean`
    Returns:
      the connection timeout

  - ### setConnectTimeout

    public void setConnectTimeout(int connectTimeout)
    Sets the connection timeout in milliseconds.
    Parameters:
      `connectTimeout` - the connection timeout

  - ### getRpcTimeout

    public long getRpcTimeout()
    Description copied from interface: `StaticMembershipServiceMBean`
    Returns the RPC timeout in milliseconds.
    Specified by:
      `getRpcTimeout` in interface `StaticMembershipServiceMBean`
    Returns:
      the RPC timeout

  - ### setRpcTimeout

    public void setRpcTimeout(long rpcTimeout)
    Sets the RPC timeout in milliseconds.
    Parameters:
      `rpcTimeout` - the RPC timeout

  - ### getUseThread

    public boolean getUseThread()
    Description copied from interface: `StaticMembershipServiceMBean`
    Returns whether a background ping thread is in use.
    Specified by:
      `getUseThread` in interface `StaticMembershipServiceMBean`
    Returns:
      true if a background thread is used

  - ### setUseThread

    public void setUseThread(boolean useThread)
    Sets whether to use a background thread for pinging.
    Parameters:
      `useThread` - true to use a background thread

  - ### getPingInterval

    public long getPingInterval()
    Description copied from interface: `StaticMembershipServiceMBean`
    Returns the ping interval in milliseconds.
    Specified by:
      `getPingInterval` in interface `StaticMembershipServiceMBean`
    Returns:
      the ping interval

  - ### setPingInterval

    public void setPingInterval(long pingInterval)
    Sets the ping interval in milliseconds.
    Parameters:
      `pingInterval` - the ping interval

  - ### setProperties

    public void setProperties(Properties properties)
    Description copied from interface: `MembershipService`
    Sets the properties for the membership service. This must be called before the `start()` method is called. The properties are implementation specific.
    Specified by:
      `setProperties` in interface `MembershipService`
    Overrides:
      `setProperties` in class `MembershipServiceBase`
    Parameters:
      `properties` - - to be used to configure the membership service.

  - ### setDefaults

    protected void setDefaults(Properties properties)
    Sets default property values.
    Parameters:
      `properties` - the properties to configure