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() |
Channel |
getChannel() |
byte[] |
getDomain() |
long |
getDropTime() |
long |
getFrequency() |
String |
getInfo()
Return descriptive information about this implementation and the
corresponding version number, in the format
<description>/<version> . |
boolean |
getLocalLoopbackDisabled(boolean localLoopbackDisabled) |
Member |
getLocalMember(boolean alive)
Return the local member
|
String |
getLocalMemberName()
Return the local member name
|
String |
getMcastAddr()
Deprecated.
use getAddress
|
String |
getMcastBindAddress()
Deprecated.
use getBind
|
long |
getMcastDropTime()
Deprecated.
use getDropTime
|
long |
getMcastFrequency()
Deprecated.
use getFrequency
|
int |
getMcastPort()
Deprecated.
use getPort()
|
int |
getMcastSoTimeout()
Deprecated.
use getSoTimeout
|
int |
getMcastTTL()
Deprecated.
use getTtl
|
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 |
setChannel(Channel channel) |
protected void |
setDefaults(Properties properties) |
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 |
setMcastAddr(String addr)
Deprecated.
use setAddress
|
void |
setMcastBindAddress(String bindaddr) |
void |
setMcastDropTime(long time) |
void |
setMcastFrequency(long time)
Deprecated.
use setFrequency
|
void |
setMcastPort(int port)
Deprecated.
use setPort
|
void |
setMcastSoTimeout(int mcastSoTimeout)
Deprecated.
use setSoTimeout
|
void |
setMcastTTL(int mcastTTL)
Deprecated.
use setTtl
|
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
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals, hashCode
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 String getInfo()
<description>/<version>
.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)
@Deprecated public void setMcastAddr(String addr)
addr
- Stringpublic String getAddress()
@Deprecated public String getMcastAddr()
public void setMcastBindAddress(String bindaddr)
public void setBind(String bindaddr)
@Deprecated public String getMcastBindAddress()
public String getBind()
@Deprecated public void setMcastPort(int port)
port
- intpublic 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(boolean localLoopbackDisabled)
@Deprecated public int getMcastPort()
public int getPort()
@Deprecated public void setMcastFrequency(long time)
time
- longpublic void setFrequency(long time)
@Deprecated public long getMcastFrequency()
public long getFrequency()
public void setMcastDropTime(long time)
public void setDropTime(long time)
@Deprecated public long getMcastDropTime()
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
@Deprecated public int getMcastSoTimeout()
public int getSoTimeout()
@Deprecated public void setMcastSoTimeout(int mcastSoTimeout)
mcastSoTimeout
- intpublic void setSoTimeout(int mcastSoTimeout)
@Deprecated public int getMcastTTL()
public int getTtl()
public byte[] getPayload()
public byte[] getDomain()
@Deprecated public void setMcastTTL(int mcastTTL)
mcastTTL
- intpublic 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)
public Channel getChannel()
public void setChannel(Channel channel)
protected void setDefaults(Properties properties)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.