mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Merge branch 'improve-network-statistics' into bundle-msg-at-broadcast
This commit is contained in:
commit
bef470031e
@ -43,7 +43,7 @@ public class PriceRequest {
|
||||
final String baseUrl = provider.getBaseUrl();
|
||||
final SettableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> resultFuture = SettableFuture.create();
|
||||
ListenableFuture<Tuple2<Map<String, Long>, Map<String, MarketPrice>>> future = executorService.submit(() -> {
|
||||
Thread.currentThread().setName("PriceRequest-" + provider.toString());
|
||||
Thread.currentThread().setName("PriceRequest-" + provider.getBaseUrl());
|
||||
return provider.getAll();
|
||||
});
|
||||
|
||||
|
@ -50,52 +50,52 @@ public class Statistic {
|
||||
private final static LongProperty totalReceivedBytes = new SimpleLongProperty(0);
|
||||
private final static Map<String, Integer> totalReceivedMessages = new ConcurrentHashMap<>();
|
||||
private final static Map<String, Integer> totalSentMessages = new ConcurrentHashMap<>();
|
||||
private final static Map<String, Integer> totalReceivedMessagesPerSec = new ConcurrentHashMap<>();
|
||||
private final static Map<String, Integer> totalSentMessagesPerSec = new ConcurrentHashMap<>();
|
||||
private final static Map<String, Integer> totalReceivedMessagesLastSec = new ConcurrentHashMap<>();
|
||||
private final static Map<String, Integer> totalSentMessagesLastSec = new ConcurrentHashMap<>();
|
||||
private final static LongProperty numTotalSentMessages = new SimpleLongProperty(0);
|
||||
private final static LongProperty numTotalSentMessagesLastSec = new SimpleLongProperty(0);
|
||||
private final static DoubleProperty numTotalSentMessagesPerSec = new SimpleDoubleProperty(0);
|
||||
private final static LongProperty numTotalReceivedMessages = new SimpleLongProperty(0);
|
||||
private final static LongProperty numTotalReceivedMessagesLastSec = new SimpleLongProperty(0);
|
||||
private final static DoubleProperty numTotalReceivedMessagesPerSec = new SimpleDoubleProperty(0);
|
||||
private static String totalSentMessagesPerSecString;
|
||||
private static String totalReceivedMessagesPerSecString;
|
||||
private static String totalSentMessagesLastSecString;
|
||||
private static String totalReceivedMessagesLastSecString;
|
||||
|
||||
static {
|
||||
UserThread.runPeriodically(() -> {
|
||||
numTotalSentMessages.set(totalSentMessages.values().stream().mapToInt(Integer::intValue).sum());
|
||||
numTotalSentMessagesLastSec.set(totalSentMessagesPerSec.values().stream().mapToInt(Integer::intValue).sum());
|
||||
numTotalSentMessagesLastSec.set(totalSentMessagesLastSec.values().stream().mapToInt(Integer::intValue).sum());
|
||||
numTotalReceivedMessages.set(totalReceivedMessages.values().stream().mapToInt(Integer::intValue).sum());
|
||||
numTotalReceivedMessagesLastSec.set(totalReceivedMessagesPerSec.values().stream().mapToInt(Integer::intValue).sum());
|
||||
numTotalReceivedMessagesLastSec.set(totalReceivedMessagesLastSec.values().stream().mapToInt(Integer::intValue).sum());
|
||||
|
||||
long passed = (System.currentTimeMillis() - startTime) / 1000;
|
||||
numTotalSentMessagesPerSec.set(((double) numTotalSentMessages.get()) / passed);
|
||||
numTotalReceivedMessagesPerSec.set(((double) numTotalReceivedMessages.get()) / passed);
|
||||
|
||||
// We keep totalSentMessagesPerSec in a string so it is available at logging (totalSentMessagesPerSec is reset)
|
||||
totalSentMessagesPerSecString = totalSentMessagesPerSec.toString();
|
||||
totalReceivedMessagesPerSecString = totalReceivedMessagesPerSec.toString();
|
||||
totalSentMessagesLastSecString = totalSentMessagesLastSec.toString();
|
||||
totalReceivedMessagesLastSecString = totalReceivedMessagesLastSec.toString();
|
||||
|
||||
// We do not clear the map as the totalSentMessagesPerSec is not thread safe and clearing could lead to null pointers
|
||||
totalSentMessagesPerSec.entrySet().forEach(e -> e.setValue(0));
|
||||
totalReceivedMessagesPerSec.entrySet().forEach(e -> e.setValue(0));
|
||||
totalSentMessagesLastSec.entrySet().forEach(e -> e.setValue(0));
|
||||
totalReceivedMessagesLastSec.entrySet().forEach(e -> e.setValue(0));
|
||||
}, 1);
|
||||
|
||||
// We log statistics every minute
|
||||
UserThread.runPeriodically(() -> {
|
||||
log.info("Network statistics:\n" +
|
||||
"totalSentBytes: {} kb;\n" +
|
||||
"numTotalSentMessages/totalSentMessages: {} / {};\n" +
|
||||
"numTotalSentMessagesLastSec/totalSentMessagesPerSec: {} / {};\n" +
|
||||
"totalReceivedBytes: {} kb\n" +
|
||||
"numTotalReceivedMessages/totalReceivedMessages: {} / {};\n" +
|
||||
"numTotalReceivedMessagesLastSec/totalReceivedMessagesPerSec: {} / {};",
|
||||
"Bytes sent: {} kb;\n" +
|
||||
"Number of sent messages/Sent messages: {} / {};\n" +
|
||||
"Number of sent messages of last sec/Sent messages of last sec: {} / {};\n" +
|
||||
"Bytes received: {} kb\n" +
|
||||
"Number of received messages/Received messages: {} / {};\n" +
|
||||
"Number of received messages of last sec/Received messages of last sec: {} / {};",
|
||||
totalSentBytes.get() / 1024d,
|
||||
numTotalSentMessages.get(), totalSentMessages,
|
||||
numTotalSentMessagesLastSec.get(), totalSentMessagesPerSecString,
|
||||
numTotalSentMessagesLastSec.get(), totalSentMessagesLastSecString,
|
||||
totalReceivedBytes.get() / 1024d,
|
||||
numTotalReceivedMessages.get(), totalReceivedMessages,
|
||||
numTotalReceivedMessagesLastSec.get(), totalReceivedMessagesPerSecString);
|
||||
numTotalReceivedMessagesLastSec.get(), totalReceivedMessagesLastSecString);
|
||||
}, 60);
|
||||
}
|
||||
|
||||
@ -191,10 +191,10 @@ public class Statistic {
|
||||
totalReceivedMessages.put(messageClassName, counter);
|
||||
|
||||
counter = 1;
|
||||
if (totalReceivedMessagesPerSec.containsKey(messageClassName)) {
|
||||
counter = totalReceivedMessagesPerSec.get(messageClassName) + 1;
|
||||
if (totalReceivedMessagesLastSec.containsKey(messageClassName)) {
|
||||
counter = totalReceivedMessagesLastSec.get(messageClassName) + 1;
|
||||
}
|
||||
totalReceivedMessagesPerSec.put(messageClassName, counter);
|
||||
totalReceivedMessagesLastSec.put(messageClassName, counter);
|
||||
}
|
||||
|
||||
void addSentMessage(NetworkEnvelope networkEnvelope) {
|
||||
@ -212,10 +212,10 @@ public class Statistic {
|
||||
totalSentMessages.put(messageClassName, counter);
|
||||
|
||||
counter = 1;
|
||||
if (totalSentMessagesPerSec.containsKey(messageClassName)) {
|
||||
counter = totalSentMessagesPerSec.get(messageClassName) + 1;
|
||||
if (totalSentMessagesLastSec.containsKey(messageClassName)) {
|
||||
counter = totalSentMessagesLastSec.get(messageClassName) + 1;
|
||||
}
|
||||
totalSentMessagesPerSec.put(messageClassName, counter);
|
||||
totalSentMessagesLastSec.put(messageClassName, counter);
|
||||
}
|
||||
|
||||
public void setRoundTripTime(int roundTripTime) {
|
||||
|
Loading…
Reference in New Issue
Block a user