org.apache.qpid.test.framework.clocksynch
Class UDPClockReference

java.lang.Object
  extended by org.apache.qpid.test.framework.clocksynch.UDPClockReference
All Implemented Interfaces:
Runnable, org.apache.qpid.junit.extensions.ShutdownHookable

public class UDPClockReference
extends Object
implements Runnable, org.apache.qpid.junit.extensions.ShutdownHookable

UDPClockReference supplies a refernce clock signal (generated from System.nanoTime()).

CRC Card
Responsibilities Collaborations
Supply a reference clock signal.

Todo:
Port hard coded. Make configurable., Errors rethrown as runtimes, or silently terminate the service. Could add better error handling if needed.

Field Summary
protected  boolean publish
          Flag used to indicate that the time server should keep running.
static int REFERENCE_PORT
          Defines the port to run the clock reference on.
protected  DatagramSocket socket
          Holds the socket to receive clock reference requests on.
 
Constructor Summary
UDPClockReference()
          Creates a clock reference service on the standard port.
 
Method Summary
 Thread getShutdownHook()
          Supplies a shutdown hook.
static void main(String[] args)
          For testing purposes.
 void run()
          Implements the run loop for this reference time server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REFERENCE_PORT

public static final int REFERENCE_PORT
Defines the port to run the clock reference on.

See Also:
Constant Field Values

socket

protected DatagramSocket socket
Holds the socket to receive clock reference requests on.


publish

protected boolean publish
Flag used to indicate that the time server should keep running. Set to false to terminate.

Constructor Detail

UDPClockReference

public UDPClockReference()
Creates a clock reference service on the standard port.

Method Detail

run

public void run()
Implements the run loop for this reference time server. This waits for incoming time requests, and replies to any, with a message with the local time stamp in it. Periodically (controlled by TIMEOUT), the run loop will check if the publish flag has been cleared, and terminate the reference time service if so.

Specified by:
run in interface Runnable

getShutdownHook

public Thread getShutdownHook()
Supplies a shutdown hook.

Specified by:
getShutdownHook in interface org.apache.qpid.junit.extensions.ShutdownHookable
Returns:
The shut down hook.

main

public static void main(String[] args)
For testing purposes. Runs a reference clock on the default port.

Parameters:
args - None.


Licensed to the Apache Software Foundation