Save This Page
Home » apache-tomcat-6.0.16-src » org.apache » catalina » tribes » membership » [javadoc | source]
org.apache.catalina.tribes.membership
public class: McastServiceImpl [javadoc | source]
java.lang.Object
   org.apache.catalina.tribes.membership.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:
public class  McastServiceImpl.ReceiverThread   
public class  McastServiceImpl.SenderThread   
protected static class  McastServiceImpl.RecoveryThread   
Field Summary
protected static  int MAX_PACKET_SIZE     
protected  boolean doRunSender    Internal flag used for the listen thread that listens to the multicasting socket. 
protected  boolean doRunReceiver     
protected  int startLevel     
protected  MulticastSocket socket    Socket that we intend to listen to 
protected  MemberImpl member    The local member that we intend to broad cast over and over again 
protected  InetAddress address    The multicast address 
protected  int port    The multicast port 
protected  long timeToExpiration    The time it takes for a member to expire. 
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  DatagramPacket receivePacket    Reuse the receivePacket, no need to create a new one everytime 
protected  Membership membership    The membership, used so that we calculate memberships when they arrive or don't arrive 
protected  MembershipListener service    The actual listener, for callback when shits goes down 
protected  McastServiceImpl.ReceiverThread receiver    Thread to listen for pings 
protected  McastServiceImpl.SenderThread sender    Thread to send pings 
protected  long serviceStartTime    When was the service started 
protected  int mcastTTL    Time to live for the multicast packets that are being sent out 
protected  int mcastSoTimeout    Read timeout on the mcast socket 
protected  InetAddress mcastBindAddress    bind address 
protected  int recoveryCounter    nr of times the system has to fail before a recovery is initiated 
protected  long recoverySleepTime    The time the recovery thread sleeps between recovery attempts 
protected  boolean recoveryEnabled    Add the ability to turn on/off recovery 
protected  Object expiredMutex     
Constructor:
 public McastServiceImpl(MemberImpl member,
    long sendFrequency,
    long expireTime,
    int port,
    InetAddress bind,
    InetAddress mcastAddress,
    int ttl,
    int soTimeout,
    MembershipListener service) throws IOException 
    Create a new mcast service impl
    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 -
Method from org.apache.catalina.tribes.membership.McastServiceImpl Summary:
checkExpired,   getRecoveryCounter,   getRecoverySleepTime,   getServiceStartTime,   init,   isRecoveryEnabled,   receive,   send,   setRecoveryCounter,   setRecoveryEnabled,   setRecoverySleepTime,   setupSocket,   start,   stop
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.catalina.tribes.membership.McastServiceImpl Detail:
 protected  void checkExpired() 
 public int getRecoveryCounter() 
 public long getRecoverySleepTime() 
 public long getServiceStartTime() 
 public  void init() throws IOException 
 public boolean isRecoveryEnabled() 
 public  void receive() throws IOException 
    Receive a datagram packet, locking wait
 public  void send(boolean checkexpired) throws IOException 
    Send a ping
 public  void setRecoveryCounter(int recoveryCounter) 
 public  void setRecoveryEnabled(boolean recoveryEnabled) 
 public  void setRecoverySleepTime(long recoverySleepTime) 
 protected  void setupSocket() throws IOException 
 public synchronized  void start(int level) throws IOException 
    Start the service
 public synchronized boolean stop(int level) throws IOException 
    Stops the service