This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding final set of changes for Cache RCAs
- Loading branch information
Showing
5 changed files
with
153 additions
and
78 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...om/amazon/opendistro/elasticsearch/performanceanalyzer/rca/store/rca/cache/CacheUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.store.rca.cache; | ||
|
||
import com.amazon.opendistro.elasticsearch.performanceanalyzer.metricsdb.MetricsDB; | ||
import com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.api.Metric; | ||
import com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.api.flow_units.MetricFlowUnit; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.jooq.Record; | ||
|
||
public class CacheUtil { | ||
private static final Logger LOG = LogManager.getLogger(CacheUtil.class); | ||
private static final double CONVERT_BYTES_TO_MEGABYTES = Math.pow(1024, 3); | ||
|
||
public static Double getTotalSizeInMB(final Metric sizeMetric) { | ||
double sizeTotalInMB = 0; | ||
|
||
// we expect the Metric to have single flow unit | ||
// TODO: Depending on Ruizhen's comment | ||
MetricFlowUnit flowUnit = sizeMetric.getFlowUnits().get(0); | ||
if (flowUnit.isEmpty() || flowUnit.getData() == null) { | ||
return sizeTotalInMB; | ||
} | ||
|
||
for (Record record : flowUnit.getData()) { | ||
double size = record.getValue(MetricsDB.MAX, Double.class); | ||
if (Double.isNaN(size)) { | ||
LOG.error("Failed to parse metric in FlowUnit from {}", sizeMetric.getClass().getName()); | ||
} else { | ||
sizeTotalInMB += size / CONVERT_BYTES_TO_MEGABYTES; | ||
} | ||
} | ||
return sizeTotalInMB; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.