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

[tor-commits] [onionoo/master] Rename lastSeenMillis to mostRecentStatusMillis.



commit 88bc0219725b01d24110f6d48528dc88d4fa3839
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Wed Feb 7 10:56:45 2018 +0100

    Rename lastSeenMillis to mostRecentStatusMillis.
---
 .../onionoo/writer/BandwidthDocumentWriter.java      | 20 ++++++++++----------
 .../onionoo/writer/ClientsDocumentWriter.java        |  8 ++++----
 .../onionoo/writer/DetailsDocumentWriter.java        |  2 +-
 .../torproject/onionoo/writer/DocumentWriter.java    |  2 +-
 .../onionoo/writer/DocumentWriterRunner.java         | 13 +++++++------
 .../onionoo/writer/SummaryDocumentWriter.java        |  2 +-
 .../onionoo/writer/UptimeDocumentWriter.java         | 18 +++++++++---------
 .../onionoo/writer/WeightsDocumentWriter.java        | 20 ++++++++++----------
 8 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java
index ad66bde..47eaa3e 100644
--- a/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/BandwidthDocumentWriter.java
@@ -31,7 +31,7 @@ public class BandwidthDocumentWriter implements DocumentWriter {
   }
 
   @Override
-  public void writeDocuments(long lastSeenMillis) {
+  public void writeDocuments(long mostRecentStatusMillis) {
     UpdateStatus updateStatus = this.documentStore.retrieve(
         UpdateStatus.class, true);
     long updatedMillis = updateStatus != null
@@ -45,7 +45,7 @@ public class BandwidthDocumentWriter implements DocumentWriter {
         continue;
       }
       BandwidthDocument bandwidthDocument = this.compileBandwidthDocument(
-          fingerprint, lastSeenMillis, bandwidthStatus);
+          fingerprint, mostRecentStatusMillis, bandwidthStatus);
       this.documentStore.store(bandwidthDocument, fingerprint);
     }
     log.info("Wrote bandwidth document files");
