diff --git a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/MonitorP2PModule.java b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/MonitorP2PModule.java
index 80e8571150..32bad2ab14 100644
--- a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/MonitorP2PModule.java
+++ b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/MonitorP2PModule.java
@@ -32,6 +32,7 @@ import io.bisq.network.p2p.peers.getdata.RequestDataManager;
import io.bisq.network.p2p.peers.keepalive.KeepAliveManager;
import io.bisq.network.p2p.peers.peerexchange.PeerExchangeManager;
import io.bisq.network.p2p.storage.P2PDataStorage;
+import io.bisq.seednode_monitor.metrics.MetricsModel;
import org.springframework.core.env.Environment;
import java.io.File;
@@ -47,7 +48,7 @@ public class MonitorP2PModule extends AppModule {
@Override
protected void configure() {
- bind(MetricsByNodeAddressMap.class).in(Singleton.class);
+ bind(MetricsModel.class).in(Singleton.class);
bind(MonitorP2PService.class).in(Singleton.class);
bind(PeerManager.class).in(Singleton.class);
diff --git a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/MonitorP2PService.java b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/MonitorP2PService.java
index 68b2291dd8..9421778dfd 100644
--- a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/MonitorP2PService.java
+++ b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/MonitorP2PService.java
@@ -23,7 +23,7 @@ import io.bisq.network.Socks5ProxyProvider;
import io.bisq.network.p2p.network.NetworkNode;
import io.bisq.network.p2p.network.SetupListener;
import io.bisq.network.p2p.storage.P2PDataStorage;
-import io.bisq.seednode_monitor.request.MonitorRequestManager;
+import io.bisq.seednode_monitor.metrics.MonitorRequestManager;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
diff --git a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/SeedNodeMonitor.java b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/SeedNodeMonitor.java
index 35b792c6d4..284c49e4c8 100644
--- a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/SeedNodeMonitor.java
+++ b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/SeedNodeMonitor.java
@@ -20,6 +20,7 @@ import io.bisq.core.btc.wallet.BsqWalletService;
import io.bisq.core.btc.wallet.BtcWalletService;
import io.bisq.core.btc.wallet.WalletsSetup;
import io.bisq.core.offer.OpenOfferManager;
+import io.bisq.seednode_monitor.metrics.MetricsModel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -36,7 +37,7 @@ public class SeedNodeMonitor {
private static SeedNodeMonitorEnvironment environment;
@Getter
- private final MetricsByNodeAddressMap metricsByNodeAddressMap;
+ private final MetricsModel metricsService;
public static void setEnvironment(SeedNodeMonitorEnvironment environment) {
SeedNodeMonitor.environment = environment;
@@ -96,7 +97,7 @@ public class SeedNodeMonitor {
seedNodeModule = new SeedNodeMonitorModule(environment);
injector = Guice.createInjector(seedNodeModule);
- metricsByNodeAddressMap = injector.getInstance(MetricsByNodeAddressMap.class);
+ metricsService = injector.getInstance(MetricsModel.class);
MonitorAppSetup appSetup = injector.getInstance(MonitorAppSetup.class);
appSetup.start();
diff --git a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/SeedNodeMonitorMain.java b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/SeedNodeMonitorMain.java
index b898c843df..86dd891db8 100644
--- a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/SeedNodeMonitorMain.java
+++ b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/SeedNodeMonitorMain.java
@@ -99,7 +99,7 @@ public class SeedNodeMonitorMain extends BisqExecutable {
port(8080);
get("/", (req, res) -> {
log.info("Incoming request from: " + req.userAgent());
- return seedNodeMonitor.getMetricsByNodeAddressMap().getResultAsHtml();
+ return seedNodeMonitor.getMetricsService().getResultAsHtml();
});
new SeedNodeMonitorMain().execute(args);
diff --git a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/Metrics.java b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/metrics/Metrics.java
similarity index 95%
rename from seednode_monitor/src/main/java/io/bisq/seednode_monitor/Metrics.java
rename to seednode_monitor/src/main/java/io/bisq/seednode_monitor/metrics/Metrics.java
index 59288c2f02..cb26f4987a 100644
--- a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/Metrics.java
+++ b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/metrics/Metrics.java
@@ -15,7 +15,7 @@
* along with bisq. If not, see .
*/
-package io.bisq.seednode_monitor;
+package io.bisq.seednode_monitor.metrics;
import lombok.Getter;
diff --git a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/MetricsByNodeAddressMap.java b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/metrics/MetricsModel.java
similarity index 89%
rename from seednode_monitor/src/main/java/io/bisq/seednode_monitor/MetricsByNodeAddressMap.java
rename to seednode_monitor/src/main/java/io/bisq/seednode_monitor/metrics/MetricsModel.java
index ae15b6bdcd..419cc8f3a3 100644
--- a/seednode_monitor/src/main/java/io/bisq/seednode_monitor/MetricsByNodeAddressMap.java
+++ b/seednode_monitor/src/main/java/io/bisq/seednode_monitor/metrics/MetricsModel.java
@@ -15,11 +15,12 @@
* along with bisq. If not, see .
*/
-package io.bisq.seednode_monitor;
+package io.bisq.seednode_monitor.metrics;
import io.bisq.common.util.MathUtils;
import io.bisq.network.p2p.NodeAddress;
import io.bisq.network.p2p.seed.SeedNodesRepository;
+import io.bisq.seednode_monitor.MonitorOptionKeys;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@@ -32,7 +33,7 @@ import java.util.*;
import java.util.stream.Collectors;
@Slf4j
-public class MetricsByNodeAddressMap extends HashMap {
+public class MetricsModel {
private SlackApi slackApi;
@Getter
private String resultAsString;
@@ -42,26 +43,34 @@ public class MetricsByNodeAddressMap extends HashMap {
@Setter
private long lastCheckTs;
private int totalErrors = 0;
+ private HashMap map = new HashMap<>();
@Inject
- public MetricsByNodeAddressMap(SeedNodesRepository seedNodesRepository,
- @Named(MonitorOptionKeys.SLACK_URL_SEED_CHANNEL) String slackUrlSeedChannel) {
+ public MetricsModel(SeedNodesRepository seedNodesRepository,
+ @Named(MonitorOptionKeys.SLACK_URL_SEED_CHANNEL) String slackUrlSeedChannel) {
this.seedNodesRepository = seedNodesRepository;
if (!slackUrlSeedChannel.isEmpty())
slackApi = new SlackApi(slackUrlSeedChannel);
}
+ public void addToMap(NodeAddress nodeAddress, Metrics metrics) {
+ map.put(nodeAddress, metrics);
+ }
+
+ public Metrics getMetrics(NodeAddress nodeAddress) {
+ return map.get(nodeAddress);
+ }
public void updateReport() {
Map accumulatedValues = new HashMap<>();
final double[] items = {0};
- List> entryList = entrySet().stream()
+ List> entryList = map.entrySet().stream()
.sorted(Comparator.comparing(entrySet -> seedNodesRepository.getOperator(entrySet.getKey())))
.collect(Collectors.toList());
totalErrors = 0;
entryList.stream().forEach(e -> {
- totalErrors += e.getValue().errorMessages.size();
+ totalErrors += e.getValue().errorMessages.stream().filter(s -> !s.isEmpty()).count();
final List