# Class StaticMembershipInterceptor

java.lang.Object
org.apache.catalina.tribes.group.ChannelInterceptorBase
org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor

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

public class StaticMembershipInterceptor extends ChannelInterceptorBase implements StaticMembershipInterceptorMBean
Channel interceptor that manages static membership for a cluster.

## Nested Class Summary

### Nested classes/interfaces inherited from interface ChannelInterceptor

`ChannelInterceptor.InterceptorEvent`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Member`
`localMember`
The local member for this interceptor.
`protected static final byte[]`
`MEMBER_START`
Payload sent when a member starts.
`protected static final byte[]`
`MEMBER_STOP`
Payload sent when a member shuts down.
`protected final ArrayList<Member>`
`members`
List of static members configured for this interceptor.
`protected static final StringManager`
`sm`
String manager for this class.

### Fields inherited from class ChannelInterceptorBase

`optionFlag`

## Constructor Summary

Constructors
Constructor
Description
`StaticMembershipInterceptor()`
Default constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`addStaticMember(Member member)`
Adds a static member to the membership list.
`protected ChannelInterceptor`
`getfirstInterceptor()`
Returns the first (bottom-most) interceptor in the chain.
`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
`boolean`
`hasMembers()`
Intercepts the `Channel.hasMembers()` method
`void`
`messageReceived(ChannelMessage msg)`
The `messageReceived` is invoked when a message is received.
`void`
`removeStaticMember(Member member)`
Removes a static member from the membership list.
`protected void`
`sendLocalMember(Member[] members)`
Sends a local member start message to the given members.
`protected void`
`sendMemberMessage(Member[] members, byte[] message)`
Sends a member message to the given members.
`protected void`
`sendShutdown(Member[] members)`
Sends a shutdown message to the given members.
`void`
`setLocalMember(Member member)`
Sets the local member for this interceptor.
`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, heartbeat, memberAdded, memberDisappeared, okToProcess, sendMessage, setChannel, setNext, setOptionFlag, setPrevious`

### Methods inherited from class Object

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

### Methods inherited from interface StaticMembershipInterceptorMBean

`getOptionFlag`

## Field Details

### sm

protected static final StringManager sm
String manager for this class.

### MEMBER_START

protected static final byte[] MEMBER_START
Payload sent when a member starts.

### MEMBER_STOP

protected static final byte[] MEMBER_STOP
Payload sent when a member shuts down.

### members

protected final ArrayList<Member> members
List of static members configured for this interceptor.

### localMember

protected Member localMember
The local member for this interceptor.

## Constructor Details

### StaticMembershipInterceptor

public StaticMembershipInterceptor()
Default constructor.

## Method Details

### addStaticMember

public void addStaticMember(Member member)
Adds a static member to the membership list.

Parameters:
  `member` - the member to add

### removeStaticMember

public void removeStaticMember(Member member)
Removes a static member from the membership list.

Parameters:
  `member` - the member to remove

### setLocalMember

public void setLocalMember(Member member)
Sets the local member for this interceptor.

Parameters:
  `member` - the local member

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

### 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`
Specified by:
  `getLocalMember` in interface `StaticMembershipInterceptorMBean`
Overrides:
  `getLocalMember` in class `ChannelInterceptorBase`
Parameters:
  `incAlive` - boolean
Returns:
  the member that represents this node
See Also:
  - `Channel.getLocalMember(boolean)`

### start

public void start(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

Sends notifications upwards.

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

Sends local member shutdown.

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`

### sendLocalMember

protected void sendLocalMember(Member[] members)
Sends a local member start message to the given members.

Parameters:
  `members` - the members to notify

### sendShutdown

protected void sendShutdown(Member[] members)
Sends a shutdown message to the given members.

Parameters:
  `members` - the members to notify

### getfirstInterceptor

protected ChannelInterceptor getfirstInterceptor()
Returns the first (bottom-most) interceptor in the chain.

Returns:
  the first channel interceptor

### sendMemberMessage

protected void sendMemberMessage(Member[] members, byte[] message) throws ChannelException
Sends a member message to the given members.

Parameters:
  `members` - the members to send to
  `message` - the message payload
Throws:
  `ChannelException` - if sending fails