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
Modifier and TypeFieldDescriptionprotected static final byte[]
static final String
protected static final StringManager
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
-
Method Summary
Modifier and TypeMethodDescriptionint
long
getLocalMember
(boolean incAliveTime) Get the local member.Get the MembershipProviderReturn the membership provider class.getProperty
(String name) Return a property.int
void
setConnectTimeout
(int connectTimeout) void
setDomain
(byte[] domain) Set the associated 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) Stops 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
-
MEMBERSHIP_PROVIDER_CLASS_NAME
- See Also:
-
INITIAL_ID
protected static final byte[] INITIAL_ID
-
-
Constructor Details
-
CloudMembershipService
public CloudMembershipService()
-
-
Method Details
-
getProperty
-
setProperty
-
getMembershipProviderClassName
Return the membership provider class.- Returns:
- the classname
-
setMembershipProviderClassName
Set the membership provider class.- Parameters:
membershipProviderClassName
- the class name
-
start
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 interfaceMembershipService
- 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.
-
stop
public void stop(int level) Description copied from interface:MembershipService
Stops the membership service. If a membership listeners is added the listener will start to receive membership events.- Specified by:
stop
in interfaceMembershipService
- Parameters:
level
- - level MBR_RX stops listening for members, level MBR_TX stops broad casting the server
-
getLocalMember
Description copied from interface:MembershipService
Get the local member.- Specified by:
getLocalMember
in interfaceMembershipService
- 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 interfaceMembershipService
- Parameters:
listenHost
- Listen to hostlistenPort
- Listen to portsecurePort
- Use a secure portudpPort
- 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 interfaceMembershipService
- Parameters:
payload
- byte[]
-
setDomain
public void setDomain(byte[] domain) Description copied from interface:MembershipService
Set the associated domain.- Specified by:
setDomain
in interfaceMembershipService
- Parameters:
domain
- the domain
-
getMembershipProvider
Description copied from interface:MembershipService
Get the MembershipProvider- Specified by:
getMembershipProvider
in interfaceMembershipService
- Returns:
- MembershipProvider
-
setMembershipProvider
-
getConnectTimeout
public int getConnectTimeout()- Specified by:
getConnectTimeout
in interfaceCloudMembershipServiceMBean
-
setConnectTimeout
public void setConnectTimeout(int connectTimeout) -
getReadTimeout
public int getReadTimeout()- Specified by:
getReadTimeout
in interfaceCloudMembershipServiceMBean
-
setReadTimeout
public void setReadTimeout(int readTimeout) -
getExpirationTime
public long getExpirationTime()- Specified by:
getExpirationTime
in interfaceCloudMembershipServiceMBean
-
setExpirationTime
public void setExpirationTime(long expirationTime)
-