DNSMembershipProvider (Apache Tomcat 9.0.68 API Documentation)

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

## Class DNSMembershipProvider

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

- All Implemented Interfaces:
    `ChannelListener`, `Heartbeat`, `MembershipProvider`

      public class DNSMembershipProvider
      extends CloudMembershipProvider

  A `MembershipProvider` that uses DNS to retrieve the members of a cluster.

  Configuration example for Kubernetes

  `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"
                       membershipProviderClassName="org.apache.catalina.tribes.membership.cloud.DNSMembershipProvider"/>
                 </Channel>
               </Cluster>
               ...

  `dns-membership-service.yml`

       apiVersion: v1
       kind: Service
       metadata:
         annotations:
           service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
           description: "The service for tomcat cluster membership."
         name: my-tomcat-app-membership
       spec:
         clusterIP: None
         ports:
         - name: membership
           port: 8888
         selector:
           app: my-tomcat-app

  Environment variable configuration
  `DNS_MEMBERSHIP_SERVICE_NAME=my-tomcat-app-membership`

- - ### Field Summary

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

      `connectionTimeout, CUSTOM_ENV_PREFIX, expirationTime, headers, localIp, md5, port, readTimeout, sm, startTime, streamProvider, url`

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

      `executor, membership, membershipListener, service`

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance 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 Member[]` | `fetchMembers()` | Fetch current cluster members from the cloud orchestration.
    `void` | `start​(int level)` |
    `boolean` | `stop​(int level)` |

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

      `getEnv, getNamespace, heartbeat, init, messageReceived, updateMember`

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

- - ### Constructor Detail

    - #### DNSMembershipProvider

          public DNSMembershipProvider()

  - ### Method Detail

    - #### start

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

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

    - #### stop

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

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

    - #### fetchMembers

          protected Member[] fetchMembers()

      Description copied from class: `CloudMembershipProvider`
      Fetch current cluster members from the cloud orchestration.
      Specified by:
        `fetchMembers` in class `CloudMembershipProvider`
      Returns:
        the member array

    - #### 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`
      Overrides:
        `accept` in class `CloudMembershipProvider`
      Parameters:
        `msg` - Serializable
        `sender` - Member
      Returns:
        boolean