org.apache.catalina.tribes.membership
public class McastServiceImpl extends Object
Version: $Revision: 787702 $, $Date: 2009-06-23 17:16:48 +0200 (Tue, 23 Jun 2009) $
Nested Class Summary | |
---|---|
class | McastServiceImpl.ReceiverThread |
protected static class | McastServiceImpl.RecoveryThread |
class | McastServiceImpl.SenderThread |
Field Summary | |
---|---|
protected 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 Object | expiredMutex |
protected 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 static int | MAX_PACKET_SIZE |
protected int | port
The multicast port |
protected 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 DatagramPacket | sendPacket
Reuse the sendPacket, no need to create a new one everytime |
protected MembershipListener | service
The actual listener, for callback when shits goes down |
protected long | serviceStartTime
When was the service started |
protected 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 Summary | |
---|---|
McastServiceImpl(MemberImpl member, long sendFrequency, long expireTime, int port, InetAddress bind, InetAddress mcastAddress, int ttl, int soTimeout, MembershipListener service)
Create a new mcast service impl |
Method Summary | |
---|---|
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 | 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 |
Parameters: member - the local member sendFrequency - the time (ms) in between pings sent out expireTime - the time (ms) for a member to expire port - the mcast port bind - the bind address (not sure this is used yet) mcastAddress - the mcast address service - the callback service
Throws: IOException
Throws: IOException
Throws: Exception
Parameters: level 1 starts the receiver, level 2 starts the sender
Throws: IOException if the service fails to start IllegalStateException if the service is already started
Throws: IOException if the service fails to disconnect from the sockets