dlmarion commented on code in PR #6165:
URL: https://github.com/apache/accumulo/pull/6165#discussion_r2878139875


##########
server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/navbar.js:
##########
@@ -138,27 +138,18 @@ function updateServerNotifications(statusData) {
  * Updates the scan server notification based on REST v2 metrics status.
  */
 function refreshSserverStatus() {
-  return $.when(
-    $.getJSON(REST_V2_PREFIX + '/sservers/summary'),

Review Comment:
   If this endpoint is not referenced anywhere else, then it can be removed. 
Or, you could reuse it and keep the name with the new logic and return type.



##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java:
##########
@@ -268,11 +270,29 @@ public Map<Id,CumulativeDistributionSummary> 
getCompactorAllMetricSummary() {
   @GET
   @Path("sservers/summary")
   @Produces(MediaType.APPLICATION_JSON)
-  @Description("Returns an aggregate view of the metric responses for all 
ScanServers")
+  @Description("Returns an aggregate raw metric summary for all ScanServers")
   public Map<Id,CumulativeDistributionSummary> getScanServerAllMetricSummary() 
{
     return 
monitor.getInformationFetcher().getSummaryForEndpoint().getSServerAllMetricSummary();
   }
 
+  @GET
+  @Path("sservers/view")

Review Comment:
   No issue here with returning a more optimized data structure for the UI. My 
question is - does this method replace one of the other methods for ScanServers 
above? If so, can it be removed?



##########
server/monitor/src/main/java/org/apache/accumulo/monitor/next/Endpoints.java:
##########
@@ -268,11 +270,29 @@ public Map<Id,CumulativeDistributionSummary> 
getCompactorAllMetricSummary() {
   @GET
   @Path("sservers/summary")
   @Produces(MediaType.APPLICATION_JSON)
-  @Description("Returns an aggregate view of the metric responses for all 
ScanServers")
+  @Description("Returns an aggregate raw metric summary for all ScanServers")
   public Map<Id,CumulativeDistributionSummary> getScanServerAllMetricSummary() 
{
     return 
monitor.getInformationFetcher().getSummaryForEndpoint().getSServerAllMetricSummary();
   }
 
+  @GET
+  @Path("sservers/view")
+  @Produces(MediaType.APPLICATION_JSON)
+  @Description("Returns a UI-ready view model for the Scan Server status page")
+  public ScanServerView getScanServerPageView() {
+    var summary = monitor.getInformationFetcher().getSummaryForEndpoint();
+    Set<ServerId> scanServers =
+        
summary.getResourceGroups().stream().map(summary::getSServerResourceGroupServers)
+            
.filter(Objects::nonNull).flatMap(Set::stream).collect(Collectors.toSet());
+    int problemScanServerCount = (int) summary.getProblemHosts().stream()
+        .filter(serverId -> serverId.getType() == 
ServerId.Type.SCAN_SERVER).count();
+    long nowMs = System.currentTimeMillis();
+    Collection<MetricResponse> responses =
+        
monitor.getInformationFetcher().getAllMetrics().getAllPresent(scanServers).values();
+    return ScanServerView.fromMetrics(responses, scanServers.size(), 
problemScanServerCount, nowMs,
+        summary.getTimestamp());

Review Comment:
   The InformationFetcher object keeps a reference to the most recent 
SystemInformation object, which has the metrics stored in some pre-computed 
state. The InformationFetcher object builds a newer version of the 
SystemInformation in the background and swaps the reference when the process is 
complete.
   
   If you moved the computation into the SystemInformation class, then you 
would have access to the `rgSServerMetrics` object which already stores the 
scan server metrics by resource group, and you would only need to compute the 
view once, in the SystemInformation.finish method. I think the way this is done 
currently, the view will be re-computed from the current metrics every time the 
page refreshes, but the metrics are static until the new SystemInformation 
object is complete.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to