From f1c4892cb57567380401469f7251547d9b54e154 Mon Sep 17 00:00:00 2001 From: Rupert Smith Date: Thu, 16 Aug 2007 10:18:08 +0000 Subject: Added distributed clock synchronization using UDP datagrams. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@566644 13f79535-47bb-0310-9956-ffa450edef68 --- .../framework/distributedtesting/TestClient.java | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'java/integrationtests/src') diff --git a/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java b/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java index c5061d0d8d..486950a2f7 100644 --- a/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java +++ b/java/integrationtests/src/main/java/org/apache/qpid/test/framework/distributedtesting/TestClient.java @@ -29,8 +29,13 @@ import org.apache.qpid.interop.clienttestcases.TestCase3BasicPubSub; import org.apache.qpid.sustained.SustainedClientTestCase; import org.apache.qpid.test.framework.MessagingTestConfigProperties; import org.apache.qpid.test.framework.TestUtils; +import org.apache.qpid.test.framework.clocksynch.ClockSynchThread; +import org.apache.qpid.test.framework.clocksynch.ClockSynchronizer; +import org.apache.qpid.test.framework.clocksynch.UDPClockSynchronizer; import org.apache.qpid.test.framework.distributedcircuit.TestClientCircuitEnd; +import uk.co.thebadgerset.junit.extensions.SleepThrottle; +import uk.co.thebadgerset.junit.extensions.Throttle; import uk.co.thebadgerset.junit.extensions.util.ParsedProperties; import uk.co.thebadgerset.junit.extensions.util.TestContextProperties; @@ -41,7 +46,7 @@ import java.util.*; /** * Implements a test client as described in the interop testing spec * (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification). A test client is an agent that - * reacts to control message sequences send by the test {@link org.apache.qpid.test.framework.distributedtesting.Coordinator}. + * reacts to control message sequences send by the test {@link Coordinator}. * *

*
Messages Handled by SustainedTestClient
Message Action @@ -51,6 +56,7 @@ import java.util.*; *
Start Send test messages defined by test parameters. Send report on messages sent. *
Status Request Send report on messages received. *
Terminate Terminate the test client. + *
ClockSynch Synch clock against the supplied UDP address. *
* *

@@ -104,6 +110,9 @@ public class TestClient implements MessageListener /** This flag indicates that the test client should attempt to join the currently running test case on start up. */ protected boolean join; + /** Holds the clock synchronizer for the test node. */ + ClockSynchThread clockSynchThread; + /** * Creates a new interop test client, listenting to the specified broker and virtual host, with the specified client * identifying name. @@ -404,12 +413,31 @@ public class TestClient implements MessageListener } else if ("TERMINATE".equals(controlType)) { - log.info("Received termination instruction from coordinator."); + console.info("Received termination instruction from coordinator."); // Is a cleaner shutdown needed? connection.close(); System.exit(0); } + else if ("CLOCK_SYNCH".equals(controlType)) + { + log.debug("Received clock synch command."); + String address = message.getStringProperty("ADDRESS"); + + log.debug("address = " + address); + + // Re-create (if necessary) and start the clock synch thread to synch the clock every ten seconds. + if (clockSynchThread != null) + { + clockSynchThread.terminate(); + } + + SleepThrottle throttle = new SleepThrottle(); + throttle.setRate(0.1f); + + clockSynchThread = new ClockSynchThread(new UDPClockSynchronizer(address), throttle); + clockSynchThread.start(); + } else { // Log a warning about this but otherwise ignore it. -- cgit v1.2.1
CRC Card