commit 31034e8781c76df218426db030cac964566e3d34
Author: Karsten Loesing <karsten.loes...@gmx.net>
Date:   Fri Nov 1 17:40:11 2019 +0100

    Tweak BridgeDB metrics file names.
    
    We were using the same path for BridgeDB metrics in out/ and recent/,
    and file names didn't contain the "-bridgedb-metrics" suffix that we
    intended to add.
    
    We're now using paths generated by BridgedbMetricsPersistence.
    
    Also update create-tarballs.sh to create BridgeDB metrics tarballs.
    
    Still part of #19332.
---
 .../collector/bridgedb/BridgedbMetricsProcessor.java | 20 +++++++-------------
 src/main/resources/create-tarballs.sh                |  7 +++++++
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git 
a/src/main/java/org/torproject/metrics/collector/bridgedb/BridgedbMetricsProcessor.java
 
b/src/main/java/org/torproject/metrics/collector/bridgedb/BridgedbMetricsProcessor.java
index 7ae4502..9bb4f36 100644
--- 
a/src/main/java/org/torproject/metrics/collector/bridgedb/BridgedbMetricsProcessor.java
+++ 
b/src/main/java/org/torproject/metrics/collector/bridgedb/BridgedbMetricsProcessor.java
@@ -11,6 +11,7 @@ import org.torproject.metrics.collector.conf.Configuration;
 import org.torproject.metrics.collector.conf.ConfigurationException;
 import org.torproject.metrics.collector.conf.Key;
 import org.torproject.metrics.collector.cron.CollecTorMain;
+import org.torproject.metrics.collector.persist.BridgedbMetricsPersistence;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -21,7 +22,6 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.Instant;
-import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
 import java.util.Arrays;
 import java.util.Stack;
@@ -50,12 +50,6 @@ public class BridgedbMetricsProcessor extends CollecTorMain {
   private String recentPathName;
 
   /**
-   * File name format.
-   */
-  private DateTimeFormatter filenameFormat = DateTimeFormatter.ofPattern(
-      "uuuu/MM/dd/uuuu-MM-dd-HH-mm-ss");
-
-  /**
    * Initialize this class with the given configuration.
    */
   public BridgedbMetricsProcessor(Configuration config) {
@@ -101,10 +95,12 @@ public class BridgedbMetricsProcessor extends 
CollecTorMain {
         .readDescriptors(this.inputDirectory)) {
       if (descriptor instanceof BridgedbMetrics) {
         BridgedbMetrics bridgedbMetrics = (BridgedbMetrics) descriptor;
+        BridgedbMetricsPersistence persistence
+            = new BridgedbMetricsPersistence(bridgedbMetrics);
         Path tarballPath = Paths.get(this.outputPathName,
-            bridgedbMetrics.bridgedbMetricsEnd().format(this.filenameFormat));
+            persistence.getStoragePath());
         Path rsyncPath = Paths.get(this.recentPathName,
-            bridgedbMetrics.bridgedbMetricsEnd().format(this.filenameFormat));
+            persistence.getRecentPath());
         this.writeDescriptor(bridgedbMetrics.getRawDescriptorBytes(),
             tarballPath, rsyncPath);
       } else if (descriptor instanceof UnparseableDescriptor) {
@@ -127,10 +123,8 @@ public class BridgedbMetricsProcessor extends 
CollecTorMain {
    * storing them in instance attributes.
    */
   private void initializeConfiguration() throws ConfigurationException {
-    this.outputPathName = Paths.get(config.getPath(Key.OutputPath).toString(),
-        "bridgedb-metrics").toString();
-    this.recentPathName = Paths.get(config.getPath(Key.RecentPath).toString(),
-        "bridgedb-metrics").toString();
+    this.outputPathName = config.getPath(Key.OutputPath).toString();
+    this.recentPathName = config.getPath(Key.RecentPath).toString();
     this.inputDirectory =
         config.getPath(Key.BridgedbMetricsLocalOrigins).toFile();
   }
diff --git a/src/main/resources/create-tarballs.sh 
b/src/main/resources/create-tarballs.sh
index 695bb24..3927960 100755
--- a/src/main/resources/create-tarballs.sh
+++ b/src/main/resources/create-tarballs.sh
@@ -63,6 +63,8 @@ TARBALLS=(
   snowflakes-$YEARTWO-$MONTHTWO
   bridge-pool-assignments-$YEARONE-$MONTHONE
   bridge-pool-assignments-$YEARTWO-$MONTHTWO
+  bridgedb-metrics-$YEARONE-$MONTHONE
+  bridgedb-metrics-$YEARTWO-$MONTHTWO
 )
 TARBALLS=($(printf "%s\n" "${TARBALLS[@]}" | uniq))
 
@@ -94,6 +96,8 @@ DIRECTORIES=(
   $OUTDIR/snowflakes/$YEARTWO/$MONTHTWO/
   $OUTDIR/bridge-pool-assignments/$YEARONE/$MONTHONE/
   $OUTDIR/bridge-pool-assignments/$YEARTWO/$MONTHTWO/
+  $OUTDIR/bridgedb-metrics/$YEARONE/$MONTHONE/
+  $OUTDIR/bridgedb-metrics/$YEARTWO/$MONTHTWO/
 )
 DIRECTORIES=($(printf "%s\n" "${DIRECTORIES[@]}" | uniq))
 
@@ -183,4 +187,7 @@ ln -f -s -t $ARCHIVEDIR/snowflakes/ 
$TARBALLTARGETDIR/snowflakes-20??-??.tar.xz
 mkdir -p $ARCHIVEDIR/bridge-pool-assignments/
 ln -f -s -t $ARCHIVEDIR/bridge-pool-assignments/ 
$TARBALLTARGETDIR/bridge-pool-assignments-20??-??.tar.xz
 
+mkdir -p $ARCHIVEDIR/bridgedb-metrics/
+ln -f -s -t $ARCHIVEDIR/bridgedb-metrics/ 
$TARBALLTARGETDIR/bridgedb-metrics-20??-??.tar.xz
+
 echo `date` "Finished."



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

Reply via email to