| 
 | Apache Tomcat 6.0.53 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.catalina.tribes.membership.McastServiceImpl
public class McastServiceImpl
A membership implementation using simple multicast. This is the representation of a multicast membership service. This class is responsible for maintaining a list of active cluster nodes in the cluster. If a node fails to send out a heartbeat, the node will be dismissed. This is the low level implementation that handles the multicasting sockets. Need to fix this, could use java.nio and only need one thread to send and receive, or just use a timeout on the receive
| Nested Class Summary | |
|---|---|
|  class | McastServiceImpl.ReceiverThread | 
| protected static class | McastServiceImpl.RecoveryThread | 
|  class | McastServiceImpl.SenderThread | 
| Field Summary | |
|---|---|
| protected  java.net.InetAddress | addressThe multicast address | 
| protected  boolean | doRunReceiver | 
| protected  boolean | doRunSenderInternal flag used for the listen thread that listens to the multicasting socket. | 
| protected  java.lang.Object | expiredMutex | 
| protected static int | MAX_PACKET_SIZE | 
| protected  java.net.InetAddress | mcastBindAddressbind address | 
| protected  int | mcastSoTimeoutRead timeout on the mcast socket | 
| protected  int | mcastTTLTime to live for the multicast packets that are being sent out | 
| protected  MemberImpl | memberThe local member that we intend to broad cast over and over again | 
| protected  Membership | membershipThe membership, used so that we calculate memberships when they arrive or don't arrive | 
| protected  int | portThe multicast port | 
| protected  java.net.DatagramPacket | receivePacketReuse the receivePacket, no need to create a new one everytime | 
| protected  McastServiceImpl.ReceiverThread | receiverThread to listen for pings | 
| protected  int | recoveryCounternr of times the system has to fail before a recovery is initiated | 
| protected  boolean | recoveryEnabledAdd the ability to turn on/off recovery | 
| protected  long | recoverySleepTimeThe time the recovery thread sleeps between recovery attempts | 
| protected  McastServiceImpl.SenderThread | senderThread to send pings | 
| protected  long | sendFrequencyHow often to we send out a broadcast saying we are alive, must be smaller than timeToExpiration | 
| protected  java.net.DatagramPacket | sendPacketReuse the sendPacket, no need to create a new one everytime | 
| protected  MembershipListener | serviceThe actual listener, for callback when shits goes down | 
| protected  long | serviceStartTimeWhen was the service started | 
| protected  java.net.MulticastSocket | socketSocket that we intend to listen to | 
| protected  int | startLevel | 
| protected  long | timeToExpirationThe time it takes for a member to expire. | 
| Constructor Summary | |
|---|---|
| McastServiceImpl(MemberImpl member,
                 long sendFrequency,
                 long expireTime,
                 int port,
                 java.net.InetAddress bind,
                 java.net.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 | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
protected static int MAX_PACKET_SIZE
protected boolean doRunSender
protected 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 McastServiceImpl.ReceiverThread receiver
protected McastServiceImpl.SenderThread sender
protected long serviceStartTime
protected int mcastTTL
protected int mcastSoTimeout
protected java.net.InetAddress mcastBindAddress
protected int recoveryCounter
protected long recoverySleepTime
protected boolean recoveryEnabled
protected java.lang.Object expiredMutex
| Constructor Detail | 
|---|
public McastServiceImpl(MemberImpl member,
                        long sendFrequency,
                        long expireTime,
                        int port,
                        java.net.InetAddress bind,
                        java.net.InetAddress mcastAddress,
                        int ttl,
                        int soTimeout,
                        MembershipListener service)
                 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 service
java.io.IOException| Method Detail | 
|---|
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 sender
java.io.IOException - if the service fails to start
java.lang.IllegalStateException - if the service is already started
public boolean stop(int level)
             throws java.io.IOException
java.io.IOException - if the service fails to disconnect from the sockets
public void receive()
             throws java.io.IOException
java.io.IOExceptionprotected void checkExpired()
public void send(boolean checkexpired)
          throws java.io.IOException
java.lang.Exception
java.io.IOExceptionpublic 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)
| 
 | Apache Tomcat 6.0.53 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||