public class McastService extends Object implements MembershipService, MembershipListener, MessageListener
Modifier and Type | Field and Description |
---|---|
protected byte[] |
domain |
protected static Member[] |
EMPTY_MEMBERS
Return all the members
|
protected McastServiceImpl |
impl
A handle to the actual low level implementation
|
protected MembershipListener |
listener
A membership listener delegate (should be the cluster :)
|
protected MemberImpl |
localMember
The local member
|
protected MessageListener |
msglistener
A message listener delegate for broadcasts
|
protected byte[] |
payload |
protected Properties |
properties
The implementation specific properties
|
protected static StringManager |
sm
The string manager for this package.
|
MBR_RX, MBR_TX
Constructor and Description |
---|
McastService()
Create a membership service.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(ChannelMessage msg) |
void |
broadcast(ChannelMessage message)
Broadcasts a message to all members
|
Member |
findMemberByName(String name)
Return the member by name
|
String |
getAddress() |
String |
getBind() |
byte[] |
getDomain() |
long |
getDropTime() |
long |
getFrequency() |
boolean |
getLocalLoopbackDisabled() |
Member |
getLocalMember(boolean alive)
Return the local member
|
String |
getLocalMemberName()
Return the local member name
|
Member |
getMember(Member mbr) |
Member[] |
getMembers()
Returns a list of all the members in the cluster.
|
String[] |
getMembersByName()
Return all the members by name
|
byte[] |
getPayload() |
int |
getPort() |
Properties |
getProperties()
Return the properties, see setProperties
|
int |
getRecoveryCounter() |
boolean |
getRecoveryEnabled() |
long |
getRecoverySleepTime() |
int |
getSoTimeout() |
int |
getTtl() |
boolean |
hasMembers()
has members?
|
protected void |
hasProperty(Properties properties,
String name)
Check if a required property is available.
|
static void |
main(String[] args)
Simple test program
|
void |
memberAdded(Member member)
A member was added to the group
|
void |
memberDisappeared(Member member)
Callback from the impl when a new member has been received
|
void |
messageReceived(ChannelMessage msg)
Receive a message from the IO components in the Channel stack
|
void |
removeMembershipListener()
Remove the membership listener
|
void |
removeMessageListener() |
void |
setAddress(String addr) |
void |
setBind(String bindaddr) |
void |
setDomain(byte[] domain) |
void |
setDomain(String domain) |
void |
setDropTime(long time) |
void |
setFrequency(long time) |
void |
setLocalLoopbackDisabled(boolean localLoopbackDisabled) |
void |
setLocalMemberProperties(String listenHost,
int listenPort,
int securePort,
int udpPort)
Sets the local member properties for broadcasting
|
void |
setMcastBindAddress(String bindaddr) |
void |
setMcastDropTime(long time) |
void |
setMembershipListener(MembershipListener listener)
Add a membership listener, this version only supports one listener per service,
so calling this method twice will result in only the second listener being active.
|
void |
setMessageListener(MessageListener listener) |
void |
setPayload(byte[] payload)
Set a payload to be broadcasted with each membership
broadcast.
|
void |
setPort(int port) |
void |
setProperties(Properties properties)
Sets the properties for the membership service.
|
void |
setRecoveryCounter(int recoveryCounter) |
void |
setRecoveryEnabled(boolean recoveryEnabled) |
void |
setRecoverySleepTime(long recoverySleepTime) |
void |
setSoTimeout(int mcastSoTimeout) |
void |
setTtl(int mcastTTL) |
void |
start()
Start broadcasting and listening to membership pings
|
void |
start(int level)
Starts the membership service.
|
void |
stop(int svc)
Stop broadcasting and listening to membership pings
|
protected static final StringManager sm
protected Properties properties
protected McastServiceImpl impl
protected MembershipListener listener
protected MessageListener msglistener
protected MemberImpl localMember
protected byte[] payload
protected byte[] domain
protected static final Member[] EMPTY_MEMBERS
public void setProperties(Properties properties)
MembershipService
start()
method is called.
The properties are implementation specific.setProperties
in interface MembershipService
properties
- IllegalArgumentException
- if a property is missing.public Properties getProperties()
getProperties
in interface MembershipService
public String getLocalMemberName()
public Member getLocalMember(boolean alive)
getLocalMember
in interface MembershipService
public void setLocalMemberProperties(String listenHost, int listenPort, int securePort, int udpPort)
setLocalMemberProperties
in interface MembershipService
public void setAddress(String addr)
public String getAddress()
public void setMcastBindAddress(String bindaddr)
public void setBind(String bindaddr)
public String getBind()
public void setPort(int port)
public void setRecoveryCounter(int recoveryCounter)
public int getRecoveryCounter()
public void setRecoveryEnabled(boolean recoveryEnabled)
public boolean getRecoveryEnabled()
public void setRecoverySleepTime(long recoverySleepTime)
public long getRecoverySleepTime()
public void setLocalLoopbackDisabled(boolean localLoopbackDisabled)
public boolean getLocalLoopbackDisabled()
public int getPort()
public void setFrequency(long time)
public long getFrequency()
public void setMcastDropTime(long time)
public void setDropTime(long time)
public long getDropTime()
protected void hasProperty(Properties properties, String name)
properties
- The set of propertiesname
- The property to check forpublic void start() throws Exception
start
in interface MembershipService
Exception
- if a IO error occurspublic void start(int level) throws Exception
MembershipService
start
in interface MembershipService
level
- - level MBR_RX starts listening for members, level MBR_TX
starts broad casting the serverException
- if the service fails to start.IllegalArgumentException
- if the level is incorrect.public void stop(int svc)
stop
in interface MembershipService
svc
- - level MBR_RX stops listening for members, level MBR_TX
stops broad casting the serverpublic String[] getMembersByName()
getMembersByName
in interface MembershipService
public Member findMemberByName(String name)
findMemberByName
in interface MembershipService
public boolean hasMembers()
hasMembers
in interface MembershipService
public Member getMember(Member mbr)
getMember
in interface MembershipService
mbr
- Memberpublic Member[] getMembers()
MembershipService
getMembers
in interface MembershipService
public void setMembershipListener(MembershipListener listener)
setMembershipListener
in interface MembershipService
listener
- The listenerpublic void setMessageListener(MessageListener listener)
public void removeMessageListener()
public void removeMembershipListener()
removeMembershipListener
in interface MembershipService
public void memberAdded(Member member)
MembershipListener
memberAdded
in interface MembershipListener
member
- Member - the member that was addedpublic void memberDisappeared(Member member)
memberDisappeared
in interface MembershipListener
member
- The memberMember.SHUTDOWN_PAYLOAD
public void messageReceived(ChannelMessage msg)
MessageListener
messageReceived
in interface MessageListener
msg
- ChannelMessagepublic boolean accept(ChannelMessage msg)
accept
in interface MessageListener
public void broadcast(ChannelMessage message) throws ChannelException
MembershipService
broadcast
in interface MembershipService
ChannelException
public int getSoTimeout()
public void setSoTimeout(int mcastSoTimeout)
public int getTtl()
public byte[] getPayload()
public byte[] getDomain()
public void setTtl(int mcastTTL)
public void setPayload(byte[] payload)
MembershipService
setPayload
in interface MembershipService
payload
- byte[]public void setDomain(byte[] domain)
setDomain
in interface MembershipService
public void setDomain(String domain)
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.