From 7c2409eab0607923e7180d2d0df7fbf517835bd1 Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Thu, 1 Mar 2012 12:44:43 -0600 Subject: [PATCH] Issue #353 apply the server time offset before requesting updates instead of after so that way there is no time gap for the first request Change-Id: I3ceb8cefbedc3b64ca207c559e8cd381f6f184fd Former-commit-id: 059b4fcb3224b37b4a235f57e2065b9506f29d46 --- .../refresh/ThinClientDataUpdateTree.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/ThinClientDataUpdateTree.java b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/ThinClientDataUpdateTree.java index 27dae58fe9..333d5db5d8 100644 --- a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/ThinClientDataUpdateTree.java +++ b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/ThinClientDataUpdateTree.java @@ -90,8 +90,9 @@ public class ThinClientDataUpdateTree extends DataUpdateTree { } public Collection updateAllData() { - String time = DATE_FORMAT.format(new Date(lastQuery)); - lastQuery = getServerTime(); + String time = DATE_FORMAT.format(new Date(lastQuery + - getServerTimeOffset())); + lastQuery = System.currentTimeMillis(); Set messages = new HashSet(); for (DataPair pair : getDataPairs()) { AbstractResourceData resourceData = pair.data.getResourceData(); @@ -128,16 +129,16 @@ public class ThinClientDataUpdateTree extends DataUpdateTree { } /** - * Get the estimated current time on the server. This is useful if the - * client and server have differences in their clocks. The time returned - * from this method will always be slightly earlier than the actual server - * time because of network latency. The earlier time guarantees that all - * updates are retrieved but may result in updates being retrieved twice if - * the data is inserted during this one second window + * Get the estimated difference between the clock on the server and the + * local clock. The offset returned from this method will always be slightly + * earlier than the actual server time because of network latency. The + * earlier time guarantees that all updates are retrieved but may result in + * updates being retrieved twice if the data is inserted during this one + * second window * * @return */ - private long getServerTime() { + private long getServerTimeOffset() { if (serverTimeLag == Long.MIN_VALUE) { try { GetServerTimeResponse response = (GetServerTimeResponse) ThriftClient @@ -146,11 +147,11 @@ public class ThinClientDataUpdateTree extends DataUpdateTree { } catch (VizException e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); - return System.currentTimeMillis() - 1000l; + return 1000l; } } // put in a 1 second overlap in case insert time is a bit off. - return System.currentTimeMillis() - serverTimeLag - 1000l; + return serverTimeLag + 1000l; } }