Commit 31034e87 authored by Karsten Loesing's avatar Karsten Loesing
Browse files

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.
parent 500b7c5a
Loading
Loading
Loading
Loading
+7 −13
Original line number Diff line number Diff line
@@ -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;
@@ -49,12 +49,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.
   */
@@ -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();
  }
+7 −0
Original line number Diff line number Diff line
@@ -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."