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

[tor-commits] [collector/master] Add the build revision to index.json files.



commit 0a586c0be0a3d3f399f550ec3929a04ad4c71904
Author: iwakeh <iwakeh@xxxxxxxxxxxxxx>
Date:   Wed Sep 20 10:15:32 2017 +0000

    Add the build revision to index.json files.
    
    Implements the final part of task-21414 for CollecTor.
---
 CHANGELOG.md                                           |  5 +++++
 build.xml                                              |  2 +-
 src/build                                              |  2 +-
 .../torproject/collector/index/CreateIndexJson.java    | 18 +++++++++++++++++-
 4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0810fcf..4973f7e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,11 @@
    - Add "Sync" as OnionPerfSource to synchronize .tpf files from
      other CollecTor instances.
 
+ * Medium changes
+   - Add new optional "build_revision" field to index.json with the
+     Git revision of the CollecTor instance's software used to create
+     this file, which will be omitted if unknown.
+
  * Minor changes
    - Remove all styling resources (fonts, CSS, etc.) from directory
      listings.
diff --git a/build.xml b/build.xml
index 943c717..d60350b 100644
--- a/build.xml
+++ b/build.xml
@@ -11,7 +11,7 @@
   <property name="release.version" value="1.3.0-dev" />
   <property name="project-main-class" value="org.torproject.collector.Main" />
   <property name="name" value="collector"/>
-  <property name="metricslibversion" value="2.1.0" />
+  <property name="metricslibversion" value="2.1.1" />
   <property name="jarincludes" value="collector.properties logback.xml" />
 
   <patternset id="runtime" >
diff --git a/src/build b/src/build
index a64b94a..78e533f 160000
--- a/src/build
+++ b/src/build
@@ -1 +1 @@
-Subproject commit a64b94a635e5396266d5c5b5cf88850b9f4b6a24
+Subproject commit 78e533fdc84e20769a8a155d1426cbea59c6e7cc
diff --git a/src/main/java/org/torproject/collector/index/CreateIndexJson.java b/src/main/java/org/torproject/collector/index/CreateIndexJson.java
index e10109b..5c4daf9 100644
--- a/src/main/java/org/torproject/collector/index/CreateIndexJson.java
+++ b/src/main/java/org/torproject/collector/index/CreateIndexJson.java
@@ -21,10 +21,12 @@ import org.slf4j.LoggerFactory;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Locale;
+import java.util.Properties;
 import java.util.SortedSet;
 import java.util.TimeZone;
 import java.util.TreeSet;
@@ -53,10 +55,23 @@ public class CreateIndexJson extends CollecTorMain {
 
   private static final TimeZone dateTimezone = TimeZone.getTimeZone("UTC");
 
+  private static String buildRevision = null;
+
   /** Creates indexes of directories containing archived and recent
    * descriptors and write index files to disk. */
   public CreateIndexJson(Configuration conf) {
     super(conf);
+    Properties buildProperties = new Properties();
+    try (InputStream is = getClass().getClassLoader()
+        .getResourceAsStream("collector.buildrevision.properties")) {
+      buildProperties.load(is);
+      buildRevision = buildProperties.getProperty("collector.build.revision",
+          null);
+    } catch (Exception ex) {
+      // This doesn't hamper the index creation: only log a warning.
+      logger.warn("No build revision available.", ex);
+      buildRevision = null;
+    }
   }
 
   @Override
@@ -107,7 +122,8 @@ public class CreateIndexJson extends CollecTorMain {
       }
     }
     return new IndexNode(dateTimeFormat.format(
-        System.currentTimeMillis()), basePath, null, directoryNodes);
+        System.currentTimeMillis()), buildRevision, basePath, null,
+        directoryNodes);
   }
 
   private DirectoryNode indexDirectory(File directory) {



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