mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Add hasError util method
Reformattings, cleanups
This commit is contained in:
parent
1eca9dff4b
commit
5e4156910a
3 changed files with 24 additions and 18 deletions
|
@ -56,6 +56,10 @@ public class RequestInfo {
|
||||||
null;
|
null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasError() {
|
||||||
|
return errorMessage != null && !errorMessage.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Value
|
@Value
|
||||||
public static class Data {
|
public static class Data {
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
|
@ -154,12 +154,11 @@ public class InventoryMonitor implements SetupListener {
|
||||||
RequestInfo requestInfo,
|
RequestInfo requestInfo,
|
||||||
@Nullable Map<InventoryItem, String> result,
|
@Nullable Map<InventoryItem, String> result,
|
||||||
@Nullable String errorMessage) {
|
@Nullable String errorMessage) {
|
||||||
long responseTime = System.currentTimeMillis();
|
|
||||||
if (errorMessage != null && !errorMessage.isEmpty()) {
|
if (errorMessage != null && !errorMessage.isEmpty()) {
|
||||||
log.warn("Error at connection to peer {}: {}", nodeAddress, errorMessage);
|
log.warn("Error at connection to peer {}: {}", nodeAddress, errorMessage);
|
||||||
requestInfo.setErrorMessage(errorMessage);
|
requestInfo.setErrorMessage(errorMessage);
|
||||||
} else {
|
} else {
|
||||||
requestInfo.setResponseTime(responseTime);
|
requestInfo.setResponseTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean ignoreDeviationAtStartup;
|
boolean ignoreDeviationAtStartup;
|
||||||
|
|
|
@ -191,7 +191,8 @@ public class InventoryWebServer {
|
||||||
"n/a";
|
"n/a";
|
||||||
sb.append("Run duration: ").append(duration).append("<br/>");
|
sb.append("Run duration: ").append(duration).append("<br/>");
|
||||||
|
|
||||||
String filteredSeedNodes = requestInfo.getDisplayValue(InventoryItem.filteredSeeds).replace(System.getProperty("line.separator"), "<br/>");
|
String filteredSeedNodes = requestInfo.getDisplayValue(InventoryItem.filteredSeeds)
|
||||||
|
.replace(System.getProperty("line.separator"), "<br/>");
|
||||||
if (filteredSeedNodes.isEmpty()) {
|
if (filteredSeedNodes.isEmpty()) {
|
||||||
filteredSeedNodes = "-";
|
filteredSeedNodes = "-";
|
||||||
}
|
}
|
||||||
|
@ -386,16 +387,20 @@ public class InventoryWebServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!warningsAtRequestNumber.isEmpty()) {
|
if (!warningsAtRequestNumber.isEmpty()) {
|
||||||
historicalWarnings = warningsAtRequestNumber.size() + " repeated warning(s) at request(s) " + Joiner.on(", ").join(warningsAtRequestNumber);
|
historicalWarnings = warningsAtRequestNumber.size() + " repeated warning(s) at request(s) " +
|
||||||
|
Joiner.on(", ").join(warningsAtRequestNumber);
|
||||||
}
|
}
|
||||||
if (!alertsAtRequestNumber.isEmpty()) {
|
if (!alertsAtRequestNumber.isEmpty()) {
|
||||||
historicalAlerts = alertsAtRequestNumber.size() + " repeated alert(s) at request(s): " + Joiner.on(", ").join(alertsAtRequestNumber);
|
historicalAlerts = alertsAtRequestNumber.size() + " repeated alert(s) at request(s): " +
|
||||||
|
Joiner.on(", ").join(alertsAtRequestNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String historicalWarningsHtml = warningsAtRequestNumber.isEmpty() ? "" :
|
String historicalWarningsHtml = warningsAtRequestNumber.isEmpty() ? "" :
|
||||||
", <b><a id=\"warn\" href=\"#\" title=\"" + historicalWarnings + "\">" + WARNING_ICON + warningsAtRequestNumber.size() + "</a></b>";
|
", <b><a id=\"warn\" href=\"#\" title=\"" + historicalWarnings + "\">" + WARNING_ICON +
|
||||||
|
warningsAtRequestNumber.size() + "</a></b>";
|
||||||
String historicalAlertsHtml = alertsAtRequestNumber.isEmpty() ? "" :
|
String historicalAlertsHtml = alertsAtRequestNumber.isEmpty() ? "" :
|
||||||
", <b><a id=\"alert\" href=\"#\" title=\"" + historicalAlerts + "\">" + ALERT_ICON + alertsAtRequestNumber.size() + "</a></b>";
|
", <b><a id=\"alert\" href=\"#\" title=\"" + historicalAlerts + "\">" + ALERT_ICON +
|
||||||
|
alertsAtRequestNumber.size() + "</a></b>";
|
||||||
|
|
||||||
return title +
|
return title +
|
||||||
getColorTagByDeviationSeverity(deviationSeverity) +
|
getColorTagByDeviationSeverity(deviationSeverity) +
|
||||||
|
@ -473,9 +478,7 @@ public class InventoryWebServer {
|
||||||
private String getErrorMsgLine(NodeAddress seedNode,
|
private String getErrorMsgLine(NodeAddress seedNode,
|
||||||
RequestInfo requestInfo,
|
RequestInfo requestInfo,
|
||||||
Map<NodeAddress, List<RequestInfo>> map) {
|
Map<NodeAddress, List<RequestInfo>> map) {
|
||||||
boolean isError = requestInfo.getErrorMessage() != null &&
|
String errorMessage = requestInfo.hasError() ? requestInfo.getErrorMessage() : "-";
|
||||||
!requestInfo.getErrorMessage().isEmpty();
|
|
||||||
String errorMessage = isError ? requestInfo.getErrorMessage() : "-";
|
|
||||||
List<RequestInfo> requestInfoList = map.get(seedNode);
|
List<RequestInfo> requestInfoList = map.get(seedNode);
|
||||||
List<String> errorsAtRequestNumber = new ArrayList<>();
|
List<String> errorsAtRequestNumber = new ArrayList<>();
|
||||||
String historicalErrorsHtml = "";
|
String historicalErrorsHtml = "";
|
||||||
|
@ -484,14 +487,12 @@ public class InventoryWebServer {
|
||||||
RequestInfo requestInfo1 = requestInfoList.get(i);
|
RequestInfo requestInfo1 = requestInfoList.get(i);
|
||||||
|
|
||||||
// We ignore old errors as at startup timeouts are expected and each node restarts once a day
|
// We ignore old errors as at startup timeouts are expected and each node restarts once a day
|
||||||
if (requestInfo1.getRequestStartTime() > 0 &&
|
long duration = System.currentTimeMillis() - requestInfo1.getRequestStartTime();
|
||||||
System.currentTimeMillis() - requestInfo1.getRequestStartTime() > TimeUnit.HOURS.toMillis(24)) {
|
if (requestInfo1.getRequestStartTime() > 0 && duration > TimeUnit.HOURS.toMillis(24)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isError1 = requestInfo1.getErrorMessage() != null &&
|
if (requestInfo1.hasError()) {
|
||||||
!requestInfo1.getErrorMessage().isEmpty();
|
|
||||||
if (isError1) {
|
|
||||||
errorsAtRequestNumber.add((i + 1) + " (" + requestInfo1.getErrorMessage() + ")");
|
errorsAtRequestNumber.add((i + 1) + " (" + requestInfo1.getErrorMessage() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -509,12 +510,14 @@ public class InventoryWebServer {
|
||||||
type = "warning";
|
type = "warning";
|
||||||
style = "warn";
|
style = "warn";
|
||||||
}
|
}
|
||||||
String historicalAlerts = errorsAtRequestNumber.size() + " repeated " + type + "(s) at request(s): " + Joiner.on(", ").join(errorsAtRequestNumber);
|
String historicalAlerts = errorsAtRequestNumber.size() + " repeated " + type + "(s) at request(s): " +
|
||||||
|
Joiner.on(", ").join(errorsAtRequestNumber);
|
||||||
historicalErrorsHtml = errorsAtRequestNumber.isEmpty() ? "" :
|
historicalErrorsHtml = errorsAtRequestNumber.isEmpty() ? "" :
|
||||||
", <b><a id=\"" + style + "\" href=\"#\" title=\"" + historicalAlerts + "\">" + errorIcon + errorsAtRequestNumber.size() + "</a></b>";
|
", <b><a id=\"" + style + "\" href=\"#\" title=\"" + historicalAlerts + "\">" + errorIcon +
|
||||||
|
errorsAtRequestNumber.size() + "</a></b>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeviationSeverity deviationSeverity = isError ?
|
DeviationSeverity deviationSeverity = requestInfo.hasError() ?
|
||||||
errorsAtRequestNumber.size() > 4 ? DeviationSeverity.ALERT : DeviationSeverity.WARN
|
errorsAtRequestNumber.size() > 4 ? DeviationSeverity.ALERT : DeviationSeverity.WARN
|
||||||
: DeviationSeverity.OK;
|
: DeviationSeverity.OK;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue