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

[tor-commits] [metrics-db/master] Provide torperf files via rsync.



commit 1b62b6cdd9c9f7d8b76e24196577d6777ee53692
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Fri Jun 1 14:02:54 2012 +0200

    Provide torperf files via rsync.
---
 src/org/torproject/ernie/db/Main.java              |    2 +
 src/org/torproject/ernie/db/RsyncDataProvider.java |   23 ++++++++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/org/torproject/ernie/db/Main.java b/src/org/torproject/ernie/db/Main.java
index c0f100a..3fd6656 100644
--- a/src/org/torproject/ernie/db/Main.java
+++ b/src/org/torproject/ernie/db/Main.java
@@ -155,6 +155,8 @@ public class Main {
           config.getDownloadExitList(),
           !config.getDownloadGetTorStats() ? null :
           new File(config.getGetTorDirectory()),
+          !config.getProcessTorperfFiles() ? null :
+          new File(config.getTorperfOutputDirectory()),
           new File(config.getRsyncDirectory()));
     }
 
diff --git a/src/org/torproject/ernie/db/RsyncDataProvider.java b/src/org/torproject/ernie/db/RsyncDataProvider.java
index dac0249..4cb8e99 100644
--- a/src/org/torproject/ernie/db/RsyncDataProvider.java
+++ b/src/org/torproject/ernie/db/RsyncDataProvider.java
@@ -22,7 +22,7 @@ public class RsyncDataProvider {
       File sanitizedBridgesWriteDirectory,
       File sanitizedAssignmentsDirectory,
       boolean downloadExitList, File getTorDirectory,
-      File rsyncDirectory) {
+      File torperfOutputDirectory, File rsyncDirectory) {
 
     /* Initialize logger. */
     Logger logger = Logger.getLogger(RsyncDataProvider.class.getName());
@@ -154,6 +154,26 @@ public class RsyncDataProvider {
         + fileNamesInRsync.size() + " files left in "
         + rsyncDirectory.getAbsolutePath() + ".");
 
+    /* Copy Torperf files. */
+    if (torperfOutputDirectory != null) {
+      files.add(torperfOutputDirectory);
+      while (!files.isEmpty()) {
+        File pop = files.pop();
+        if (pop.isDirectory()) {
+          files.addAll(Arrays.asList(pop.listFiles()));
+        } else if (pop.getName().endsWith(".tpf") &&
+            pop.lastModified() >= cutOffMillis) {
+          String fileName = pop.getName();
+          this.copyFile(pop, new File(rsyncDirectory,
+              "torperf/" + fileName));
+          fileNamesInRsync.remove(pop.getName());
+        }
+      }
+    }
+    logger.info("After copying Torperf files, there are still "
+        + fileNamesInRsync.size() + " files left in "
+        + rsyncDirectory.getAbsolutePath() + ".");
+
     /* Copy GetTor stats. */
     if (getTorDirectory != null) {
       String getTorFileName = "gettor_stats.txt";
@@ -165,7 +185,6 @@ public class RsyncDataProvider {
         fileNamesInRsync.remove(getTorFileName);
       }
     }
-
     logger.info("After copying the GetTor stats file, there are still "
         + fileNamesInRsync.size() + " files left in "
         + rsyncDirectory.getAbsolutePath() + ".");

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