public class McastServiceImpl
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
McastServiceImpl.ReceiverThread |
protected static class |
McastServiceImpl.RecoveryThread |
class |
McastServiceImpl.SenderThread |
Modifier and Type | Field and Description |
---|---|
protected java.net.InetAddress |
address
The multicast address
|
protected boolean |
doRunReceiver |
protected boolean |
doRunSender
Internal flag used for the listen thread that listens to the multicasting socket.
|
protected java.util.concurrent.ExecutorService |
executor
Dont interrupt the sender/receiver thread, but pass off to an executor
|
protected java.lang.Object |
expiredMutex |
protected boolean |
localLoopbackDisabled
disable/enable local loopback message
|
protected static int |
MAX_PACKET_SIZE |
protected java.net.InetAddress |
mcastBindAddress
bind address
|
protected int |
mcastSoTimeout
Read timeout on the mcast socket
|
protected int |
mcastTTL
Time to live for the multicast packets that are being sent out
|
protected MemberImpl |
member
The local member that we intend to broad cast over and over again
|
protected Membership |
membership
The membership, used so that we calculate memberships when they arrive or don't arrive
|
protected MessageListener |
msgservice
The actual listener for broadcast callbacks
|
protected int |
port
The multicast port
|
protected java.net.DatagramPacket |
receivePacket
Reuse the receivePacket, no need to create a new one everytime
|
protected McastServiceImpl.ReceiverThread |
receiver
Thread to listen for pings
|
protected int |
recoveryCounter
nr of times the system has to fail before a recovery is initiated
|
protected boolean |
recoveryEnabled
Add the ability to turn on/off recovery
|
protected long |
recoverySleepTime
The time the recovery thread sleeps between recovery attempts
|
protected McastServiceImpl.SenderThread |
sender
Thread to send pings
|
protected long |
sendFrequency
How often to we send out a broadcast saying we are alive, must be smaller than timeToExpiration
|
protected java.net.DatagramPacket |
sendPacket
Reuse the sendPacket, no need to create a new one everytime
|
protected MembershipListener |
service
The actual listener, for callback when stuff goes down
|
protected java.net.MulticastSocket |
socket
Socket that we intend to listen to
|
protected int |
startLevel |
protected long |
timeToExpiration
The time it takes for a member to expire.
|
Constructor and Description |
---|
McastServiceImpl(MemberImpl member,
long sendFrequency,
long expireTime,
int port,
java.net.InetAddress bind,
java.net.InetAddress mcastAddress,
int ttl,
int soTimeout,
MembershipListener service,
MessageListener msgservice,
boolean localLoopbackDisabled)
Create a new mcast service impl
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkExpired() |
int |
getRecoveryCounter() |
long |
getRecoverySleepTime() |
long |
getServiceStartTime() |
void |
init() |
boolean |
isRecoveryEnabled() |
void |
receive()
Receive a datagram packet, locking wait
|
void |
send(boolean checkexpired)
Send a ping
|
void |
send(boolean checkexpired,
java.net.DatagramPacket packet) |
void |
setRecoveryCounter(int recoveryCounter) |
void |
setRecoveryEnabled(boolean recoveryEnabled) |
void |
setRecoverySleepTime(long recoverySleepTime) |
protected void |
setupSocket() |
void |
start(int level)
Start the service
|
boolean |
stop(int level)
Stops the service
|
protected static int MAX_PACKET_SIZE
protected volatile boolean doRunSender
protected volatile boolean doRunReceiver
protected int startLevel
protected java.net.MulticastSocket socket
protected MemberImpl member
protected java.net.InetAddress address
protected int port
protected long timeToExpiration
protected long sendFrequency
protected java.net.DatagramPacket sendPacket
protected java.net.DatagramPacket receivePacket
protected Membership membership
protected MembershipListener service
protected MessageListener msgservice
protected McastServiceImpl.ReceiverThread receiver
protected McastServiceImpl.SenderThread sender
protected int mcastTTL
protected int mcastSoTimeout
protected java.net.InetAddress mcastBindAddress
protected int recoveryCounter
protected long recoverySleepTime
protected boolean recoveryEnabled
protected java.util.concurrent.ExecutorService executor
protected boolean localLoopbackDisabled
protected final java.lang.Object expiredMutex
public McastServiceImpl(MemberImpl member, long sendFrequency, long expireTime, int port, java.net.InetAddress bind, java.net.InetAddress mcastAddress, int ttl, int soTimeout, MembershipListener service, MessageListener msgservice, boolean localLoopbackDisabled) throws java.io.IOException
member
- - the local membersendFrequency
- - the time (ms) in between pings sent outexpireTime
- - the time (ms) for a member to expireport
- - the mcast portbind
- - the bind address (not sure this is used yet)mcastAddress
- - the mcast addressservice
- - the callback servicelocalLoopbackDisabled
- - disable loopbackModejava.io.IOException
public void init() throws java.io.IOException
java.io.IOException
protected void setupSocket() throws java.io.IOException
java.io.IOException
public void start(int level) throws java.io.IOException
level
- 1 starts the receiver, level 2 starts the senderjava.io.IOException
- if the service fails to startjava.lang.IllegalStateException
- if the service is already startedpublic boolean stop(int level) throws java.io.IOException
java.io.IOException
- if the service fails to disconnect from the socketspublic void receive() throws java.io.IOException
java.io.IOException
protected void checkExpired()
public void send(boolean checkexpired) throws java.io.IOException
java.io.IOException
public void send(boolean checkexpired, java.net.DatagramPacket packet) throws java.io.IOException
java.io.IOException
public long getServiceStartTime()
public int getRecoveryCounter()
public boolean isRecoveryEnabled()
public long getRecoverySleepTime()
public void setRecoveryCounter(int recoveryCounter)
public void setRecoveryEnabled(boolean recoveryEnabled)
public void setRecoverySleepTime(long recoverySleepTime)
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.