Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
Metrics
Library
Commits
45ad8a0d
Commit
45ad8a0d
authored
Apr 15, 2016
by
Karsten Loesing
Browse files
Make unrecognized keys of Torperf results available.
parent
6f561bef
Changes
3
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
45ad8a0d
...
...
@@ -4,6 +4,8 @@
-
Include the hostname in directory source entries of consensuses
and votes.
-
Also accept
\r\n
as newline in Torperf results files.
-
Make unrecognized keys of Torperf results available together with
the corresponding values, rather than just the whole line.
*
Minor changes
-
Include a Torperf results line with more than one unrecognized
...
...
src/org/torproject/descriptor/TorperfResult.java
View file @
45ad8a0d
/* Copyright 2012--201
5
The Tor Project
/* Copyright 2012--201
6
The Tor Project
* See LICENSE for licensing information */
package
org.torproject.descriptor
;
...
...
@@ -7,6 +7,10 @@ import java.util.SortedMap;
public
interface
TorperfResult
extends
Descriptor
{
/* Return all unrecognized keys together with their values, or null if
* all keys were recognized. */
public
SortedMap
<
String
,
String
>
getUnrecognizedKeys
();
/* Return the configured name of the data source. */
public
String
getSource
();
...
...
src/org/torproject/descriptor/impl/TorperfResultImpl.java
View file @
45ad8a0d
...
...
@@ -153,6 +153,10 @@ public class TorperfResultImpl extends DescriptorImpl
throw
new
DescriptorParseException
(
"Unrecognized key '"
+
key
+
"' in line '"
+
line
+
"'."
);
}
else
{
if
(
this
.
unrecognizedKeys
==
null
)
{
this
.
unrecognizedKeys
=
new
TreeMap
<>();
}
this
.
unrecognizedKeys
.
put
(
key
,
value
);
if
(
this
.
unrecognizedLines
==
null
)
{
this
.
unrecognizedLines
=
new
ArrayList
<>();
}
...
...
@@ -275,16 +279,19 @@ public class TorperfResultImpl extends DescriptorImpl
Arrays
.
asList
(
"10,20,30,40,50,60,70,80,90"
.
split
(
","
)));
private
void
parseDataPercentile
(
String
value
,
String
keyValue
,
String
line
)
throws
DescriptorParseException
{
String
percentileString
=
keyValue
.
substring
(
"DATAPERC"
.
length
(),
keyValue
.
indexOf
(
"="
));
String
key
=
keyValue
.
substring
(
0
,
keyValue
.
indexOf
(
"="
));
String
percentileString
=
key
.
substring
(
"DATAPERC"
.
length
(
));
if
(!
this
.
unparsedPercentiles
.
contains
(
percentileString
))
{
throw
new
DescriptorParseException
(
"Illegal value in '"
+
keyValue
+
"' in line '"
+
line
+
"'."
);
if
(
this
.
unrecognizedKeys
==
null
)
{
this
.
unrecognizedKeys
=
new
TreeMap
<>();
}
this
.
unrecognizedKeys
.
put
(
key
,
value
);
}
else
{
this
.
unparsedPercentiles
.
remove
(
percentileString
);
int
decileIndex
=
(
Integer
.
parseInt
(
percentileString
)
/
10
)
-
1
;
long
timestamp
=
this
.
parseTimestamp
(
value
,
keyValue
,
line
);
this
.
dataDeciles
[
decileIndex
]
=
timestamp
;
}
this
.
unparsedPercentiles
.
remove
(
percentileString
);
int
decileIndex
=
(
Integer
.
parseInt
(
percentileString
)
/
10
)
-
1
;
long
timestamp
=
this
.
parseTimestamp
(
value
,
keyValue
,
line
);
this
.
dataDeciles
[
decileIndex
]
=
timestamp
;
}
private
void
parseLaunch
(
String
value
,
String
keyValue
,
String
line
)
...
...
@@ -383,6 +390,12 @@ public class TorperfResultImpl extends DescriptorImpl
}
}
private
SortedMap
<
String
,
String
>
unrecognizedKeys
;
public
SortedMap
<
String
,
String
>
getUnrecognizedKeys
()
{
return
this
.
unrecognizedKeys
==
null
?
null
:
new
TreeMap
<>(
this
.
unrecognizedKeys
);
}
private
String
source
;
public
String
getSource
()
{
return
this
.
source
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment