Skip to content

Commit

Permalink
Merge pull request #270 from slacmshankar/metricspage
Browse files Browse the repository at this point in the history
Use the cached version of capacity planning data in the appliance metrics details page
  • Loading branch information
slacmshankar authored Sep 27, 2024
2 parents 41874ba + e3d7522 commit 5e8e765
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ public static CPStaticData getMetricsForAppliances(ConfigService configService)
cachedCPStaticData = newStaticData;
return cachedCPStaticData;
}


public static CPStaticData getCachedMetricsForAppliances(ConfigService configService) throws IOException {
return cachedCPStaticData;
}

public static class CPStaticData {
public ConcurrentHashMap<ApplianceInfo, CapacityPlanningData> cpApplianceMetrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.epics.archiverappliance.config.ConfigService;
import org.epics.archiverappliance.config.PVTypeInfo;
import org.epics.archiverappliance.mgmt.archivepv.CapacityPlanningData;
import org.epics.archiverappliance.mgmt.archivepv.CapacityPlanningData.CPStaticData;
import org.epics.archiverappliance.utils.ui.GetUrlContent;
import org.epics.archiverappliance.utils.ui.MimeTypeConstants;
import org.json.simple.JSONArray;
Expand Down Expand Up @@ -89,18 +90,25 @@ public void execute(HttpServletRequest req, HttpServletResponse resp, ConfigServ
"PVs in archive workflow",
Integer.toString(configService.getMgmtRuntimeState().getPVsPendingInWorkflow()));

CapacityPlanningData capacityPlanningMetrics = CapacityPlanningData.getMetricsForAppliances(configService)
.cpApplianceMetrics
.get(configService.getMyApplianceInfo());
ApplianceAggregateInfo applianceAggregateDifferenceFromLastFetch =
capacityPlanningMetrics.getApplianceAggregateDifferenceFromLastFetch(configService);
addDetailedStatus(
result, "Capacity planning last update", capacityPlanningMetrics.getStaticDataLastUpdated());
addDetailedStatus(
result,
"Engine write thread usage",
twoSignificantDigits.format(
capacityPlanningMetrics.getEngineWriteThreadUsage(PVTypeInfo.DEFAULT_BUFFER_INTERVAL)));
CPStaticData cpStaticData = CapacityPlanningData.getCachedMetricsForAppliances(configService);
ApplianceAggregateInfo applianceAggregateDifferenceFromLastFetch = null;
if(cpStaticData != null) {
CapacityPlanningData capacityPlanningMetrics = cpStaticData
.cpApplianceMetrics
.get(configService.getMyApplianceInfo());

applianceAggregateDifferenceFromLastFetch =
capacityPlanningMetrics.getApplianceAggregateDifferenceFromLastFetch(configService);

addDetailedStatus(
result, "Capacity planning last update", capacityPlanningMetrics.getStaticDataLastUpdated());
addDetailedStatus(
result,
"Engine write thread usage",
twoSignificantDigits.format(
capacityPlanningMetrics.getEngineWriteThreadUsage(PVTypeInfo.DEFAULT_BUFFER_INTERVAL)));
}

addDetailedStatus(
result,
"Aggregated appliance storage rate (in GB/year)",
Expand All @@ -117,21 +125,23 @@ public void execute(HttpServletRequest req, HttpServletResponse resp, ConfigServ
"Aggregated appliance PV count",
noSignificantDigits.format(
configService.getAggregatedApplianceInfo(info).getTotalPVCount()));
addDetailedStatus(
result,
"Incremental appliance storage rate (in GB/year)",
twoSignificantDigits.format(
(applianceAggregateDifferenceFromLastFetch.getTotalStorageRate() * 60 * 60 * 24 * 365)
/ (1024 * 1024 * 1024)));
addDetailedStatus(
result,
"Incremental appliance event rate (in events/sec)",
twoSignificantDigits.format(applianceAggregateDifferenceFromLastFetch.getTotalEventRate()));
addDetailedStatus(
result,
"Incremental appliance PV count",
noSignificantDigits.format(applianceAggregateDifferenceFromLastFetch.getTotalPVCount()));

if(applianceAggregateDifferenceFromLastFetch != null) {
addDetailedStatus(
result,
"Incremental appliance storage rate (in GB/year)",
twoSignificantDigits.format(
(applianceAggregateDifferenceFromLastFetch.getTotalStorageRate() * 60 * 60 * 24 * 365)
/ (1024 * 1024 * 1024)));

addDetailedStatus(
result,
"Incremental appliance event rate (in events/sec)",
twoSignificantDigits.format(applianceAggregateDifferenceFromLastFetch.getTotalEventRate()));
addDetailedStatus(
result,
"Incremental appliance PV count",
noSignificantDigits.format(applianceAggregateDifferenceFromLastFetch.getTotalPVCount()));
}
out.println(JSONValue.toJSONString(result));
}
}
Expand Down

0 comments on commit 5e8e765

Please sign in to comment.