protected void constructResourceHeatMapGraph()

in src/main/java/org/opensearch/performanceanalyzer/rca/store/OpenSearchAnalysisGraph.java [560:701]


    protected void constructResourceHeatMapGraph() {
        LOG.info("Constructing temperature profile RCA components");
        ShardStore shardStore = new ShardStore();

        HeapAllocRateByShardTemperatureCalculator heapAllocByShard =
                new HeapAllocRateByShardTemperatureCalculator();
        HeapAllocRateByShardAvgTemperatureCalculator heapAllocRateByShardAvg =
                new HeapAllocRateByShardAvgTemperatureCalculator();
        HeapAllocRateShardIndependentTemperatureCalculator shardIndependentHeapAllocRate =
                new HeapAllocRateShardIndependentTemperatureCalculator();
        HeapAllocRateTotalTemperatureCalculator heapAllocRateTotal =
                new HeapAllocRateTotalTemperatureCalculator();

        CpuUtilByShardsMetricBasedTemperatureCalculator cpuUtilByShard =
                new CpuUtilByShardsMetricBasedTemperatureCalculator();
        AvgCpuUtilByShardsMetricBasedTemperatureCalculator avgCpuUtilByShards =
                new AvgCpuUtilByShardsMetricBasedTemperatureCalculator();
        ShardIndependentTemperatureCalculatorCpuUtilMetric shardIndependentCpuUtilMetric =
                new ShardIndependentTemperatureCalculatorCpuUtilMetric();
        TotalCpuUtilForTotalNodeMetric cpuUtilPeakUsage = new TotalCpuUtilForTotalNodeMetric();

        ShardSizeMetricBasedTemperatureCalculator shardSizeByShard =
                new ShardSizeMetricBasedTemperatureCalculator();
        ShardSizeAvgTemperatureCalculator shardSizeAvg = new ShardSizeAvgTemperatureCalculator();
        ShardTotalDiskUsageTemperatureCalculator shardTotalDiskUsage =
                new ShardTotalDiskUsageTemperatureCalculator();

        // heat map is developed only for data nodes.
        cpuUtilByShard.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        avgCpuUtilByShards.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        shardIndependentCpuUtilMetric.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        cpuUtilPeakUsage.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);

        heapAllocByShard.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        heapAllocRateByShardAvg.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        shardIndependentHeapAllocRate.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        heapAllocRateTotal.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);

        shardSizeByShard.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        shardSizeAvg.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        shardTotalDiskUsage.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);

        addLeaf(cpuUtilByShard);
        addLeaf(avgCpuUtilByShards);
        addLeaf(shardIndependentCpuUtilMetric);
        addLeaf(cpuUtilPeakUsage);

        addLeaf(heapAllocByShard);
        addLeaf(heapAllocRateByShardAvg);
        addLeaf(shardIndependentHeapAllocRate);
        addLeaf(heapAllocRateTotal);

        addLeaf(shardSizeByShard);
        addLeaf(shardSizeAvg);
        addLeaf(shardTotalDiskUsage);

        CpuUtilDimensionTemperatureRca cpuUtilHeat =
                new CpuUtilDimensionTemperatureRca(
                        EVALUATION_INTERVAL_SECONDS,
                        shardStore,
                        cpuUtilByShard,
                        avgCpuUtilByShards,
                        shardIndependentCpuUtilMetric,
                        cpuUtilPeakUsage);
        cpuUtilHeat.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        cpuUtilHeat.addAllUpstreams(
                Arrays.asList(
                        cpuUtilByShard,
                        avgCpuUtilByShards,
                        shardIndependentCpuUtilMetric,
                        cpuUtilPeakUsage));

        HeapAllocRateTemperatureRca heapAllocRateHeat =
                new HeapAllocRateTemperatureRca(
                        EVALUATION_INTERVAL_SECONDS,
                        shardStore,
                        heapAllocByShard,
                        heapAllocRateByShardAvg,
                        shardIndependentHeapAllocRate,
                        heapAllocRateTotal);

        heapAllocRateHeat.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        heapAllocRateHeat.addAllUpstreams(
                Arrays.asList(
                        heapAllocByShard,
                        heapAllocRateByShardAvg,
                        shardIndependentHeapAllocRate,
                        heapAllocRateTotal));

        ShardSizeDimensionTemperatureRca shardSizeHeat =
                new ShardSizeDimensionTemperatureRca(
                        EVALUATION_INTERVAL_SECONDS,
                        shardStore,
                        shardSizeByShard,
                        shardSizeAvg,
                        shardTotalDiskUsage);
        shardSizeHeat.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        shardSizeHeat.addAllUpstreams(
                Arrays.asList(shardSizeByShard, shardSizeAvg, shardTotalDiskUsage));

        NodeTemperatureRca nodeTemperatureRca =
                new NodeTemperatureRca(cpuUtilHeat, heapAllocRateHeat, shardSizeHeat);
        nodeTemperatureRca.addTag(
                RcaConsts.RcaTagConstants.TAG_LOCUS,
                RcaConsts.RcaTagConstants.LOCUS_DATA_MASTER_NODE);
        nodeTemperatureRca.addAllUpstreams(
                Arrays.asList(cpuUtilHeat, heapAllocRateHeat, shardSizeHeat));

        //    ClusterTemperatureRca clusterTemperatureRca = new
        // ClusterTemperatureRca(nodeTemperatureRca);
        //    clusterTemperatureRca.addTag(TAG_LOCUS, LOCUS_MASTER_NODE);
        //    clusterTemperatureRca.addTag(TAG_AGGREGATE_UPSTREAM, LOCUS_DATA_NODE);
        //    clusterTemperatureRca.addAllUpstreams(Collections.singletonList(nodeTemperatureRca));
    }