Skip to content

Commit

Permalink
Use the cached version of capacity planning data in the appliance met…
Browse files Browse the repository at this point in the history
…rics details page

This addresses #269
  • Loading branch information
slacmshankar committed Sep 26, 2024
1 parent 41874ba commit e3d7522
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 e3d7522

Please sign in to comment.