public class McastService extends java.lang.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 java.util.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(java.lang.String name)
Return the member by name
|
java.lang.String |
getAddress() |
java.lang.String |
getBind() |
byte[] |
getDomain() |
long |
getDropTime() |
long |
getFrequency() |
java.lang.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
|
java.lang.String |
getLocalMemberName()
Return the local member name
|
java.lang.String |
getMcastAddr()
Deprecated.
use getAddress
|
java.lang.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.
|
java.lang.String[] |
getMembersByName()
Return all the members by name
|
byte[] |
getPayload() |
int |
getPort() |
java.util.Properties |
getProperties()
Return the properties, see setProperties
|
int |
getRecoveryCounter() |
boolean |
getRecoveryEnabled() |
long |
getRecoverySleepTime() |
int |
getSoTimeout() |
int |
getTtl() |
boolean |
hasMembers()
has members?
|
protected void |
hasProperty(java.util.Properties properties,
java.lang.String name)
Check if a required property is available.
|
static void |
main(java.lang.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(java.lang.String addr) |
void |
setBind(java.lang.String bindaddr) |
void |
setDomain(byte[] domain) |
void |
setDomain(java.lang.String domain) |
void |
setDropTime(long time) |
void |
setFrequency(long time) |
void |
setLocalLoopbackDisabled(boolean localLoopbackDisabled) |
void |
setLocalMemberProperties(java.lang.String listenHost,
int listenPort,
int securePort,
int udpPort)
Sets the local member properties for broadcasting
|
void |
setMcastAddr(java.lang.String addr)
Deprecated.
use setAddress
|
void |
setMcastBindAddress(java.lang.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(java.util.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 java.util.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 java.lang.String getInfo()
<description>/<version>
.public void setProperties(java.util.Properties properties)
MembershipService
start()
method is called.
The properties are implementation specific.setProperties
in interface MembershipService
properties
- java.lang.IllegalArgumentException
- if a property is missing.public java.util.Properties getProperties()
getProperties
in interface MembershipService
public java.lang.String getLocalMemberName()
public Member getLocalMember(boolean alive)
getLocalMember
in interface MembershipService
public void setLocalMemberProperties(java.lang.String listenHost, int listenPort, int securePort, int udpPort)
setLocalMemberProperties
in interface MembershipService
public void setAddress(java.lang.String addr)
@Deprecated public void setMcastAddr(java.lang.String addr)
addr
- Stringpublic java.lang.String getAddress()
@Deprecated public java.lang.String getMcastAddr()
public void setMcastBindAddress(java.lang.String bindaddr)
public void setBind(java.lang.String bindaddr)
@Deprecated public java.lang.String getMcastBindAddress()
public java.lang.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(java.util.Properties properties, java.lang.String name)
properties
- The set of propertiesname
- The property to check forpublic void start() throws java.lang.Exception
start
in interface MembershipService
java.lang.Exception
- if a IO error occurspublic void start(int level) throws java.lang.Exception
MembershipService
start
in interface MembershipService
level
- - level MBR_RX starts listening for members, level MBR_TX
starts broad casting the serverjava.lang.Exception
- if the service fails to start.java.lang.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 java.lang.String[] getMembersByName()
getMembersByName
in interface MembershipService
public Member findMemberByName(java.lang.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(java.lang.String domain)
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- Command-line argumentsjava.lang.Exception
- If an error occursCopyright © 2000-2015 Apache Software Foundation. All Rights Reserved.