Class MembershipServiceBase
java.lang.Object
org.apache.catalina.tribes.membership.MembershipServiceBase
- All Implemented Interfaces:
MembershipListener
,MembershipService
- Direct Known Subclasses:
CloudMembershipService
,McastService
,StaticMembershipService
public abstract class MembershipServiceBase
extends Object
implements MembershipService, MembershipListener
-
Field Summary
Modifier and TypeFieldDescriptionprotected Channel
protected MembershipListener
protected Properties
The implementation specific propertiesFields inherited from interface org.apache.catalina.tribes.MembershipService
MBR_RX, MBR_TX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
broadcast
(ChannelMessage message) Broadcasts a message to all members.findMemberByName
(String name) Get a member.Return the channel that is related to this MembershipServiceRetrieve the specified member from the membership.Member[]
String[]
boolean
void
memberAdded
(Member member) A member was added to the groupvoid
memberDisappeared
(Member member) A member was removed from the group
If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD datavoid
Removes the membership listener.void
setChannel
(Channel channel) Set the channel that is related to this MembershipServicevoid
setMembershipListener
(MembershipListener listener) Sets the membership listener, only one listener can be added.void
setProperties
(Properties properties) Sets the properties for the membership service.void
start()
Starts the membership service.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.MembershipService
getLocalMember, getMembershipProvider, setDomain, setLocalMemberProperties, setPayload, start, stop
-
Field Details
-
properties
The implementation specific properties -
listener
-
channel
-
-
Constructor Details
-
MembershipServiceBase
public MembershipServiceBase()
-
-
Method Details
-
setProperties
Description copied from interface:MembershipService
Sets the properties for the membership service. This must be called before thestart()
method is called. The properties are implementation specific.- Specified by:
setProperties
in interfaceMembershipService
- Parameters:
properties
- - to be used to configure the membership service.
-
getProperties
- Specified by:
getProperties
in interfaceMembershipService
- Returns:
- the properties for the configuration used.
-
hasMembers
public boolean hasMembers()- Specified by:
hasMembers
in interfaceMembershipService
- Returns:
- true if the the group contains members
-
getMember
Description copied from interface:MembershipService
Retrieve the specified member from the membership.- Specified by:
getMember
in interfaceMembershipService
- Parameters:
mbr
- The member to retrieve- Returns:
- the member
-
getMembers
- Specified by:
getMembers
in interfaceMembershipService
- Returns:
- a list of all the members in the cluster.
-
getMembersByName
- Specified by:
getMembersByName
in interfaceMembershipService
- Returns:
- all members by name
-
findMemberByName
Description copied from interface:MembershipService
Get a member.- Specified by:
findMemberByName
in interfaceMembershipService
- Parameters:
name
- The member name- Returns:
- the member
-
setMembershipListener
Description copied from interface:MembershipService
Sets the membership listener, only one listener can be added. If you call this method twice, the last listener will be used.- Specified by:
setMembershipListener
in interfaceMembershipService
- Parameters:
listener
- The listener
-
removeMembershipListener
public void removeMembershipListener()Description copied from interface:MembershipService
Removes the membership listener.- Specified by:
removeMembershipListener
in interfaceMembershipService
-
memberAdded
Description copied from interface:MembershipListener
A member was added to the group- Specified by:
memberAdded
in interfaceMembershipListener
- Parameters:
member
- Member - the member that was added
-
memberDisappeared
Description copied from interface:MembershipListener
A member was removed from the group
If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD data- Specified by:
memberDisappeared
in interfaceMembershipListener
- Parameters:
member
- Member- See Also:
-
broadcast
Description copied from interface:MembershipService
Broadcasts a message to all members.- Specified by:
broadcast
in interfaceMembershipService
- Parameters:
message
- The message to broadcast- Throws:
ChannelException
- Message broadcast failed
-
getChannel
Description copied from interface:MembershipService
Return the channel that is related to this MembershipService- Specified by:
getChannel
in interfaceMembershipService
- Returns:
- Channel
-
setChannel
Description copied from interface:MembershipService
Set the channel that is related to this MembershipService- Specified by:
setChannel
in interfaceMembershipService
- Parameters:
channel
- The channel
-
start
Description copied from interface:MembershipService
Starts the membership service. If a membership listeners is added the listener will start to receive membership events. Performs a start level 1 and 2- Specified by:
start
in interfaceMembershipService
- Throws:
Exception
- if the service fails to start.
-