@@ -53,13 +53,13 @@ public class BandwidthDocumentWriter implements DocumentWriter {
 
 
   private BandwidthDocument compileBandwidthDocument(String fingerprint,
-      long lastSeenMillis, BandwidthStatus bandwidthStatus) {
+      long mostRecentStatusMillis, BandwidthStatus bandwidthStatus) {
     BandwidthDocument bandwidthDocument = new BandwidthDocument();
     bandwidthDocument.setFingerprint(fingerprint);
-    bandwidthDocument.setWriteHistory(this.compileGraphType(lastSeenMillis,
-        bandwidthStatus.getWriteHistory()));
-    bandwidthDocument.setReadHistory(this.compileGraphType(lastSeenMillis,
-        bandwidthStatus.getReadHistory()));
+    bandwidthDocument.setWriteHistory(this.compileGraphType(
+        mostRecentStatusMillis, bandwidthStatus.getWriteHistory()));
+    bandwidthDocument.setReadHistory(this.compileGraphType(
+        mostRecentStatusMillis, bandwidthStatus.getReadHistory()));
     return bandwidthDocument;
   }
 
@@ -87,10 +87,10 @@ public class BandwidthDocumentWriter implements DocumentWriter {
       DateTimeHelper.TWO_DAYS,
       DateTimeHelper.TEN_DAYS };
 
-  private Map<String, GraphHistory> compileGraphType(long lastSeenMillis,
-      SortedMap<Long, long[]> history) {
+  private Map<String, GraphHistory> compileGraphType(
+      long mostRecentStatusMillis, SortedMap<Long, long[]> history) {
     GraphHistoryCompiler ghc = new GraphHistoryCompiler(
-        lastSeenMillis + DateTimeHelper.ONE_HOUR);
+        mostRecentStatusMillis + DateTimeHelper.ONE_HOUR);
     for (int i = 0; i < this.graphIntervals.length; i++) {
       ghc.addGraphType(this.graphNames[i], this.graphIntervals[i],
           this.dataPointIntervals[i]);
diff --git a/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java
index 7ed2048..de63893 100644
--- a/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/ClientsDocumentWriter.java
@@ -55,7 +55,7 @@ public class ClientsDocumentWriter implements DocumentWriter {
   private int writtenDocuments = 0;
 
   @Override
-  public void writeDocuments(long lastSeenMillis) {
+  public void writeDocuments(long mostRecentStatusMillis) {
     UpdateStatus updateStatus = this.documentStore.retrieve(
         UpdateStatus.class, true);
     long updatedMillis = updateStatus != null
@@ -70,7 +70,7 @@ public class ClientsDocumentWriter implements DocumentWriter {
       }
       SortedSet<ClientsHistory> history = clientsStatus.getHistory();
       ClientsDocument clientsDocument = this.compileClientsDocument(
-          hashedFingerprint, lastSeenMillis, history);
+          hashedFingerprint, mostRecentStatusMillis, history);
       this.documentStore.store(clientsDocument, hashedFingerprint);
       this.writtenDocuments++;
     }
@@ -99,10 +99,10 @@ public class ClientsDocumentWriter implements DocumentWriter {
       DateTimeHelper.TEN_DAYS };
 
   private ClientsDocument compileClientsDocument(String hashedFingerprint,
-      long lastSeenMillis, SortedSet<ClientsHistory> history) {
+      long mostRecentStatusMillis, SortedSet<ClientsHistory> history) {
     ClientsDocument clientsDocument = new ClientsDocument();
     clientsDocument.setFingerprint(hashedFingerprint);
-    GraphHistoryCompiler ghc = new GraphHistoryCompiler(lastSeenMillis
+    GraphHistoryCompiler ghc = new GraphHistoryCompiler(mostRecentStatusMillis
         + DateTimeHelper.ONE_HOUR);
     ghc.setThreshold(2L);
     for (int i = 0; i < this.graphIntervals.length; i++) {
diff --git a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
index 7ffaa07..8490f05 100644
--- a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
@@ -32,7 +32,7 @@ public class DetailsDocumentWriter implements DocumentWriter {
   }
 
   @Override
-  public void writeDocuments(long lastSeenMillis) {
+  public void writeDocuments(long mostRecentStatusMillis) {
     UpdateStatus updateStatus = this.documentStore.retrieve(
         UpdateStatus.class, true);
     long updatedMillis = updateStatus != null
diff --git a/src/main/java/org/torproject/onionoo/writer/DocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/DocumentWriter.java
index 359de6f..9fc893f 100644
--- a/src/main/java/org/torproject/onionoo/writer/DocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/DocumentWriter.java
@@ -5,7 +5,7 @@ package org.torproject.onionoo.writer;
 
 public interface DocumentWriter {
 
-  public abstract void writeDocuments(long lastSeenMillis);
+  public abstract void writeDocuments(long mostRecentStatusMillis);
 
   public abstract String getStatsString();
 }
diff --git a/src/main/java/org/torproject/onionoo/writer/DocumentWriterRunner.java b/src/main/java/org/torproject/onionoo/writer/DocumentWriterRunner.java
index 968ab72..4ab8f7e 100644
--- a/src/main/java/org/torproject/onionoo/writer/DocumentWriterRunner.java
+++ b/src/main/java/org/torproject/onionoo/writer/DocumentWriterRunner.java
@@ -32,22 +32,23 @@ public class DocumentWriterRunner {
 
   /** Lets each configured document writer write its documents. */
   public void writeDocuments() {
-    long lastSeenMillis = retrieveLastSeenMillis();
+    long mostRecentStatusMillis = retrieveMostRecentStatusMillis();
     for (DocumentWriter dw : this.documentWriters) {
       log.debug("Writing " + dw.getClass().getSimpleName());
-      dw.writeDocuments(lastSeenMillis);
+      dw.writeDocuments(mostRecentStatusMillis);
     }
   }
 
-  private long retrieveLastSeenMillis() {
+  private long retrieveMostRecentStatusMillis() {
     DocumentStore documentStore = DocumentStoreFactory.getDocumentStore();
-    long lastSeenMillis = -1L;
+    long mostRecentStatusMillis = -1L;
     for (String fingerprint : documentStore.list(NodeStatus.class)) {
       NodeStatus nodeStatus = documentStore.retrieve(
           NodeStatus.class, true, fingerprint);
-      lastSeenMillis = Math.max(lastSeenMillis, nodeStatus.getLastSeenMillis());
+      mostRecentStatusMillis = Math.max(mostRecentStatusMillis,
+          nodeStatus.getLastSeenMillis());
     }
-    return lastSeenMillis;
+    return mostRecentStatusMillis;
   }
 
   /** Logs statistics of all configured document writers. */
diff --git a/src/main/java/org/torproject/onionoo/writer/SummaryDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/SummaryDocumentWriter.java
index 74ef31c..356feab 100644
--- a/src/main/java/org/torproject/onionoo/writer/SummaryDocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/SummaryDocumentWriter.java
@@ -33,7 +33,7 @@ public class SummaryDocumentWriter implements DocumentWriter {
   private int deletedDocuments = 0;
 
   @Override
-  public void writeDocuments(long lastSeenAllRelaysAndBridgesMillis) {
+  public void writeDocuments(long mostRecentStatusMillis) {
     long relaysLastValidAfterMillis = -1L;
     long bridgesLastPublishedMillis = -1L;
     for (String fingerprint : this.documentStore.list(NodeStatus.class)) {
diff --git a/src/main/java/org/torproject/onionoo/writer/UptimeDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/UptimeDocumentWriter.java
index db09e3d..22b7ba5 100644
--- a/src/main/java/org/torproject/onionoo/writer/UptimeDocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/UptimeDocumentWriter.java
@@ -36,7 +36,7 @@ public class UptimeDocumentWriter implements DocumentWriter {
   }
 
   @Override
-  public void writeDocuments(long lastSeenMillis) {
+  public void writeDocuments(long mostRecentStatusMillis) {
     UptimeStatus uptimeStatus = this.documentStore.retrieve(
         UptimeStatus.class, true);
     if (uptimeStatus == null) {
@@ -50,14 +50,14 @@ public class UptimeDocumentWriter implements DocumentWriter {
     SortedSet<String> updatedUptimeStatuses = this.documentStore.list(
         UptimeStatus.class, updatedMillis);
     for (String fingerprint : updatedUptimeStatuses) {
-      this.updateDocument(fingerprint, lastSeenMillis, uptimeStatus);
+      this.updateDocument(fingerprint, mostRecentStatusMillis, uptimeStatus);
     }
     log.info("Wrote uptime document files");
   }
 
   private int writtenDocuments = 0;
 
-  private void updateDocument(String fingerprint, long lastSeenMillis,
+  private void updateDocument(String fingerprint, long mostRecentStatusMillis,
       UptimeStatus knownStatuses) {
     UptimeStatus uptimeStatus = this.documentStore.retrieve(
         UptimeStatus.class, true, fingerprint);
@@ -70,7 +70,7 @@ public class UptimeDocumentWriter implements DocumentWriter {
           ? knownStatuses.getRelayHistory()
           : knownStatuses.getBridgeHistory();
       UptimeDocument uptimeDocument = this.compileUptimeDocument(relay,
-          fingerprint, history, knownStatusesHistory, lastSeenMillis);
+          fingerprint, history, knownStatusesHistory, mostRecentStatusMillis);
       this.documentStore.store(uptimeDocument, fingerprint);
       this.writtenDocuments++;
     }
@@ -99,11 +99,11 @@ public class UptimeDocumentWriter implements DocumentWriter {
 
   private UptimeDocument compileUptimeDocument(boolean relay,
       String fingerprint, SortedSet<UptimeHistory> history,
-      SortedSet<UptimeHistory> knownStatuses, long lastSeenMillis) {
+      SortedSet<UptimeHistory> knownStatuses, long mostRecentStatusMillis) {
     UptimeDocument uptimeDocument = new UptimeDocument();
     uptimeDocument.setFingerprint(fingerprint);
     uptimeDocument.setUptime(this.compileUptimeHistory(relay, history,
-        knownStatuses, lastSeenMillis, null));
+        knownStatuses, mostRecentStatusMillis, null));
     SortedMap<String, Map<String, GraphHistory>> flags = new TreeMap<>();
     SortedSet<String> allFlags = new TreeSet<>();
     for (UptimeHistory hist : history) {
@@ -113,7 +113,7 @@ public class UptimeDocumentWriter implements DocumentWriter {
     }
     for (String flag : allFlags) {
       Map<String, GraphHistory> graphsForFlags = this.compileUptimeHistory(
-          relay, history, knownStatuses, lastSeenMillis, flag);
+          relay, history, knownStatuses, mostRecentStatusMillis, flag);
       if (!graphsForFlags.isEmpty()) {
         flags.put(flag, graphsForFlags);
       }
@@ -126,7 +126,7 @@ public class UptimeDocumentWriter implements DocumentWriter {
 
   private Map<String, GraphHistory> compileUptimeHistory(boolean relay,
       SortedSet<UptimeHistory> history, SortedSet<UptimeHistory> knownStatuses,
-      long lastSeenMillis, String flag) {
+      long mostRecentStatusMillis, String flag) {
 
     /* Extracting history entries for compiling GraphHistory objects is a bit
      * harder than for the other document types. The reason is that we have to
@@ -143,7 +143,7 @@ public class UptimeDocumentWriter implements DocumentWriter {
     /* Initialize the graph history compiler, and tell it that history entries
      * are divisible. This is different from the other history writers. */
     GraphHistoryCompiler ghc = new GraphHistoryCompiler(
-        lastSeenMillis + DateTimeHelper.ONE_HOUR);
+        mostRecentStatusMillis + DateTimeHelper.ONE_HOUR);
     for (int i = 0; i < this.graphIntervals.length; i++) {
       ghc.addGraphType(this.graphNames[i], this.graphIntervals[i],
           this.dataPointIntervals[i]);
diff --git a/src/main/java/org/torproject/onionoo/writer/WeightsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/WeightsDocumentWriter.java
index 2d2239b..c701f41 100644
--- a/src/main/java/org/torproject/onionoo/writer/WeightsDocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/WeightsDocumentWriter.java
@@ -31,7 +31,7 @@ public class WeightsDocumentWriter implements DocumentWriter {
   }
 
   @Override
-  public void writeDocuments(long lastSeenMillis) {
+  public void writeDocuments(long mostRecentStatusMillis) {
     UpdateStatus updateStatus = this.documentStore.retrieve(
         UpdateStatus.class, true);
     long updatedMillis = updateStatus != null
@@ -46,7 +46,7 @@ public class WeightsDocumentWriter implements DocumentWriter {
       }
       SortedMap<long[], double[]> history = weightsStatus.getHistory();
       WeightsDocument weightsDocument = this.compileWeightsDocument(
-          fingerprint, history, lastSeenMillis);
+          fingerprint, history, mostRecentStatusMillis);
       this.documentStore.store(weightsDocument, fingerprint);
     }
     log.info("Wrote weights document files");
@@ -74,27 +74,27 @@ public class WeightsDocumentWriter implements DocumentWriter {
       DateTimeHelper.TEN_DAYS };
 
   private WeightsDocument compileWeightsDocument(String fingerprint,
-      SortedMap<long[], double[]> history, long lastSeenMillis) {
+      SortedMap<long[], double[]> history, long mostRecentStatusMillis) {
     WeightsDocument weightsDocument = new WeightsDocument();
     weightsDocument.setFingerprint(fingerprint);
     weightsDocument.setConsensusWeightFraction(
-        this.compileGraphType(history, lastSeenMillis, 1));
+        this.compileGraphType(history, mostRecentStatusMillis, 1));
     weightsDocument.setGuardProbability(
-        this.compileGraphType(history, lastSeenMillis, 2));
+        this.compileGraphType(history, mostRecentStatusMillis, 2));
     weightsDocument.setMiddleProbability(
-        this.compileGraphType(history, lastSeenMillis, 3));
+        this.compileGraphType(history, mostRecentStatusMillis, 3));
     weightsDocument.setExitProbability(
-        this.compileGraphType(history, lastSeenMillis, 4));
+        this.compileGraphType(history, mostRecentStatusMillis, 4));
     weightsDocument.setConsensusWeight(
-        this.compileGraphType(history, lastSeenMillis, 6));
+        this.compileGraphType(history, mostRecentStatusMillis, 6));
     return weightsDocument;
   }
 
   private Map<String, GraphHistory> compileGraphType(
-      SortedMap<long[], double[]> history, long lastSeenMillis,
+      SortedMap<long[], double[]> history, long mostRecentStatusMillis,
       int graphTypeIndex) {
     GraphHistoryCompiler ghc = new GraphHistoryCompiler(
-        lastSeenMillis + DateTimeHelper.ONE_HOUR);
+        mostRecentStatusMillis + DateTimeHelper.ONE_HOUR);
     for (int i = 0; i < this.graphIntervals.length; i++) {
       ghc.addGraphType(this.graphNames[i], this.graphIntervals[i],
           this.dataPointIntervals[i]);

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits