Package org.apache.catalina.tribes.membership.cloud

# Class CloudMembershipService

java.lang.Object
org.apache.catalina.tribes.membership.MembershipServiceBase
org.apache.catalina.tribes.membership.cloud.CloudMembershipService

All Implemented Interfaces:
  `CloudMembershipServiceMBean`, `MembershipListener`, `MembershipService`

public class CloudMembershipService extends MembershipServiceBase implements CloudMembershipServiceMBean
A `MembershipService` that uses Kubernetes API(default) or DNS to retrieve the members of a cluster.

The default implementation of the MembershipProvider component is the `KubernetesMembershipProvider`. The MembershipProvider can be configured by the `membershipProviderClassName` property. Possible shortcuts are `kubernetes` and `dns`. For dns look at the `DNSMembershipProvider`.

Configuration example

`server.xml`

     <Server ...

       <Service ...

         <Engine ...

           <Host ...

             <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
               <Channel className="org.apache.catalina.tribes.group.GroupChannel">
                 <Membership className="org.apache.catalina.tribes.membership.cloud.CloudMembershipService"/>
               </Channel>
             </Cluster>
             ...

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static final byte[]`
`INITIAL_ID`
`static final String`
`MEMBERSHIP_PROVIDER_CLASS_NAME`
`protected static final StringManager`
`sm`

### Fields inherited from class org.apache.catalina.tribes.membership.MembershipServiceBase

`channel, listener, properties`

### Fields inherited from interface org.apache.catalina.tribes.MembershipService

`MBR_RX, MBR_TX`

## Constructor Summary

Constructors
Constructor
Description
`CloudMembershipService()`

## Method Summary

Modifier and Type
Method
Description
`int`
`getConnectTimeout()`
`long`
`getExpirationTime()`
`Member`
`getLocalMember(boolean incAliveTime)`
Get the local member.
`MembershipProvider`
`getMembershipProvider()`
Get the MembershipProvider
`String`
`getMembershipProviderClassName()`
Return the membership provider class.
`Object`
`getProperty(String name)`
Return a property.
`int`
`getReadTimeout()`
`void`
`setConnectTimeout(int connectTimeout)`
`void`
`setDomain(byte[] domain)`
`void`
`setExpirationTime(long expirationTime)`
`void`
`setLocalMemberProperties(String listenHost, int listenPort, int securePort, int udpPort)`
Sets the local member properties for broadcasting.
`void`
`setMembershipProvider(MembershipProvider memberProvider)`
`void`
`setMembershipProviderClassName(String membershipProviderClassName)`
Set the membership provider class.
`void`
`setPayload(byte[] payload)`
Set a payload to be broadcasted with each membership broadcast.
`boolean`
`setProperty(String name, String value)`
Set a property.
`void`
`setReadTimeout(int readTimeout)`
`void`
`start(int level)`
Starts the membership service.
`void`
`stop(int level)`
Starts the membership service.

### Methods inherited from class org.apache.catalina.tribes.membership.MembershipServiceBase

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

### 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.membership.cloud.CloudMembershipServiceMBean

`findMemberByName, getMembersByName, getProperties, hasMembers`

## Field Details

### sm

protected static final StringManager sm

### MEMBERSHIP_PROVIDER_CLASS_NAME

public static final String MEMBERSHIP_PROVIDER_CLASS_NAME

See Also:
  - Constant Field Values

### INITIAL_ID

protected static final byte[] INITIAL_ID

## Constructor Details

### CloudMembershipService

public CloudMembershipService()

## Method Details

### getProperty

public Object getProperty(String name)
Return a property.

Parameters:
  `name` - the property name
Returns:
  the property value

### setProperty

public boolean setProperty(String name, String value)
Set a property.

Parameters:
  `name` - the property name
  `value` - the property value
Returns:
  `true` if the property was successfully set

### getMembershipProviderClassName

public String getMembershipProviderClassName()
Return the membership provider class.

Returns:
  the classname

### setMembershipProviderClassName

public void setMembershipProviderClassName(String membershipProviderClassName)
Set the membership provider class.

Parameters:
  `membershipProviderClassName` - the class name

### 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 broad casting the server
Throws:
  `Exception` - if the service fails to start.
  `IllegalArgumentException` - if the level is incorrect.

### stop

public void stop(int level)
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:
  `stop` in interface `MembershipService`
Parameters:
  `level` - - level MBR_RX stops listening for members, level MBR_TX stops broad casting 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)

Specified by:
  `setDomain` in interface `MembershipService`

### getMembershipProvider

public MembershipProvider getMembershipProvider()
Description copied from interface: `MembershipService`
Get the MembershipProvider

Specified by:
  `getMembershipProvider` in interface `MembershipService`
Returns:
  MembershipProvider

### setMembershipProvider

public void setMembershipProvider(MembershipProvider memberProvider)

### getConnectTimeout

public int getConnectTimeout()

Specified by:
  `getConnectTimeout` in interface `CloudMembershipServiceMBean`

### setConnectTimeout

public void setConnectTimeout(int connectTimeout)

### getReadTimeout

public int getReadTimeout()

Specified by:
  `getReadTimeout` in interface `CloudMembershipServiceMBean`

### setReadTimeout

public void setReadTimeout(int readTimeout)

### getExpirationTime

public long getExpirationTime()

Specified by:
  `getExpirationTime` in interface `CloudMembershipServiceMBean`

### setExpirationTime

public void setExpirationTime(long expirationTime)