public class McastServiceImpl extends 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 InetAddress | addressThe multicast address | 
| protected boolean | doRunReceiver | 
| protected boolean | doRunSenderInternal flag used for the listen thread that listens to the multicasting socket. | 
| protected ExecutorService | executorDont interrupt the sender/receiver thread, but pass off to an executor | 
| protected Object | expiredMutex | 
| protected boolean | localLoopbackDisableddisable/enable local loopback message | 
| protected static int | MAX_PACKET_SIZE | 
| protected 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 MessageListener | msgserviceThe actual listener for broadcast callbacks | 
| protected int | portThe multicast port | 
| protected 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 DatagramPacket | sendPacketReuse the sendPacket, no need to create a new one everytime | 
| protected MembershipListener | serviceThe actual listener, for callback when stuff goes down | 
| protected MulticastSocket | socketSocket that we intend to listen to | 
| protected int | startLevel | 
| protected long | timeToExpirationThe time it takes for a member to expire. | 
| Constructor and Description | 
|---|
| McastServiceImpl(MemberImpl member,
                long sendFrequency,
                long expireTime,
                int port,
                InetAddress bind,
                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() | 
| Channel | getChannel() | 
| 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,
    DatagramPacket packet) | 
| void | setChannel(Channel channel) | 
| 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 volatile int startLevel
protected MulticastSocket socket
protected MemberImpl member
protected InetAddress address
protected int port
protected long timeToExpiration
protected long sendFrequency
protected DatagramPacket sendPacket
protected 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 InetAddress mcastBindAddress
protected int recoveryCounter
protected long recoverySleepTime
protected boolean recoveryEnabled
protected ExecutorService executor
protected boolean localLoopbackDisabled
protected final Object expiredMutex
public McastServiceImpl(MemberImpl member, long sendFrequency, long expireTime, int port, InetAddress bind, InetAddress mcastAddress, int ttl, int soTimeout, MembershipListener service, MessageListener msgservice, boolean localLoopbackDisabled) throws 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 loopbackModeIOExceptionpublic void init()
          throws IOException
IOExceptionprotected void setupSocket()
                    throws IOException
IOExceptionpublic void start(int level)
           throws IOException
level - 1 starts the receiver, level 2 starts the senderIOException - if the service fails to startIllegalStateException - if the service is already startedpublic boolean stop(int level)
             throws IOException
IOException - if the service fails to disconnect from the socketspublic void receive()
             throws IOException
IOExceptionprotected void checkExpired()
public void send(boolean checkexpired)
          throws IOException
IOExceptionpublic void send(boolean checkexpired,
        DatagramPacket packet)
          throws IOException
IOExceptionpublic long getServiceStartTime()
public int getRecoveryCounter()
public boolean isRecoveryEnabled()
public long getRecoverySleepTime()
public Channel getChannel()
public void setChannel(Channel channel)
public void setRecoveryCounter(int recoveryCounter)
public void setRecoveryEnabled(boolean recoveryEnabled)
public void setRecoverySleepTime(long recoverySleepTime)
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.