Skip to content

Commit

Permalink
Merge pull request #6284 from jmacxx/InventoryMonitor
Browse files Browse the repository at this point in the history
Inventory monitor: show last successful response time
  • Loading branch information
ripcurlx authored Jul 12, 2022
2 parents 4b24d20 + cb2b7f2 commit d50dbfd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions inventory/src/main/java/bisq/inventory/InventoryWebServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ private String getRequestInfo(NodeAddress seedNode,
sb.append("Response received at: ").append(responseTime).append("<br/>");

sb.append(getErrorMsgLine(seedNode, requestInfo, map));

sb.append(getLastSuccessfulResponseLine(seedNode, map));
return sb.toString();
}

Expand Down Expand Up @@ -531,4 +533,20 @@ private String getErrorMsgLine(NodeAddress seedNode,
historicalErrorsHtml +
CLOSE_TAG;
}

private String getLastSuccessfulResponseLine(NodeAddress seedNode,
Map<NodeAddress, List<RequestInfo>> map) {
long newestResponseTime = 0;
List<RequestInfo> requestInfoList = map.get(seedNode);
if (requestInfoList != null) {
for (int i = 0; i < requestInfoList.size(); i++) {
RequestInfo requestInfo1 = requestInfoList.get(i);
newestResponseTime = Math.max(newestResponseTime, requestInfo1.getResponseTime());
}
}
String responseMessage = newestResponseTime > 0 ? new Date(newestResponseTime).toString() : "none";
return "Last response received: " +
responseMessage +
CLOSE_TAG;
}
}

0 comments on commit d50dbfd

Please sign in to comment.