Show last successful response time.

This commit is contained in:
jmacxx 2022-07-08 09:04:43 -05:00
parent 49b5430e49
commit cb2b7f29f9
No known key found for this signature in database
GPG Key ID: 155297BABFE94A1B

View File

@ -242,6 +242,8 @@ public class InventoryWebServer {
sb.append("Response received at: ").append(responseTime).append("<br/>"); sb.append("Response received at: ").append(responseTime).append("<br/>");
sb.append(getErrorMsgLine(seedNode, requestInfo, map)); sb.append(getErrorMsgLine(seedNode, requestInfo, map));
sb.append(getLastSuccessfulResponseLine(seedNode, map));
return sb.toString(); return sb.toString();
} }
@ -531,4 +533,20 @@ public class InventoryWebServer {
historicalErrorsHtml + historicalErrorsHtml +
CLOSE_TAG; 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;
}
} }