Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various monitor improvements #4787

Merged
merged 27 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5c7aa80
Add deviation to persistent warnings/alerts
chimp1984 Nov 4, 2020
850f73a
Fix formatting
chimp1984 Nov 4, 2020
4d17e98
Update COMMIT_HASH to 04440f95 (after merged master)
chimp1984 Nov 4, 2020
ac955e1
Reduce TTL for ack and mailbox messages
chimp1984 Nov 4, 2020
b09ebde
Update COMMIT_HASH to fd2a04a2
chimp1984 Nov 4, 2020
012c54c
Fix log at startup
chimp1984 Nov 4, 2020
f10d231
Log when we remove expired entries
chimp1984 Nov 4, 2020
4becece
Increase MAX_PERMITTED_MESSAGE_SIZE to 15 MB, increase SOCKET_TIMEOUT…
chimp1984 Nov 4, 2020
b002c93
Increase SOCKET_TIMEOUT to 6 min
chimp1984 Nov 4, 2020
a1c8474
Add comments, revert TTL change at AckMessage as it has no effect anyway
chimp1984 Nov 4, 2020
33e378a
Update COMMIT_HASH to fec8f6e3
chimp1984 Nov 4, 2020
16880b2
Change deviation limits for OfferPayload
chimp1984 Nov 8, 2020
86a853b
Set response time only in non error case
chimp1984 Nov 8, 2020
a056542
Add historical data for error msg
chimp1984 Nov 8, 2020
1eca9df
Use dash for empty filteredSeedNodes value
chimp1984 Nov 8, 2020
5e41569
Add hasError util method
chimp1984 Nov 8, 2020
04ab507
Update COMMIT_HASH to 627888f0
chimp1984 Nov 8, 2020
86a2045
Fix wrong kb display
chimp1984 Nov 9, 2020
69802e2
Reduce timeout
chimp1984 Nov 9, 2020
bb095d4
Increase timout to 90 sec
chimp1984 Nov 10, 2020
6a2583d
Decrease deviationTolerance for numAllConnectionsLostEvents
chimp1984 Nov 10, 2020
1b7c1ce
Only reset numAllConnectionsLostEvents if we have nodes connected
chimp1984 Nov 10, 2020
2486bd5
Shut down if more then 1 all connections lost events
chimp1984 Nov 10, 2020
8bc78c8
Cleanup tor dir if all connections lost
chimp1984 Nov 10, 2020
2b80776
Update commit hash to 7f83d1b3
chimp1984 Nov 10, 2020
ee5fca9
Revert timeout changes and MAX_PERMITTED_MESSAGE_SIZE change
chimp1984 Nov 12, 2020
ccfcc35
Clean tor dir at startup
chimp1984 Nov 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/src/main/java/bisq/common/setup/CommonSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
public class CommonSetup {

public static void setup(Config config, GracefulShutDownHandler gracefulShutDownHandler) {
AsciiLogo.showAsciiLogo();
setupLog(config);
AsciiLogo.showAsciiLogo();
Version.setBaseCryptoNetworkId(config.baseCurrencyNetwork.ordinal());
Version.printVersion();
maybePrintPathOfCodeSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void onMessage(NetworkEnvelope networkEnvelope, Connection connection) {
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()));
peerManager.resetNumAllConnectionsLostEvents();
peerManager.maybeResetNumAllConnectionsLostEvents();
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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void request() {
}

private void onTimeOut() {
errorMessageHandler.handleErrorMessage("Timeout got triggered (" + TIMEOUT_SEC + " sec)");
errorMessageHandler.handleErrorMessage("Request timeout");
shutDown();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public enum InventoryItem {
// Percentage deviation
OfferPayload("OfferPayload",
true,
new DeviationByPercentage(0.9, 1.1, 0.95, 1.05), 5),
new DeviationByPercentage(0.8, 1.2, 0.9, 1.1), 5),
MailboxStoragePayload("MailboxStoragePayload",
true,
new DeviationByPercentage(0.9, 1.1, 0.95, 1.05), 2),
Expand Down Expand Up @@ -102,7 +102,7 @@ public enum InventoryItem {
new DeviationByPercentage(0, 3, 0, 2.5), 2),
numAllConnectionsLostEvents("numAllConnectionsLostEvents",
true,
new DeviationByIntegerDiff(1, 2), 3),
new DeviationByIntegerDiff(1, 2), 1),
sentBytesPerSec("sentBytesPerSec",
true,
new DeviationByPercentage(), 5),
Expand Down Expand Up @@ -137,6 +137,7 @@ public enum InventoryItem {

// The number of past requests we check to see if there have been repeated alerts or warnings. The higher the
// number the more repeated alert need to have happened to cause a notification alert.
// Smallest number is 1, as that takes only the last request data and does not look further back.
@Getter
private int deviationTolerance = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Getter
public class RequestInfo {
// Carries latest commit hash of feature changes (not latest commit as that is then the commit for editing that field)
public static final String COMMIT_HASH = "d789282b";
public static final String COMMIT_HASH = "7f83d1b3";

private final long requestStartTime;
@Setter
Expand All @@ -56,6 +56,10 @@ public String getValue(InventoryItem inventoryItem) {
null;
}

public boolean hasError() {
return errorMessage != null && !errorMessage.isEmpty();
}

@Value
public static class Data {
private final String value;
Expand Down
47 changes: 26 additions & 21 deletions inventory/src/main/java/bisq/inventory/InventoryMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package bisq.inventory;


import bisq.core.app.TorSetup;
import bisq.core.network.p2p.inventory.GetInventoryRequestManager;
import bisq.core.network.p2p.inventory.model.Average;
import bisq.core.network.p2p.inventory.model.DeviationSeverity;
Expand Down Expand Up @@ -61,8 +62,8 @@ public class InventoryMonitor implements SetupListener {
private final File appDir;
private final boolean useLocalhostForP2P;
private final int intervalSec;
private final NetworkNode networkNode;
private final GetInventoryRequestManager getInventoryRequestManager;
private NetworkNode networkNode;
private GetInventoryRequestManager getInventoryRequestManager;

private ArrayList<NodeAddress> seedNodes;
private InventoryWebServer inventoryWebServer;
Expand All @@ -82,20 +83,25 @@ public InventoryMonitor(File appDir,
this.useLocalhostForP2P = useLocalhostForP2P;
this.intervalSec = intervalSec;

networkNode = getNetworkNode(appDir);
getInventoryRequestManager = new GetInventoryRequestManager(networkNode);

// We maintain our own list as we want to monitor also old v2 nodes which are not part of the normal seed
// node list anymore.
String networkName = network.name().toLowerCase();
String fileName = network.isMainnet() ? "inv_" + networkName : networkName;
DefaultSeedNodeRepository.readSeedNodePropertyFile(fileName)
.ifPresent(bufferedReader -> {
seedNodes = new ArrayList<>(DefaultSeedNodeRepository.getSeedNodeAddressesFromPropertyFile(fileName));
addJsonFileManagers(seedNodes);
inventoryWebServer = new InventoryWebServer(port, seedNodes, bufferedReader);
networkNode.start(this);
});
// We get more connectivity issues. Cleaning tor cache files helps usually for those problems.
File torDir = new File(appDir, "tor");
TorSetup torSetup = new TorSetup(torDir);
torSetup.cleanupTorFiles(() -> {
networkNode = getNetworkNode(torDir);
getInventoryRequestManager = new GetInventoryRequestManager(networkNode);

// We maintain our own list as we want to monitor also old v2 nodes which are not part of the normal seed
// node list anymore.
String networkName = network.name().toLowerCase();
String fileName = network.isMainnet() ? "inv_" + networkName : networkName;
DefaultSeedNodeRepository.readSeedNodePropertyFile(fileName)
.ifPresent(bufferedReader -> {
seedNodes = new ArrayList<>(DefaultSeedNodeRepository.getSeedNodeAddressesFromPropertyFile(fileName));
addJsonFileManagers(seedNodes);
inventoryWebServer = new InventoryWebServer(port, seedNodes, bufferedReader);
networkNode.start(this);
});
}, log::error);
}


Expand Down Expand Up @@ -154,16 +160,16 @@ private void processResponse(NodeAddress nodeAddress,
RequestInfo requestInfo,
@Nullable Map<InventoryItem, String> result,
@Nullable String errorMessage) {
if (errorMessage != null) {
if (errorMessage != null && !errorMessage.isEmpty()) {
log.warn("Error at connection to peer {}: {}", nodeAddress, errorMessage);
requestInfo.setErrorMessage(errorMessage);
} else {
requestInfo.setResponseTime(System.currentTimeMillis());
}

boolean ignoreDeviationAtStartup;
if (result != null) {
log.info("nodeAddress={}, result={}", nodeAddress, result.toString());
long responseTime = System.currentTimeMillis();
requestInfo.setResponseTime(responseTime);

// If seed just started up we ignore the deviation as it can be expected that seed is still syncing
// DAO state/blocks. P2P data should be ready but as we received it from other seeds it is not that
Expand Down Expand Up @@ -247,8 +253,7 @@ private void addJsonFileManagers(List<NodeAddress> seedNodes) {
});
}

private NetworkNode getNetworkNode(File appDir) {
File torDir = new File(appDir, "tor");
private NetworkNode getNetworkNode(File torDir) {
CoreNetworkProtoResolver networkProtoResolver = new CoreNetworkProtoResolver(Clock.systemDefaultZone());
return new NetworkNodeProvider(networkProtoResolver,
ArrayList::new,
Expand Down
Loading