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

## Class CloudMembershipProvider

- java.lang.Object
- - org.apache.catalina.tribes.membership.MembershipProviderBase
  - - org.apache.catalina.tribes.membership.cloud.CloudMembershipProvider

- All Implemented Interfaces:
    `ChannelListener`, `Heartbeat`, `MembershipProvider`
  Direct Known Subclasses:
    `DNSMembershipProvider`, `KubernetesMembershipProvider`

      public abstract class CloudMembershipProvider
      extends MembershipProviderBase
      implements Heartbeat, ChannelListener

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected int` | `connectionTimeout` |
    `protected static java.lang.String` | `CUSTOM_ENV_PREFIX` |
    `protected long` | `expirationTime` |
    `protected java.util.Map<java.lang.String,​java.lang.String>` | `headers` |
    `protected java.lang.String` | `localIp` |
    `protected java.security.MessageDigest` | `md5` |
    `protected int` | `port` |
    `protected int` | `readTimeout` |
    `protected static StringManager` | `sm` |
    `protected java.time.Instant` | `startTime` |
    `protected StreamProvider` | `streamProvider` |
    `protected java.lang.String` | `url` |

    - ### Fields inherited from class org.apache.catalina.tribes.membership.MembershipProviderBase

      `executor, membership, membershipListener, service`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CloudMembershipProvider()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `accept​(java.io.Serializable msg, Member sender)` | Invoked by the channel to determine if the listener will process this message or not.
    `protected abstract Member[]` | `fetchMembers()` | Fetch current cluster members from the cloud orchestration.
    `protected static java.lang.String` | `getEnv​(java.lang.String... keys)` | Get value of environment variable.
    `protected java.lang.String` | `getNamespace()` | Get the Kubernetes namespace, or "tomcat" if the Kubernetes environment variable cannot be found (with a warning log about the missing namespace).
    `void` | `heartbeat()` | Heartbeat invocation for resources cleanup etc
    `void` | `init​(java.util.Properties properties)` |
    `void` | `messageReceived​(java.io.Serializable msg, Member sender)` | Receive a message from the channel
    `void` | `start​(int level)` |
    `boolean` | `stop​(int level)` |
    `protected void` | `updateMember​(Member member, boolean add)` | Add or remove specified member.

    - ### Methods inherited from class org.apache.catalina.tribes.membership.MembershipProviderBase

      `getMember, getMembers, hasMembers, setMembershipListener, setMembershipService`

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

      `equals, hashCode`

- - ### Field Detail

    - #### sm

          protected static final StringManager sm

    - #### CUSTOM_ENV_PREFIX

          protected static final java.lang.String CUSTOM_ENV_PREFIX

      See Also:
        Constant Field Values

    - #### url

          protected java.lang.String url

    - #### streamProvider

          protected StreamProvider streamProvider

    - #### connectionTimeout

          protected int connectionTimeout

    - #### readTimeout

          protected int readTimeout

    - #### startTime

          protected java.time.Instant startTime

    - #### md5

          protected java.security.MessageDigest md5

    - #### headers

          protected java.util.Map<java.lang.String,​java.lang.String> headers

    - #### localIp

          protected java.lang.String localIp

    - #### port

          protected int port

    - #### expirationTime

          protected long expirationTime

  - ### Constructor Detail

    - #### CloudMembershipProvider

          public CloudMembershipProvider()

  - ### Method Detail

    - #### getEnv

          protected static java.lang.String getEnv​(java.lang.String... keys)

      Get value of environment variable.
      Parameters:
        `keys` - the environment variables
      Returns:
        the env variables values, or null if not found

    - #### getNamespace

          protected java.lang.String getNamespace()

      Get the Kubernetes namespace, or "tomcat" if the Kubernetes environment variable cannot be found (with a warning log about the missing namespace).
      Returns:
        the namespace

    - #### init

          public void init​(java.util.Properties properties)
                    throws java.io.IOException

      Specified by:
        `init` in interface `MembershipProvider`
      Overrides:
        `init` in class `MembershipProviderBase`
      Throws:
        `java.io.IOException`

    - #### start

          public void start​(int level)
                     throws java.lang.Exception

      Specified by:
        `start` in interface `MembershipProvider`
      Throws:
        `java.lang.Exception`

    - #### stop

          public boolean stop​(int level)
                       throws java.lang.Exception

      Specified by:
        `stop` in interface `MembershipProvider`
      Throws:
        `java.lang.Exception`

    - #### heartbeat

          public void heartbeat()

      Description copied from interface: `Heartbeat`
      Heartbeat invocation for resources cleanup etc
      Specified by:
        `heartbeat` in interface `Heartbeat`

    - #### fetchMembers

          protected abstract Member[] fetchMembers()

      Fetch current cluster members from the cloud orchestration.
      Returns:
        the member array

    - #### updateMember

          protected void updateMember​(Member member,
                                      boolean add)

      Add or remove specified member.
      Parameters:
        `member` - the member to add
        `add` - true if the member is added, false otherwise

    - #### messageReceived

          public void messageReceived​(java.io.Serializable msg,
                                      Member sender)

      Description copied from interface: `ChannelListener`
      Receive a message from the channel
      Specified by:
        `messageReceived` in interface `ChannelListener`
      Parameters:
        `msg` - Serializable
        `sender` - - the source of the message

    - #### accept

          public boolean accept​(java.io.Serializable msg,
                                Member sender)

      Description copied from interface: `ChannelListener`
      Invoked by the channel to determine if the listener will process this message or not.
      Specified by:
        `accept` in interface `ChannelListener`
      Parameters:
        `msg` - Serializable
        `sender` - Member
      Returns:
        boolean