Interface MembershipService
- All Known Implementing Classes:
CloudMembershipService, McastService, MembershipServiceBase, StaticMembershipService
public interface MembershipService
The
MembershipService interface is the membership component at the bottom layer, the IO layer (for
layers see the javadoc for the Channel interface).-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidbroadcast(ChannelMessage message) Broadcasts a message to all members.findMemberByName(String name) Get a member.Return the channel that is related to this MembershipServicegetLocalMember(boolean incAliveTime) Get the local member.Retrieve the specified member from the membership.Member[]Returns all members currently in the cluster.String[]Returns the names of all members in the cluster.Get the MembershipProviderReturns the properties used to configure the membership service.booleanChecks whether the membership group contains any members.voidRemoves the membership listener.voidsetChannel(Channel channel) Set the channel that is related to this MembershipServicevoidsetDomain(byte[] domain) Set the associated domain.voidsetLocalMemberProperties(String listenHost, int listenPort, int securePort, int udpPort) Sets the local member properties for broadcasting.voidsetMembershipListener(MembershipListener listener) Sets the membership listener, only one listener can be added.voidsetPayload(byte[] payload) Set a payload to be broadcasted with each membership broadcast.voidsetProperties(Properties properties) Sets the properties for the membership service.voidstart()Starts the membership service.voidstart(int level) Starts the membership service.voidstop(int level) Stops the membership service.
-
Field Details
-
MBR_RX
static final int MBR_RXReceive level.- See Also:
-
MBR_TX
static final int MBR_TXTransmit level.- See Also:
-
-
Method Details
-
setProperties
Sets the properties for the membership service. This must be called before thestart()method is called. The properties are implementation specific.- Parameters:
properties- - to be used to configure the membership service.
-
getProperties
Properties getProperties()Returns the properties used to configure the membership service.- Returns:
- the properties for the configuration used
-
start
-
start
Starts the membership service. If a membership listeners is added the listener will start to receive membership events.- Parameters:
level- - level MBR_RX starts listening for members, level MBR_TX starts broadcasting the server- Throws:
Exception- if the service fails to start.IllegalArgumentException- if the level is incorrect.
-
stop
void stop(int level) Stops the membership service. If a membership listeners is added the listener will start to receive membership events.- Parameters:
level- - level MBR_RX stops listening for members, level MBR_TX stops broadcasting the server- Throws:
IllegalArgumentException- if the level is incorrect.
-
hasMembers
boolean hasMembers()Checks whether the membership group contains any members.- Returns:
- true if the group contains members
-
getMember
-
getMembers
Member[] getMembers()Returns all members currently in the cluster.- Returns:
- an array of all the members in the cluster
-
getLocalMember
Get the local member.- Parameters:
incAliveTime-trueto set the alive time on the local member- Returns:
- the member object that defines this member
-
getMembersByName
String[] getMembersByName()Returns the names of all members in the cluster.- Returns:
- all members by name
-
findMemberByName
-
setLocalMemberProperties
Sets the local member properties for broadcasting.- Parameters:
listenHost- Listen to hostlistenPort- Listen to portsecurePort- Use a secure portudpPort- Use UDP
-
setMembershipListener
Sets the membership listener, only one listener can be added. If you call this method twice, the last listener will be used.- Parameters:
listener- The listener
-
removeMembershipListener
void removeMembershipListener()Removes the membership listener. -
setPayload
void setPayload(byte[] payload) Set a payload to be broadcasted with each membership broadcast.- Parameters:
payload- byte[]
-
setDomain
void setDomain(byte[] domain) Set the associated domain.- Parameters:
domain- the domain
-
broadcast
Broadcasts a message to all members.- Parameters:
message- The message to broadcast- Throws:
ChannelException- Message broadcast failed
-
getChannel
-
setChannel
Set the channel that is related to this MembershipService- Parameters:
channel- The channel
-
getMembershipProvider
-