Skip to content
GitLab
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
Onionoo
Commits
b8e3e95f
Commit
b8e3e95f
authored
Aug 21, 2018
by
Karsten Loesing
Browse files
Use parameterized log statements.
parent
680118d0
Changes
18
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/torproject/onionoo/cron/Main.java
View file @
b8e3e95f
...
...
@@ -115,8 +115,8 @@ public class Main implements Runnable {
int
initialDelay
=
(
75
-
currentMinute
+
currentMinute
%
5
)
%
60
;
/* Run after initialDelay delay and then every hour. */
this
.
log
.
info
(
"Periodic updater will start every hour at minute
"
+
(
(
currentMinute
+
initialDelay
)
%
60
)
+
"."
)
;
this
.
log
.
info
(
"Periodic updater will start every hour at minute
{}."
,
(
currentMinute
+
initialDelay
)
%
60
);
this
.
scheduler
.
scheduleAtFixedRate
(
mainRunnable
,
initialDelay
,
60
,
TimeUnit
.
MINUTES
);
}
...
...
@@ -210,10 +210,10 @@ public class Main implements Runnable {
this
.
dwr
.
logStatistics
();
}
if
(
this
.
dso
!=
null
)
{
this
.
log
.
info
(
"Descriptor source\n
"
+
this
.
dso
.
getStatsString
());
this
.
log
.
info
(
"Descriptor source\n
{}"
,
this
.
dso
.
getStatsString
());
}
if
(
this
.
ds
!=
null
)
{
this
.
log
.
info
(
"Document store\n
"
+
this
.
ds
.
getStatsString
());
this
.
log
.
info
(
"Document store\n
{}"
,
this
.
ds
.
getStatsString
());
}
}
...
...
src/main/java/org/torproject/onionoo/docs/BandwidthStatus.java
View file @
b8e3e95f
...
...
@@ -55,8 +55,8 @@ public class BandwidthStatus extends Document {
String
line
=
s
.
nextLine
();
String
[]
parts
=
line
.
split
(
" "
);
if
(
parts
.
length
!=
6
)
{
log
.
error
(
"Illegal line '
"
+
line
+
"
' in bandwidth "
+
"
history. Skipping this
line
."
);
log
.
error
(
"Illegal line '
{}
' in bandwidth
history. Skipping this
"
+
"
line."
,
line
);
continue
;
}
SortedMap
<
Long
,
long
[]>
history
=
parts
[
0
].
equals
(
"r"
)
...
...
src/main/java/org/torproject/onionoo/docs/ClientsHistory.java
View file @
b8e3e95f
...
...
@@ -73,29 +73,28 @@ public class ClientsHistory implements Comparable<ClientsHistory> {
String
responseHistoryString
)
{
String
[]
parts
=
responseHistoryString
.
split
(
" "
,
8
);
if
(
parts
.
length
!=
8
)
{
log
.
warn
(
"Invalid number of space-separated strings in clients "
+
"
history: '"
+
responseHistoryString
+
"'. Skipping"
);
log
.
warn
(
"Invalid number of space-separated strings in clients
history:
"
+
"
'{}'. Skipping"
,
responseHistoryString
);
return
null
;
}
long
startMillis
=
DateTimeHelper
.
parse
(
parts
[
0
]
+
" "
+
parts
[
1
]);
long
endMillis
=
DateTimeHelper
.
parse
(
parts
[
2
]
+
" "
+
parts
[
3
]);
if
(
startMillis
<
0L
||
endMillis
<
0L
)
{
log
.
warn
(
"Invalid start or end timestamp in clients history: '"
+
responseHistoryString
+
"'. Skipping."
);
log
.
warn
(
"Invalid start or end timestamp in clients history: '
{}'.
"
+
"Skipping."
,
responseHistoryString
);
return
null
;
}
if
(
startMillis
>=
endMillis
)
{
log
.
warn
(
"Start timestamp must be smaller than end timestamp in "
+
"clients history: '"
+
responseHistoryString
+
"'. Skipping."
);
log
.
warn
(
"Start timestamp must be smaller than end timestamp in clients "
+
"history: '{}'. Skipping."
,
responseHistoryString
);
return
null
;
}
double
totalResponses
;
try
{
totalResponses
=
Double
.
parseDouble
(
parts
[
4
]);
}
catch
(
NumberFormatException
e
)
{
log
.
warn
(
"Invalid response number format in clients history: '"
+
responseHistoryString
+
"'. Skipping."
);
log
.
warn
(
"Invalid response number format in clients history: '
{}'.
"
+
"Skipping."
,
responseHistoryString
);
return
null
;
}
SortedMap
<
String
,
Double
>
responsesByCountry
=
...
...
@@ -106,9 +105,8 @@ public class ClientsHistory implements Comparable<ClientsHistory> {
parseResponses
(
parts
[
7
]);
if
(
responsesByCountry
==
null
||
responsesByTransport
==
null
||
responsesByVersion
==
null
)
{
log
.
warn
(
"Invalid format of responses by country, transport, or "
+
"version in clients history: '"
+
responseHistoryString
+
"'. Skipping."
);
log
.
warn
(
"Invalid format of responses by country, transport, or version "
+
"in clients history: '{}'. Skipping."
,
responseHistoryString
);
return
null
;
}
return
new
ClientsHistory
(
startMillis
,
endMillis
,
totalResponses
,
...
...
src/main/java/org/torproject/onionoo/docs/ClientsStatus.java
View file @
b8e3e95f
...
...
@@ -44,8 +44,8 @@ public class ClientsStatus extends Document {
if
(
parsedLine
!=
null
)
{
this
.
history
.
add
(
parsedLine
);
}
else
{
log
.
error
(
"Could not parse clients history line '
"
+
line
+
"'. Skipping."
);
log
.
error
(
"Could not parse clients history line '
{}'. Skipping."
,
line
);
}
}
}
...
...
src/main/java/org/torproject/onionoo/docs/DocumentStore.java
View file @
b8e3e95f
...
...
@@ -135,8 +135,8 @@ public class DocumentStore {
this
.
listedFiles
+=
parsedNodeStatuses
.
size
();
this
.
listOperations
++;
}
catch
(
IOException
e
)
{
log
.
error
(
"Could not read file '
"
+
summaryFile
.
getAbsolutePath
()
+
"'."
,
e
);
log
.
error
(
"Could not read file '
{}'."
,
summaryFile
.
getAbsolutePath
(),
e
);
}
}
}
...
...
@@ -339,15 +339,15 @@ public class DocumentStore {
||
document
instanceof
UpdateStatus
)
{
documentString
=
document
.
toDocumentString
();
}
else
{
log
.
error
(
"Serializing is not supported for type
"
+
document
.
getClass
().
getName
()
+
"."
);
log
.
error
(
"Serializing is not supported for type
{}."
,
document
.
getClass
().
getName
());
return
false
;
}
try
{
if
(
documentString
.
length
()
>
ONE_MIBIBYTE
)
{
log
.
warn
(
"Attempting to store very large document file: path='"
+
documentFile
.
getAbsolutePath
()
+
"', bytes="
+
documentString
.
length
());
log
.
warn
(
"Attempting to store very large document file: path='
{}',
"
+
"bytes={}"
,
documentFile
.
getAbsolutePath
()
,
documentString
.
length
());
}
documentFile
.
getParentFile
().
mkdirs
();
File
documentTempFile
=
new
File
(
...
...
@@ -358,8 +358,8 @@ public class DocumentStore {
this
.
storedFiles
++;
this
.
storedBytes
+=
documentString
.
length
();
}
catch
(
IOException
e
)
{
log
.
error
(
"Could not write file '
"
+
documentFile
.
getAbsolutePath
()
+
"'."
,
e
);
log
.
error
(
"Could not write file '
{}'."
,
documentFile
.
getAbsolutePath
(),
e
);
return
false
;
}
return
true
;
...
...
@@ -419,10 +419,10 @@ public class DocumentStore {
String
contact
=
null
;
for
(
String
orAddressAndPort
:
detailsDocument
.
getOrAddresses
())
{
if
(!
orAddressAndPort
.
contains
(
":"
))
{
log
.
warn
(
"Attempt to create summary document from details "
+
"
document for fingerprint "
+
fingerprint
+
" failed
"
+
"
because of invalid OR address/port: '"
+
orAddressAndPort
+
"'. Not returning a summary document in this case."
);
log
.
warn
(
"Attempt to create summary document from details
document for
"
+
"
fingerprint {} failed because of invalid OR address/port: '{}'.
"
+
"
Not returning a summary document in this case."
,
fingerprint
,
orAddressAndPort
);
return
null
;
}
String
orAddress
=
orAddressAndPort
.
substring
(
0
,
...
...
@@ -464,9 +464,8 @@ public class DocumentStore {
/* Document file does not exist. That's okay. */
return
null
;
}
else
if
(
documentFile
.
isDirectory
())
{
log
.
error
(
"Could not read file '"
+
documentFile
.
getAbsolutePath
()
+
"', because it is a "
+
"directory."
);
log
.
error
(
"Could not read file '{}', because it is a directory."
,
documentFile
.
getAbsolutePath
());
return
null
;
}
String
documentString
;
...
...
@@ -487,14 +486,12 @@ public class DocumentStore {
this
.
retrievedFiles
++;
this
.
retrievedBytes
+=
documentString
.
length
();
}
catch
(
IOException
e
)
{
log
.
error
(
"Could not read file '"
+
documentFile
.
getAbsolutePath
()
+
"'."
,
e
);
log
.
error
(
"Could not read file '{}'."
,
documentFile
.
getAbsolutePath
(),
e
);
return
null
;
}
if
(
documentString
.
length
()
>
ONE_MIBIBYTE
)
{
log
.
warn
(
"Retrieved very large document file: path='"
+
documentFile
.
getAbsolutePath
()
+
"', bytes="
+
documentString
.
length
());
log
.
warn
(
"Retrieved very large document file: path='{}', bytes={}"
,
documentFile
.
getAbsolutePath
(),
documentString
.
length
());
}
T
result
=
null
;
if
(!
parse
)
{
...
...
@@ -517,8 +514,8 @@ public class DocumentStore {
return
this
.
retrieveParsedDocumentFile
(
documentType
,
"{"
+
documentString
+
"}"
);
}
else
{
log
.
error
(
"Parsing is not supported for type
"
+
documentType
.
getName
()
+
"."
);
log
.
error
(
"Parsing is not supported for type
{}."
,
documentType
.
getName
());
}
return
result
;
}
...
...
@@ -534,8 +531,8 @@ public class DocumentStore {
log
.
error
(
e
.
getMessage
(),
e
);
}
if
(
result
==
null
)
{
log
.
error
(
"Could not initialize parsed status file of
"
+
"type "
+
documentType
.
getName
()
+
"."
);
log
.
error
(
"Could not initialize parsed status file of
type {}."
,
documentType
.
getName
());
}
return
result
;
}
...
...
@@ -551,8 +548,8 @@ public class DocumentStore {
log
.
error
(
e
.
getMessage
(),
e
);
}
if
(
result
==
null
)
{
log
.
error
(
"Could not initialize parsed document of type
"
+
documentType
.
getName
()
+
"."
);
log
.
error
(
"Could not initialize parsed document of type
{}."
,
documentType
.
getName
());
}
return
result
;
}
...
...
@@ -568,8 +565,8 @@ public class DocumentStore {
log
.
error
(
e
.
getMessage
(),
e
);
}
if
(
result
==
null
)
{
log
.
error
(
"Could not initialize unparsed document of type
"
+
documentType
.
getName
()
+
"."
);
log
.
error
(
"Could not initialize unparsed document of type
{}."
,
documentType
.
getName
());
}
return
result
;
}
...
...
@@ -611,8 +608,7 @@ public class DocumentStore {
Class
<
T
>
documentType
,
String
fingerprint
)
{
File
documentFile
=
this
.
getDocumentFile
(
documentType
,
fingerprint
);
if
(
documentFile
==
null
||
!
documentFile
.
delete
())
{
log
.
error
(
"Could not delete file '"
+
documentFile
.
getAbsolutePath
()
+
"'."
);
log
.
error
(
"Could not delete file '{}'."
,
documentFile
.
getAbsolutePath
());
return
false
;
}
this
.
removedFiles
++;
...
...
@@ -624,9 +620,9 @@ public class DocumentStore {
File
documentFile
=
null
;
if
(
fingerprint
==
null
&&
!
documentType
.
equals
(
UpdateStatus
.
class
)
&&
!
documentType
.
equals
(
UptimeStatus
.
class
))
{
log
.
warn
(
"Attempted to locate a document file of type "
+
documentType
.
getName
()
+
" without providing a fingerprint. "
+
"Such a file does not exist."
);
log
.
warn
(
"Attempted to locate a document file of type
{} without
"
+
"providing a fingerprint. Such a file does not exist."
,
documentType
.
getName
()
);
return
null
;
}
File
directory
=
null
;
...
...
@@ -739,8 +735,8 @@ public class DocumentStore {
if
(
line
!=
null
)
{
sb
.
append
(
line
).
append
(
"\n"
);
}
else
{
log
.
error
(
"Could not serialize relay node status '
"
+
relay
.
getFingerprint
()
+
"'"
);
log
.
error
(
"Could not serialize relay node status '
{}'"
,
relay
.
getFingerprint
());
}
}
for
(
NodeStatus
bridge
:
cachedBridges
.
values
())
{
...
...
@@ -748,8 +744,8 @@ public class DocumentStore {
if
(
line
!=
null
)
{
sb
.
append
(
line
).
append
(
"\n"
);
}
else
{
log
.
error
(
"Could not serialize bridge node status '
"
+
bridge
.
getFingerprint
()
+
"'"
);
log
.
error
(
"Could not serialize bridge node status '
{}'"
,
bridge
.
getFingerprint
());
}
}
String
documentString
=
sb
.
toString
();
...
...
@@ -761,8 +757,7 @@ public class DocumentStore {
this
.
storedFiles
++;
this
.
storedBytes
+=
documentString
.
length
();
}
catch
(
IOException
e
)
{
log
.
error
(
"Could not write file '"
+
summaryFile
.
getAbsolutePath
()
+
"'."
,
e
);
log
.
error
(
"Could not write file '{}'."
,
summaryFile
.
getAbsolutePath
(),
e
);
}
}
...
...
@@ -791,8 +786,8 @@ public class DocumentStore {
if
(
line
!=
null
)
{
sb
.
append
(
line
).
append
(
"\n"
);
}
else
{
log
.
error
(
"Could not serialize relay summary document '
"
+
summaryDocument
.
getFingerprint
()
+
"'"
);
log
.
error
(
"Could not serialize relay summary document '
{}'"
,
summaryDocument
.
getFingerprint
());
}
}
String
documentString
=
sb
.
toString
();
...
...
@@ -805,8 +800,7 @@ public class DocumentStore {
this
.
storedFiles
++;
this
.
storedBytes
+=
documentString
.
length
();
}
catch
(
IOException
e
)
{
log
.
error
(
"Could not write file '"
+
summaryFile
.
getAbsolutePath
()
+
"'."
,
e
);
log
.
error
(
"Could not write file '{}'."
,
summaryFile
.
getAbsolutePath
(),
e
);
}
}
...
...
src/main/java/org/torproject/onionoo/docs/NodeStatus.java
View file @
b8e3e95f
...
...
@@ -553,8 +553,8 @@ public class NodeStatus extends Document {
try
{
String
[]
parts
=
documentString
.
trim
().
split
(
"\t"
);
if
(
parts
.
length
<
23
)
{
log
.
error
(
"Too few space-separated values in line '
"
+
documentString
.
trim
()
+
"'. Skipping."
);
log
.
error
(
"Too few space-separated values in line '
{}'. Skipping."
,
documentString
.
trim
());
return
null
;
}
String
fingerprint
=
parts
[
2
];
...
...
@@ -568,8 +568,8 @@ public class NodeStatus extends Document {
if
(
addresses
.
contains
(
";"
))
{
String
[]
addressParts
=
addresses
.
split
(
";"
,
-
1
);
if
(
addressParts
.
length
!=
3
)
{
log
.
error
(
"Invalid addresses entry in line '
"
+
documentString
.
trim
()
+
"'. Skipping."
);
log
.
error
(
"Invalid addresses entry in line '
{}'. Skipping."
,
documentString
.
trim
());
return
null
;
}
address
=
addressParts
[
0
];
...
...
@@ -590,8 +590,8 @@ public class NodeStatus extends Document {
long
lastSeenMillis
=
DateTimeHelper
.
parse
(
parts
[
4
]
+
" "
+
parts
[
5
]);
if
(
lastSeenMillis
<
0L
)
{
log
.
error
(
"Parse exception while parsing node status "
+
"
line '"
+
documentString
+
"'. Skipping."
);
log
.
error
(
"Parse exception while parsing node status
line '{}'.
"
+
"
Skipping."
,
documentString
);
return
null
;
}
else
if
(
lastSeenMillis
==
0L
)
{
log
.
debug
(
"Skipping node status with fingerprint {} that has so far "
...
...
@@ -617,8 +617,8 @@ public class NodeStatus extends Document {
}
long
firstSeenMillis
=
DateTimeHelper
.
parse
(
parts
[
15
]
+
" "
+
parts
[
16
]);
if
(
firstSeenMillis
<
0L
)
{
log
.
error
(
"Parse exception while parsing node status "
+
"
line '"
+
documentString
+
"'. Skipping."
);
log
.
error
(
"Parse exception while parsing node status
line '{}'.
"
+
"
Skipping."
,
documentString
);
return
null
;
}
nodeStatus
.
setFirstSeenMillis
(
firstSeenMillis
);
...
...
@@ -627,8 +627,8 @@ public class NodeStatus extends Document {
lastChangedAddresses
=
DateTimeHelper
.
parse
(
parts
[
17
]
+
" "
+
parts
[
18
]);
if
(
lastChangedAddresses
<
0L
)
{
log
.
error
(
"Parse exception while parsing node status "
+
"
line '"
+
documentString
+
"'. Skipping."
);
log
.
error
(
"Parse exception while parsing node status
line '{}'.
"
+
"
Skipping."
,
documentString
);
return
null
;
}
}
...
...
@@ -693,16 +693,14 @@ public class NodeStatus extends Document {
}
return
nodeStatus
;
}
catch
(
NumberFormatException
e
)
{
log
.
error
(
"Number format exception while parsing node "
+
"status line '"
+
documentString
+
"': "
+
e
.
getMessage
()
+
". Skipping."
);
log
.
error
(
"Number format exception while parsing node status line '{}'. "
+
"Skipping."
,
documentString
,
e
);
return
null
;
}
catch
(
Exception
e
)
{
/* This catch block is only here to handle yet unknown errors. It
* should go away once we're sure what kind of errors can occur. */
log
.
error
(
"Unknown exception while parsing node status "
+
"line '"
+
documentString
+
"': "
+
e
.
getMessage
()
+
". "
+
"Skipping."
);
log
.
error
(
"Unknown exception while parsing node status line '{}'. "
+
"Skipping."
,
documentString
,
e
);
return
null
;
}
}
...
...
src/main/java/org/torproject/onionoo/docs/UpdateStatus.java
View file @
b8e3e95f
...
...
@@ -25,8 +25,8 @@ public class UpdateStatus extends Document {
try
{
this
.
updatedMillis
=
Long
.
parseLong
(
documentString
.
trim
());
}
catch
(
NumberFormatException
e
)
{
log
.
error
(
"Could not parse timestamp '
"
+
documentString
+
"'.
"
+
"
Setting to 1970-01-01 00:00:00."
);
log
.
error
(
"Could not parse timestamp '
{}'. Setting to 1970-01-01
"
+
"
00:00:00."
,
documentString
);
this
.
updatedMillis
=
0L
;
}
}
...
...
src/main/java/org/torproject/onionoo/docs/UptimeHistory.java
View file @
b8e3e95f
...
...
@@ -58,32 +58,31 @@ public class UptimeHistory implements Comparable<UptimeHistory> {
public
static
UptimeHistory
fromString
(
String
uptimeHistoryString
)
{
String
[]
parts
=
uptimeHistoryString
.
split
(
" "
,
-
1
);
if
(
parts
.
length
<
3
)
{
log
.
warn
(
"Invalid number of space-separated strings in uptime "
+
"
history: '"
+
uptimeHistoryString
+
"'. Skipping"
);
log
.
warn
(
"Invalid number of space-separated strings in uptime
history:
"
+
"
'{}'. Skipping"
,
uptimeHistoryString
);
return
null
;
}
boolean
relay
=
false
;
if
(
parts
[
0
].
equalsIgnoreCase
(
"r"
))
{
relay
=
true
;
}
else
if
(!
parts
[
0
].
equals
(
"b"
))
{
log
.
warn
(
"Invalid node type in uptime history: '"
+
uptimeHistoryString
+
"'. Supported types are 'r', 'R', and "
+
"'b'. Skipping."
);
log
.
warn
(
"Invalid node type in uptime history: '{}'. Supported types are "
+
"'r', 'R', and 'b'. Skipping."
,
uptimeHistoryString
);
return
null
;
}
long
startMillis
=
DateTimeHelper
.
parse
(
parts
[
1
],
DateTimeHelper
.
DATEHOUR_NOSPACE_FORMAT
);
if
(
DateTimeHelper
.
NO_TIME_AVAILABLE
==
startMillis
)
{
log
.
warn
(
"Invalid start timestamp in uptime history: '
"
+
uptimeHistoryString
+
"'. Skipping."
);
log
.
warn
(
"Invalid start timestamp in uptime history: '
{}'. Skipping."
,
uptimeHistoryString
);
return
null
;
}
int
uptimeHours
;
try
{
uptimeHours
=
Integer
.
parseInt
(
parts
[
2
]);
}
catch
(
NumberFormatException
e
)
{
log
.
warn
(
"Invalid number format in uptime history: '
"
+
uptimeHistoryString
+
"'. Skipping."
);
log
.
warn
(
"Invalid number format in uptime history: '
{}'. Skipping."
,
uptimeHistoryString
);
return
null
;
}
SortedSet
<
String
>
flags
=
null
;
...
...
src/main/java/org/torproject/onionoo/docs/UptimeStatus.java
View file @
b8e3e95f
...
...
@@ -51,8 +51,8 @@ public class UptimeStatus extends Document {
this
.
bridgeHistory
.
add
(
parsedLine
);
}
}
else
{
log
.
error
(
"Could not parse uptime history line '
"
+
line
+
"'. Skipping."
);
log
.
error
(
"Could not parse uptime history line '
{}'. Skipping."
,
line
);
}
}
}
...
...
src/main/java/org/torproject/onionoo/docs/WeightsStatus.java
View file @
b8e3e95f
...
...
@@ -58,8 +58,8 @@ public class WeightsStatus extends Document {
continue
;
}
if
(
parts
.
length
!=
9
&&
parts
.
length
!=
11
)
{
log
.
error
(
"Illegal line '
"
+
line
+
"' in weight
s "
+
"
status file. Skipping this
line
."
);
log
.
error
(
"Illegal line '
{}' in weights status file. Skipping thi
s "
+
"
line."
,
line
);
continue
;
}
if
(
parts
[
4
].
equals
(
"NaN"
))
{
...
...
@@ -75,8 +75,8 @@ public class WeightsStatus extends Document {
break
;
}
if
(
validAfterMillis
>
freshUntilMillis
)
{
log
.
error
(
"Illegal dates in '
"
+
line
+
"
' of weights
"
+
"status file. Skipping."
);
log
.
error
(
"Illegal dates in '
{}
' of weights
status file. Skipping."
,
line
);
break
;
}
long
[]
interval
=
new
long
[]
{
validAfterMillis
,
freshUntilMillis
};
...
...
@@ -91,8 +91,8 @@ public class WeightsStatus extends Document {
weights
[
6
]
=
parseWeightDouble
(
parts
[
10
]);
}
}
catch
(
NumberFormatException
e
)
{
log
.
error
(
"Could not parse weights values in line '
"
+
line
+
"
' while reading
weights status file.
Skipping."
);
log
.
error
(
"Could not parse weights values in line '
{}' while reading "
+
"weights status file. Skipping."
,
line
);
break
;
}
this
.
history
.
put
(
interval
,
weights
);
...
...
src/main/java/org/torproject/onionoo/server/NodeIndexer.java
View file @
b8e3e95f
...
...
@@ -37,8 +37,8 @@ public class NodeIndexer implements ServletContextListener, Runnable {
File
outDir
=
new
File
(
System
.
getProperty
(
"onionoo.basedir"
,
"/srv/onionoo.torproject.org/onionoo"
),
"out"
);
if
(!
outDir
.
exists
()
||
!
outDir
.
isDirectory
())
{
log
.
error
(
"\n\n\tOut-dir not found! Expected directory:
"
+
outDir
+
"\n\tSet system property 'onionoo.basedir'."
);
log
.
error
(
"\n\n\tOut-dir not found! Expected directory:
{}"
+
"\n\tSet system property 'onionoo.basedir'."
,
outDir
);
System
.
exit
(
1
);
}
DocumentStore
documentStore
=
DocumentStoreFactory
.
getDocumentStore
();
...
...
src/main/java/org/torproject/onionoo/server/PerformanceMetrics.java
View file @
b8e3e95f
...
...
@@ -65,26 +65,19 @@ public class PerformanceMetrics {
SimpleDateFormat
dateTimeFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
dateTimeFormat
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
log
.
info
(
"Request statistics ("
+
dateTimeFormat
.
format
(
lastLoggedMillis
+
LOG_INTERVAL_MILLIS
)
+
", "
+
(
LOG_INTERVAL_SECONDS
)
+
" s):"
);
log
.
info
(
" Total processed requests: "
+
totalProcessedRequests
);
log
.
info
(
" Most frequently requested resource: "
+
requestsByResourceType
);
log
.
info
(
" Most frequently requested parameter "
+
"combinations: "
+
requestsByParameters
);
log
.
info
(
" Matching relays per request: "
+
matchingRelayDocuments
);
log
.
info
(
" Matching bridges per request: "
+
matchingBridgeDocuments
);
log
.
info
(
" Written characters per response: "
+
writtenChars
);
log
.
info
(
" Milliseconds to handle request: "
+
handleRequestMillis
);
log
.
info
(
" Milliseconds to build response: "
+
buildResponseMillis
);
log
.
info
(
"Request statistics ({}, {} s):"
,
dateTimeFormat
.
format
(
lastLoggedMillis
+
LOG_INTERVAL_MILLIS
),
LOG_INTERVAL_SECONDS
);
log
.
info
(
" Total processed requests: {}"
,
totalProcessedRequests
);
log
.
info
(
" Most frequently requested resource: {}"
,
requestsByResourceType
);
log
.
info
(
" Most frequently requested parameter combinations: {}"
,
requestsByParameters
);
log
.
info
(
" Matching relays per request: {}"
,
matchingRelayDocuments
);
log
.
info
(
" Matching bridges per request: {}"
,
matchingBridgeDocuments
);
log
.
info
(
" Written characters per response: {}"
,
writtenChars
);
log
.
info
(
" Milliseconds to handle request: {}"
,
handleRequestMillis
);
log
.
info
(
" Milliseconds to build response: {}"
,
buildResponseMillis
);
totalProcessedRequests
.
clear
();
requestsByResourceType
.
clear
();
requestsByParameters
.
clear
();
...
...
@@ -101,9 +94,9 @@ public class PerformanceMetrics {
totalProcessedRequests
.
increment
();
long
handlingTime
=
parsedRequestMillis
-
receivedRequestMillis
;
if
(
handlingTime
>
DateTimeHelper
.
ONE_SECOND
)
{
log
.
warn
(
"longer request handling:
"
+
handlingTime
+
" ms for
"
+
resourceType
+
" params: "
+
parameterKeys
+
" and "
+
charsWritten
+
" chars."
);
log
.
warn
(
"longer request handling:
{} ms for {} params: {} and {}
"
+
"chars."
,
handlingTime
,
resourceType
,
parameterKeys
,
charsWritten
);
}
handleRequestMillis
.
addLong
(
handlingTime
);
requestsByResourceType
.
addString
(
resourceType
);
...
...
@@ -113,9 +106,9 @@ public class PerformanceMetrics {
writtenChars
.
addLong
(
charsWritten
);
long
responseTime
=
writtenResponseMillis
-
parsedRequestMillis
;
if
(
responseTime
>
DateTimeHelper
.
ONE_SECOND
)
{
log
.
warn
(
"longer response building:
"
+
responseTime
+
" ms for
"
+
resourceType
+
" params: "
+
parameterKeys
+
" and "
+
charsWritten
+
" chars."
);
log
.
warn
(
"longer response building:
{} ms for {} params: {} and {}
"
+
"chars."
,
responseTime
,
resourceType
,
parameterKeys
,
charsWritten
);
}
buildResponseMillis
.
addLong
(
responseTime
);
}
...
...
src/main/java/org/torproject/onionoo/server/ServerMain.java
View file @
b8e3e95f
...
...
@@ -18,14 +18,14 @@ public class ServerMain {
public
static
void
main
(
String
[]
args
)
{
try
{
Resource
onionooXml
=
Resource
.
newSystemResource
(
"jetty.xml"
);
log
.
info
(
"Reading configuration from '
"
+
onionooXml
+
"'."
);
log
.
info
(
"Reading configuration from '
{}'."
,
onionooXml
);
XmlConfiguration
configuration
=
new
XmlConfiguration
(
onionooXml
.
getInputStream
());
Server
server
=
(
Server
)
configuration
.
configure
();
server
.
start
();
server
.
join
();
}
catch
(
Exception
ex
)
{
log
.
error
(
"Exiting, because of:
"
+
ex
.
getMessage
(),
ex
);
log
.
error
(
"Exiting, because of:
{}"
,
ex
.
getMessage
(),
ex
);
System
.
exit
(
1
);
}
}
...
...
src/main/java/org/torproject/onionoo/updater/DescriptorQueue.java
View file @
b8e3e95f
...
...
@@ -89,14 +89,14 @@ class DescriptorQueue {
String
[]
parts
=
line
.
split
(
" "
,
2
);
excludedFiles
.
put
(
parts
[
1
],
Long
.
parseLong
(
parts
[
0
]));