cgl.narada.transport.udp
Class UDPPingHandler

java.lang.Object
  extended by java.lang.Thread
      extended by cgl.narada.transport.udp.UDPPingHandler
All Implemented Interfaces:
Runnable

public class UDPPingHandler
extends Thread

Title: UDPPingHandler

Description: This class sends a ping message to figure out a node is up or down.

Version:
1.0

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
UDPPingHandler()
           
UDPPingHandler(UDPLinkFactory udpLinkFactory)
           
 
Method Summary
 void ackReceived(String linkname, long pingtime)
          does the required tasks when an acknowledge received for a ping message
 void addLinkForMonitoring(UDPLink link)
           
 void calculateNewRTT(cgl.narada.transport.udp.UDPPingHandler.PingObject pingobject, long rtt)
          calculetes the RTT value between two nodes.
 int getMaxPingFailNumber()
           
 long getPingInterval()
           
 void handlePing()
          sends ping in a given interval if acknowledge to a ping received, does required task to handle acknowledge
static void main(String[] args)
           
 void pingMessage(byte[] pmessage, byte[] time)
          creates ping message.
 void removePing(String linkname)
          removes a ping object from hashtable so that the ping for that not is not required any more.
 void run()
          runs thread
 void sendPing(UDPLink link, long _pingtime)
          sends a ping message to a given node
 void setDebug(boolean debug)
          sets a debug value for this class
 void setMaxPingFailNumber(int number)
          sets the veriable to value to limit the allowable number of sequential ping fail
 void setPingInterval(long time)
          sets the value of interval between two pings.
 void shutdownServices()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UDPPingHandler

public UDPPingHandler()

UDPPingHandler

public UDPPingHandler(UDPLinkFactory udpLinkFactory)
Method Detail

shutdownServices

public void shutdownServices()

addLinkForMonitoring

public void addLinkForMonitoring(UDPLink link)

setMaxPingFailNumber

public void setMaxPingFailNumber(int number)
sets the veriable to value to limit the allowable number of sequential ping fail

Parameters:
number - maximum allowable number

getMaxPingFailNumber

public int getMaxPingFailNumber()
Returns:
the maximum number of failed ping

setDebug

public void setDebug(boolean debug)
sets a debug value for this class

Parameters:
debug -

setPingInterval

public void setPingInterval(long time)
sets the value of interval between two pings.

Parameters:
time - is an interval values

getPingInterval

public long getPingInterval()
Returns:
the time for between two ping messages

calculateNewRTT

public void calculateNewRTT(cgl.narada.transport.udp.UDPPingHandler.PingObject pingobject,
                            long rtt)
calculetes the RTT value between two nodes. calculation is done by adding half of previous rtt and half of current rtt

Parameters:
pingobject - keeps whole data about a ping
rtt - RTT value for between two nodes.

pingMessage

public void pingMessage(byte[] pmessage,
                        byte[] time)
creates ping message. it consists of header for ping message and sending time.

Parameters:
pmessage - byte array of ping message
time - sending time. it is used both calculation for rtt and seperation between ping messages

removePing

public void removePing(String linkname)
removes a ping object from hashtable so that the ping for that not is not required any more.

Parameters:
linkname - the name of link for a node

ackReceived

public void ackReceived(String linkname,
                        long pingtime)
does the required tasks when an acknowledge received for a ping message

Parameters:
linkname - the name of link whose acknowledge is received
pingtime - the time of ping whose acknowledge is received

sendPing

public void sendPing(UDPLink link,
                     long _pingtime)
              throws Exception
sends a ping message to a given node

Parameters:
link - consists information a node to send a ping
_pingtime - ping time for the ping
Throws:
Exception

handlePing

public void handlePing()
                throws Exception
sends ping in a given interval if acknowledge to a ping received, does required task to handle acknowledge

Throws:
Exception

run

public void run()
runs thread

Specified by:
run in interface Runnable
Overrides:
run in class Thread

main

public static void main(String[] args)


For comments and suggestions please send e-mail to The NaradaBrokering Project