Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes related to PA-RTF merge #74

Merged
merged 9 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@
import org.apache.logging.log4j.Logger;
import org.opensearch.performanceanalyzer.commons.stats.ServiceMetrics;
import org.opensearch.performanceanalyzer.commons.stats.metrics.StatMetrics;
import org.opensearch.performanceanalyzer.commons.util.Util;

/*
* This class is responsible for scheduling the metrics collection.
* It creates a thread pool of size collectorThreadCount and runs the metrics collection
* in the thread pool.
*/
public class ScheduledMetricCollectorsExecutor extends Thread {
atharvasharma61 marked this conversation as resolved.
Show resolved Hide resolved
private static final Logger LOG = LogManager.getLogger(ScheduledMetricCollectorsExecutor.class);
private final int collectorThreadCount;
private static final int DEFAULT_COLLECTOR_THREAD_COUNT = 5;
private static final int COLLECTOR_THREAD_KEEPALIVE_SECS = 1000;
private final boolean checkFeatureDisabledFlag;
private boolean paEnabled = false;
private int collectorsSetting = Util.CollectorMode.RCA.getValue();
private boolean threadContentionMonitoringEnabled = false;
private int minTimeIntervalToSleep = Integer.MAX_VALUE;
private Map<PerformanceAnalyzerMetricsCollector, Long> metricsCollectors;
Expand All @@ -48,6 +55,14 @@ public synchronized void setEnabled(final boolean enabled) {
paEnabled = enabled;
}

public synchronized void setCollectorsSetting(final int value) {
collectorsSetting = value;
}

public synchronized int getCollectorsSetting() {
return collectorsSetting;
}

public synchronized boolean getEnabled() {
return paEnabled;
}
Expand Down Expand Up @@ -117,6 +132,13 @@ public void run() {
StatMetrics.COLLECTORS_MUTED, collector.getCollectorName(), 1);
continue;
}
if (!canSchedule(collector)) {
LOG.debug(
"Skipping {} Collector execution since PA is running in CollectorMode: {}",
collector.getCollectorName(),
collectorsSetting);
continue;
}
metricsCollectors.put(
collector, entry.getValue() + collector.getTimeInterval());
if (!collector.inProgress()) {
Expand Down Expand Up @@ -159,4 +181,13 @@ public void run() {
}
}
}

private boolean canSchedule(PerformanceAnalyzerMetricsCollector collector) {
if (collector instanceof TelemetryCollector) {
return (collectorsSetting == Util.CollectorMode.DUAL.getValue())
|| (collectorsSetting == Util.CollectorMode.TELEMETRY.getValue());
}
return (collectorsSetting == Util.CollectorMode.DUAL.getValue())
|| (collectorsSetting == Util.CollectorMode.RCA.getValue());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.performanceanalyzer.commons.collectors;

/** Marker interface for telemetry collectors. */
public interface TelemetryCollector {}
atharvasharma61 marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading