Add numAllConnectionsLostEvents

This commit is contained in:
chimp1984 2020-10-21 13:14:12 -05:00
parent 8c156eb5bf
commit 5bdc5abe34
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
4 changed files with 17 additions and 1 deletions

View File

@ -157,6 +157,7 @@ public class GetInventoryRequestHandler implements MessageListener {
inventory.put(InventoryItem.maxConnections, String.valueOf(maxConnections));
inventory.put(InventoryItem.numConnections, String.valueOf(networkNode.getAllConnections().size()));
inventory.put(InventoryItem.peakNumConnections, String.valueOf(peerManager.getPeakNumConnections()));
inventory.put(InventoryItem.numAllConnectionsLostEvents, String.valueOf(peerManager.getNumAllConnectionsLostEvents()));
inventory.put(InventoryItem.sentBytes, String.valueOf(Statistic.totalSentBytesProperty().get()));
inventory.put(InventoryItem.sentBytesPerSec, String.valueOf(Statistic.totalSentBytesPerSecProperty().get()));
inventory.put(InventoryItem.receivedBytes, String.valueOf(Statistic.totalReceivedBytesProperty().get()));

View File

@ -43,6 +43,7 @@ public enum InventoryItem {
maxConnections("maxConnections", Integer.class, 0.33, 3, 0.4, 2.5),
numConnections("numConnections", Integer.class, 0.33, 3, 0.4, 2.5),
peakNumConnections("peakNumConnections", Integer.class, 0.33, 3, 0.4, 2.5),
numAllConnectionsLostEvents("numAllConnectionsLostEvents", Integer.class, 0.9, 1.1, 0.95, 1.05),
sentBytes("sentBytes", Long.class, 0, 5, 0, 4),
sentBytesPerSec("sentBytesPerSec", Double.class, 0, 3, 0, 2),
receivedBytes("receivedBytes", Long.class, 0, 5, 0, 4),

View File

@ -288,7 +288,7 @@ public class InventoryWebServer {
addInventoryItem("Max. connections: ", requestInfo, averageValues, sb, InventoryItem.maxConnections);
addInventoryItem("Number of connections: ", requestInfo, averageValues, sb, InventoryItem.numConnections);
addInventoryItem("Peak number of connections: ", requestInfo, averageValues, sb, InventoryItem.peakNumConnections);
addInventoryItem("Number of 'All connections lost' events: ", requestInfo, averageValues, sb, InventoryItem.numAllConnectionsLostEvents);
addInventoryItem("Sent messages/sec: ", requestInfo, averageValues, sb, InventoryItem.sentMessagesPerSec,
value -> String.valueOf(MathUtils.roundDouble(Double.parseDouble(value), 2)));
addInventoryItem("Received messages/sec: ", requestInfo, averageValues, sb, InventoryItem.receivedMessagesPerSec,

View File

@ -130,6 +130,8 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
private int peakNumConnections;
@Setter
private boolean allowDisconnectSeedNodes;
@Getter
private int numAllConnectionsLostEvents;
///////////////////////////////////////////////////////////////////////////////////////////
@ -208,6 +210,9 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
if (lostAllConnections) {
lostAllConnections = false;
stopped = false;
log.info("\n------------------------------------------------------------\n" +
"Established a new connection from/to {} after all connections lost.\n" +
"------------------------------------------------------------", connection.getPeersNodeAddressOptional());
listeners.forEach(Listener::onNewConnectionAfterAllConnectionsLost);
}
connection.getPeersNodeAddressOptional()
@ -220,13 +225,22 @@ public final class PeerManager implements ConnectionListener, PersistedDataHost
log.info("onDisconnect called: nodeAddress={}, closeConnectionReason={}",
connection.getPeersNodeAddressOptional(), closeConnectionReason);
handleConnectionFault(connection);
boolean previousLostAllConnections = lostAllConnections;
lostAllConnections = networkNode.getAllConnections().isEmpty();
// If we enter to 'All connections lost' we count the event.
if (!previousLostAllConnections && lostAllConnections) {
numAllConnectionsLostEvents++;
}
if (lostAllConnections) {
stopped = true;
log.warn("\n------------------------------------------------------------\n" +
"All connections lost\n" +
"------------------------------------------------------------");
listeners.forEach(Listener::onAllConnectionsLost);
}
maybeRemoveBannedPeer(closeConnectionReason, connection);
}