[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [collector/master] Keep annotations of given descriptors.
commit 68f5301bd1cf8b10fcae0a2d7e924cc87093a97c
Author: iwakeh <iwakeh@xxxxxxxxxxxxxx>
Date: Fri Aug 18 13:03:05 2017 +0000
Keep annotations of given descriptors.
Makes test pass again and implements task-23215.
Changes a test descriptor to contain a second annotation.
---
CHANGELOG.md | 8 ++++++++
.../collector/persist/DescriptorPersistence.java | 14 ++++++++++++--
src/test/resources/bridge-2016-10-02-08-09-00-extra-infos | 8 ++++++++
src/test/resources/moria-1048576-2016-10-05.tpf | 2 +-
4 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e6a8bf6..ada02ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+# Changes in version 1.?.? - 2017-??-??
+
+ * Medium changes
+ - When synchronizing descriptors from another CollecTor instance,
+ keep annotations provided by the descriptor and only add the
+ default annotation, when there was none.
+
+
# Changes in version 1.2.1 - 2017-08-17
* Medium changes
diff --git a/src/main/java/org/torproject/collector/persist/DescriptorPersistence.java b/src/main/java/org/torproject/collector/persist/DescriptorPersistence.java
index d54392d..e7bce5b 100644
--- a/src/main/java/org/torproject/collector/persist/DescriptorPersistence.java
+++ b/src/main/java/org/torproject/collector/persist/DescriptorPersistence.java
@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
+import java.util.List;
public abstract class DescriptorPersistence<T extends Descriptor> {
@@ -32,9 +33,18 @@ public abstract class DescriptorPersistence<T extends Descriptor> {
protected String recentPath;
/** Initializes the paths for storing descriptors of type <code>T</code>. */
- protected DescriptorPersistence(T desc, byte[] annotation) {
+ protected DescriptorPersistence(T desc, byte[] defaultAnnotation) {
this.desc = desc;
- this.annotation = annotation;
+ List<String> annotations = desc.getAnnotations();
+ if (annotations.isEmpty()) {
+ this.annotation = defaultAnnotation;
+ } else {
+ StringBuilder sb = new StringBuilder("");
+ for (String annotation : annotations) {
+ sb.append(annotation).append("\n");
+ }
+ this.annotation = sb.toString().getBytes();
+ }
}
/** Stores the descriptor to all locations.
diff --git a/src/test/resources/bridge-2016-10-02-08-09-00-extra-infos b/src/test/resources/bridge-2016-10-02-08-09-00-extra-infos
index f485178..7eea3f8 100644
--- a/src/test/resources/bridge-2016-10-02-08-09-00-extra-infos
+++ b/src/test/resources/bridge-2016-10-02-08-09-00-extra-infos
@@ -1,4 +1,5 @@
@type bridge-extra-info 1.3
+@some-future annotation
extra-info DragonBridge A8D07F92DF78FA2C208FA6675B56E0A7BB750794
master-key-ed25519 jBoYHwHIP9vplYgonlMUFJxND0QMEBqCnL2cEe2NbYc
published 2016-10-02 06:09:10
@@ -144,6 +145,13 @@ bridge-ip-transports <OR>=8,obfs3=8,obfs4=48
router-digest-sha256 b/PO7nPdxo+we9Tr/dQt2hAyu1TbtAWdjzac3CWYzpg
router-digest BCFCBB38B15E9B500B1A6E9B0BCBBCE858660F17
@type bridge-extra-info 1.3
+@many more annotations
+@one
+@two
+@three
+@four
+@five and
+@last and final
extra-info Unnamed 1283EDA3E80CA2D485CCFEDB9715392396DFAD29
master-key-ed25519 5GUbxrSHFtj6QjHHx5ovS2gAh8/ZjtbjU4yjULS0l0s
published 2016-10-02 06:09:43
diff --git a/src/test/resources/moria-1048576-2016-10-05.tpf b/src/test/resources/moria-1048576-2016-10-05.tpf
index ea05a13..780fa33 100644
--- a/src/test/resources/moria-1048576-2016-10-05.tpf
+++ b/src/test/resources/moria-1048576-2016-10-05.tpf
@@ -4,7 +4,7 @@ BUILDTIMES=0.658563137054,1.08981704712,1.52948904037 CIRC_ID=1166 CONNECT=14756
BUILDTIMES=0.696699857712,0.833825826645,0.981504917145 CIRC_ID=1172 CONNECT=1475627521.53 DATACOMPLETE=1475627523.30 DATAPERC10=1475627522.45 DATAPERC20=1475627522.57 DATAPERC30=1475627522.68 DATAPERC40=1475627522.73 DATAPERC50=1475627522.85 DATAPERC60=1475627522.93 DATAPERC70=1475627523.04 DATAPERC80=1475627523.05 DATAPERC90=1475627523.21 DATAREQUEST=1475627521.87 DATARESPONSE=1475627522.12 DIDTIMEOUT=0 FILESIZE=1048576 LAUNCH=1475626321.13 NEGOTIATE=1475627521.53 PATH=$B411027C926A9BFFCF7DA91E3CAF1856A321EFFD,$02928855BFAD787F8B363F21860D1E7D156E0655,$95DA61AEF23A6C851028C1AA88AD8593F659E60F QUANTILE=0.800000 READBYTES=1048873 REQUEST=1475627521.53 RESPONSE=1475627521.87 SOCKET=1475627521.53 SOURCE=moria START=1475627521.53 TIMEOUT=1500 USED_AT=1475627523.30 USED_BY=2771 WRITEBYTES=74
@type torperf 1.0
BUILDTIMES=0.574013948441,0.694298028946,0.844352960587 CIRC_ID=1173 CONNECT=1475629321.12 DATACOMPLETE=1475629323.34 DATAPERC10=1475629322.05 DATAPERC20=1475629322.18 DATAPERC30=1475629322.26 DATAPERC40=1475629322.44 DATAPERC50=1475629322.58 DATAPERC60=1475629322.76 DATAPERC70=1475629322.90 DATAPERC80=1475629323.13 DATAPERC90=1475629323.24 DATAREQUEST=1475629321.47 DATARESPONSE=1475629321.71 DIDTIMEOUT=0 FILESIZE=1048576 LAUNCH=1475628121.66 NEGOTIATE=1475629321.12 PATH=$20462CBA5DA4C2D963567D17D0B7249718114A68,$480CCC94CEA04D2DEABC0D7373868E245D4C2AE2,$E1E922A20AF608728824A620BADC6EFC8CB8C2B8 QUANTILE=0.800000 READBYTES=1048873 REQUEST=1475629321.12 RESPONSE=1475629321.47 SOCKET=1475629321.12 SOURCE=moria START=1475629321.12 TIMEOUT=1500 USED_AT=1475629323.35 USED_BY=2773 WRITEBYTES=74
-@type torperf 1.0
+@type torperf 0.9
BUILDTIMES=0.573640108109,0.690929174423,0.906491041183 CIRC_ID=1175 CONNECT=1475631121.93 DATACOMPLETE=1475631124.21 DATAPERC10=1475631122.88 DATAPERC20=1475631123.01 DATAPERC30=1475631123.11 DATAPERC40=1475631123.30 DATAPERC50=1475631123.40 DATAPERC60=1475631123.55 DATAPERC70=1475631123.69 DATAPERC80=1475631123.80 DATAPERC90=1475631123.97 DATAREQUEST=1475631122.27 DATARESPONSE=1475631122.54 DIDTIMEOUT=0 FILESIZE=1048576 LAUNCH=1475629921.18 NEGOTIATE=1475631121.93 PATH=$183C2E314DD677D28CDB6839A0204C4276F6E32D,$360911BEBE036BE7D0BA45B8FC07FF50119EB5B0,$47BAD834309368640EA066913DF741AF413EDE5E QUANTILE=0.800000 READBYTES=1048873 REQUEST=1475631121.93 RESPONSE=1475631122.27 SOCKET=1475631121.93 SOURCE=moria START=1475631121.93 TIMEOUT=1500 USED_AT=1475631124.22 USED_BY=2776 WRITEBYTES=74
@type torperf 1.0
BUILDTIMES=0.578256845474,0.696436882019,0.842072963715 CIRC_ID=1176 CONNECT=1475632921.76 DATACOMPLETE=1475632923.47 DATAPERC10=1475632922.60 DATAPERC20=1475632922.69 DATAPERC30=1475632922.78 DATAPERC40=1475632922.90 DATAPERC50=1475632922.94 DATAPERC60=1475632923.03 DATAPERC70=1475632923.11 DATAPERC80=1475632923.23 DATAPERC90=1475632923.32 DATAREQUEST=1475632922.05 DATARESPONSE=1475632922.29 DIDTIMEOUT=0 FILESIZE=1048576 LAUNCH=1475631721.73 NEGOTIATE=1475632921.76 PATH=$888933294902B310106CF68C012ECDD110114452,$7961C9991F022C8A363FD440CA395D47DB5D44D5,$F65E0196C94DFFF48AFBF2F5F9E3E19AAE583FD0 QUANTILE=0.800000 READBYTES=1048873 REQUEST=1475632921.76 RESPONSE=1475632922.05 SOCKET=1475632921.76 SOURCE=moria START=1475632921.76 TIMEOUT=1500 USED_AT=1475632923.48 USED_BY=2799 WRITEBYTES=74
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits