[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [metrics-db/master] Warn if either consensus or bridge status go stale.



Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Wed, 28 Jul 2010 17:40:06 +0200
Subject: Warn if either consensus or bridge status go stale.
Commit: 63ffba1637832757cd9a9b43bea54317a6f52865

---
 .../ernie/db/ConsensusStatsFileHandler.java        |   22 ++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/org/torproject/ernie/db/ConsensusStatsFileHandler.java b/src/org/torproject/ernie/db/ConsensusStatsFileHandler.java
index c509ce5..89890ed 100644
--- a/src/org/torproject/ernie/db/ConsensusStatsFileHandler.java
+++ b/src/org/torproject/ernie/db/ConsensusStatsFileHandler.java
@@ -485,17 +485,39 @@ public class ConsensusStatsFileHandler {
         + "Added " + this.relayResultsAdded + " relay consensus(es) and "
         + this.bridgeResultsAdded + " bridge status(es) in this "
         + "execution.");
+    long now = System.currentTimeMillis();
+    SimpleDateFormat dateTimeFormat =
+        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    dateTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
     if (this.relaysRaw.isEmpty()) {
       dumpStats.append("\nNo relay consensus known yet.");
     } else {
       dumpStats.append("\nLast known relay consensus was published "
           + this.relaysRaw.lastKey() + ".");
+      try {
+        if (now - 6L * 60L * 60L * 1000L > dateTimeFormat.parse(
+            this.relaysRaw.lastKey()).getTime()) {
+          logger.warning("Last known relay consensus is more than 6 hours "
+              + "old: " + this.relaysRaw.lastKey());
+        }
+      } catch (ParseException e) {
+         /* Can't parse the timestamp? Whatever. */
+      }
     }
     if (this.bridgesRaw.isEmpty()) {
       dumpStats.append("\nNo bridge status known yet.");
     } else {
       dumpStats.append("\nLast known bridge status was published "
           + this.bridgesRaw.lastKey() + ".");
+      try {
+        if (now - 6L * 60L * 60L * 1000L > dateTimeFormat.parse(
+            this.bridgesRaw.lastKey()).getTime()) {
+          logger.warning("Last known bridge status is more than 6 hours "
+              + "old: " + this.bridgesRaw.lastKey());
+        }
+      } catch (ParseException e) {
+         /* Can't parse the timestamp? Whatever. */
+      }
     }
     logger.info(dumpStats.toString());
   }
-- 
1.7.1