Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.catalina.cluster.mcast
Class McastServiceImpl

    java.lang.Object
      org.apache.catalina.cluster.mcast.McastServiceImpl

public class McastServiceImpl
extends java.lang.Object

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

Version:
  $Revision: 571971 $, $Date: 2007-09-02 07:02:53 -0600 (Sun, 02 Sep 2007) $
Author:
  Filip Hanik, Peter Rossbach

Nested Class Summary
`class` | `McastServiceImpl.ReceiverThread`
`protected static class` | `McastServiceImpl.RecoveryThread`
`class` | `McastServiceImpl.SenderThread`

Field Summary
`protected java.net.InetAddress` | `address` The multicast address
`protected boolean` | `doRun` Internal flag used for the listen thread that listens to the multicasting socket.
`protected java.lang.Object` | `expiredMutex`
`protected java.net.InetAddress` | `mcastBindAddress`
`protected int` | `mcastSoTimeout`
`protected int` | `mcastTTL`
`protected McastMember` | `member` The local member that we intend to broad cast over and over again
`protected McastMembership` | `membership` The membership, used so that we calculate memberships when they arrive or don't arrive
`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 shits goes down
`protected long` | `serviceStartTime` When was the service started
`protected java.net.MulticastSocket` | `socket` Socket that we intend to listen to
`protected long` | `timeToExpiration` The time it takes for a member to expire.

Constructor Summary
`McastServiceImpl(McastMember 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` | `checkExpire()` check member expire or alive
`int` | `getRecoveryCounter()`
`long` | `getRecoverySleepTime()`
`long` | `getServiceStartTime()`
`protected void` | `init()`
`boolean` | `isRecoveryEnabled()`
`void` | `receive()` Receive a datagram packet, locking wait
`void` | `send()` 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
`void` | `stop()` Stops the service

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### doRun

    protected boolean doRun

  Internal flag used for the listen thread that listens to the multicasting socket.

### socket

    protected java.net.MulticastSocket socket

  Socket that we intend to listen to

### member

    protected McastMember member

  The local member that we intend to broad cast over and over again

### address

    protected java.net.InetAddress address

  The multicast address

### port

    protected int port

  The multicast port

### timeToExpiration

    protected long timeToExpiration

  The time it takes for a member to expire.

### sendFrequency

    protected long sendFrequency

  How often to we send out a broadcast saying we are alive, must be smaller than timeToExpiration

### sendPacket

    protected java.net.DatagramPacket sendPacket

  Reuse the sendPacket, no need to create a new one everytime

### receivePacket

    protected java.net.DatagramPacket receivePacket

  Reuse the receivePacket, no need to create a new one everytime

### membership

    protected McastMembership membership

  The membership, used so that we calculate memberships when they arrive or don't arrive

### service

    protected MembershipListener service

  The actual listener, for callback when shits goes down

### receiver

    protected McastServiceImpl.ReceiverThread receiver

  Thread to listen for pings

### sender

    protected McastServiceImpl.SenderThread sender

  Thread to send pings

### serviceStartTime

    protected long serviceStartTime

  When was the service started

### mcastTTL

    protected int mcastTTL

### mcastSoTimeout

    protected int mcastSoTimeout

### mcastBindAddress

    protected java.net.InetAddress mcastBindAddress

### recoveryCounter

    protected int recoveryCounter

  nr of times the system has to fail before a recovery is initiated

### recoverySleepTime

    protected long recoverySleepTime

  The time the recovery thread sleeps between recovery attempts

### recoveryEnabled

    protected boolean recoveryEnabled

  Add the ability to turn on/off recovery

### expiredMutex

    protected java.lang.Object expiredMutex

Constructor Detail

### McastServiceImpl

    public McastServiceImpl(McastMember 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

  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:
  `java.io.IOException`

Method Detail

### init

    protected void init()
                 throws java.io.IOException

  Throws:
    `java.io.IOException`

### setupSocket

    protected void setupSocket()
                        throws java.io.IOException

  Throws:
    `java.io.IOException`

### start

    public void start(int level)
               throws java.io.IOException

  Start the service

  Parameters:
    `level` - 1 starts the receiver, level 2 starts the sender
  Throws:
    `java.io.IOException` - if the service fails to start
    `java.lang.IllegalStateException` - if the service is already started

### stop

    public void stop()
              throws java.io.IOException

  Stops the service

  Throws:
    `java.io.IOException` - if the service fails to disconnect from the sockets

### receive

    public void receive()
                 throws java.io.IOException

  Receive a datagram packet, locking wait

  Throws:
    `java.io.IOException`

### checkExpire

    protected void checkExpire()

  check member expire or alive

### send

    public void send()
              throws java.lang.Exception

  Send a ping

  Throws:
    `java.lang.Exception`

### getServiceStartTime

    public long getServiceStartTime()

### getRecoveryCounter

    public int getRecoveryCounter()

### isRecoveryEnabled

    public boolean isRecoveryEnabled()

### getRecoverySleepTime

    public long getRecoverySleepTime()

### setRecoveryCounter

    public void setRecoveryCounter(int recoveryCounter)

### setRecoveryEnabled

    public void setRecoveryEnabled(boolean recoveryEnabled)

### setRecoverySleepTime

    public void setRecoverySleepTime(long recoverySleepTime)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.