in src/main/java/org/opensearch/performanceanalyzer/rca/store/rca/hotheap/HighHeapUsageOldGenRca.java [130:198]
public ResourceFlowUnit<HotResourceSummary> operate() {
counter += 1;
double oldGenHeapUsed = getOldGenUsedOrDefault(Double.NaN);
int oldGenGCEvent = getFullGcEventsOrDefault(0);
double maxTotalHeapSize = getMaxHeapSizeOrDefault(Double.MAX_VALUE);
long currTimeStamp = this.clock.millis();
if (!Double.isNaN(oldGenHeapUsed)) {
LOG.debug(
"oldGenHeapUsed = {}, oldGenGCEvent = {}, maxOldGenHeapSize = {}",
oldGenHeapUsed,
oldGenGCEvent,
maxTotalHeapSize);
gcEventSlidingWindow.next(new SlidingWindowData(currTimeStamp, oldGenGCEvent));
minOldGenSlidingWindow.next(new SlidingWindowData(currTimeStamp, oldGenHeapUsed));
}
// collect node stats from metrics
for (NodeStatAggregator nodeStatAggregator : this.nodeStatAggregators) {
nodeStatAggregator.collect(currTimeStamp);
}
if (counter == this.rcaPeriod) {
ResourceContext context = null;
HotResourceSummary summary = null;
// reset the variables
counter = 0;
double currentMinOldGenUsage = minOldGenSlidingWindow.readMin();
if (gcEventSlidingWindow.readSum() >= OLD_GEN_GC_THRESHOLD
&& !Double.isNaN(currentMinOldGenUsage)
&& currentMinOldGenUsage / maxTotalHeapSize
> OLD_GEN_USED_THRESHOLD_IN_PERCENTAGE) {
LOG.debug(
"heapUsage is above threshold. OldGGenGCEvent = {}, oldGenUsage percentage = {}",
gcEventSlidingWindow.readSum(),
currentMinOldGenUsage / maxTotalHeapSize);
context = new ResourceContext(Resources.State.UNHEALTHY);
PerformanceAnalyzerApp.RCA_VERTICES_METRICS_AGGREGATOR.updateStat(
RcaVerticesMetrics.NUM_OLD_GEN_RCA_TRIGGERED, "", 1);
} else {
context = new ResourceContext(Resources.State.HEALTHY);
}
// check to see if the value is above lower bound thres
if (gcEventSlidingWindow.readSum() >= OLD_GEN_GC_THRESHOLD
&& !Double.isNaN(currentMinOldGenUsage)
&& currentMinOldGenUsage / maxTotalHeapSize
> OLD_GEN_USED_THRESHOLD_IN_PERCENTAGE * this.lowerBoundThreshold) {
summary =
new HotResourceSummary(
ResourceUtil.OLD_GEN_HEAP_USAGE,
OLD_GEN_USED_THRESHOLD_IN_PERCENTAGE,
currentMinOldGenUsage / maxTotalHeapSize,
SLIDING_WINDOW_SIZE_IN_MINS * 60);
addTopConsumers(summary);
}
LOG.debug("High Heap Usage RCA Context = " + context.toString());
return new ResourceFlowUnit<>(this.clock.millis(), context, summary);
} else {
// we return an empty FlowUnit RCA for now. Can change to healthy (or previous known RCA
// state)
LOG.debug("Empty FlowUnit returned for High Heap Usage RCA");
return new ResourceFlowUnit<>(this.clock.millis());
}
}