Skip to content

Commit

Permalink
Additional opensearch changes and formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sruti1312 committed Apr 16, 2021
1 parent 072ce05 commit 141fc16
Show file tree
Hide file tree
Showing 52 changed files with 492 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: ./gradlew publishToMavenLocal
- name: Build PA gradle using the new RCA jar
working-directory: ./tmp/pa
run: rm licenses/performanceanalyzer-rca-1.13.jar.sha1
run: rm -f licenses/performanceanalyzer-rca-1.13.jar.sha1
- name: Update SHA
working-directory: ./tmp/pa
run: ./gradlew updateShas
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ jobs:
run: ./gradlew publishToMavenLocal
- name: Build PA gradle using the new RCA jar
working-directory: ./tmp/pa
run: rm licenses/performanceanalyzer-rca-1.13.jar.sha1
run: rm -f licenses/performanceanalyzer-rca-1.13.jar.sha1
- name: Update SHA
working-directory: ./tmp/pa
run: ./gradlew updateShas
# Explicitly set the docker-compose program path so that our build scripts in RCA can run the program
# This is necessary because of the Github Actions environment and the workingDir of the Gradle environment
- name: Set docker-compose path
run: DOCKER_COMPOSE_LOCATION=$(which docker-compose)
# Set the vm.max_map_count system property to the minimum required to run Elasticsearch
# Set the vm.max_map_count system property to the minimum required to run OpenSearch
- name: Set vm.max_map_count
run: sudo sysctl -w vm.max_map_count=262144
- name: Build PA and run Unit Tests
Expand Down
3 changes: 3 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
## Maintainers
| Maintainer | GitHub ID | Affiliation |
| --------------- | --------- | ----------- |
<<<<<<< HEAD
| Charlotte Henkle | [CEHENKLE](https://github.com/CEHENKLE) | Amazon |
| Nick Knize | [nknize](https://github.com/nknize) | Amazon |
=======
>>>>>>> es-dep
| Joshua Tokle | [jotok](https://github.com/jotok) | Amazon |
| Sruti Parthiban | [sruti1312](https://github.com/sruti1312) | Amazon |
| Haoru Xiao | [hxiao608](https://github.com/hxiao608) | Amazon |
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ buildscript {
}

dependencies {
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
classpath "org.opensearch.gradle:build-tools:${opensearch_version}-SNAPSHOT"
classpath 'org.ajoberstar:gradle-git:0.2.3'
}
}
Expand Down Expand Up @@ -480,7 +480,7 @@ afterEvaluate {
maintainer 'OpenDistro for Elasticsearch Team <opendistro@amazon.com>'
url 'https://opendistro.github.io/for-elasticsearch/downloads.html'
summary '''
Performance Analyzer plugin for OpenDistro for OpenSearch.
Performance Analyzer plugin for OpenSearch.
Reference documentation can be found at https://opendistro.github.io/for-elasticsearch-docs/.
'''.stripIndent().replace('\n', ' ').trim()
}
Expand Down
11 changes: 11 additions & 0 deletions packaging/deb/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ chown opensearch /var/lib/opensearch/rca_enabled.conf
chown -R opensearch "$OPENSEARCH_HOME/performance-analyzer-rca"
chmod a+rw /tmp

<<<<<<< HEAD
if ! grep -q '## OpenDistro Performance Analyzer' /etc/opensearch/jvm.options; then
CLK_TCK=`/usr/bin/getconf CLK_TCK`
echo >> /etc/opensearch/jvm.options
echo '## OpenDistro Performance Analyzer' >> /etc/opensearch/jvm.options
=======
if ! grep -q '## OpenSearch Performance Analyzer' /etc/opensearch/jvm.options; then
CLK_TCK=`/usr/bin/getconf CLK_TCK`
echo >> /etc/opensearch/jvm.options
echo '## OpenSearch Performance Analyzer' >> /etc/opensearch/jvm.options
>>>>>>> es-dep
echo "-Dclk.tck=$CLK_TCK" >> /etc/opensearch/jvm.options
echo "-Djdk.attach.allowAttachSelf=true" >> /etc/opensearch/jvm.options
echo "-Djava.security.policy=file:///usr/share/opensearch/plugins/opendistro-performance-analyzer/pa_config/opensearch_security.policy" >> /etc/opensearch/jvm.options
Expand All @@ -47,7 +54,11 @@ fi

if [ "x$IS_UPGRADE" != "xtrue" ]; then
if command -v systemctl > /dev/null; then
<<<<<<< HEAD
echo '# Enabling opendistro performance analyzer to start and stop along with opensearch.service'
=======
echo '# Enabling OpenSearch performance analyzer to start and stop along with opensearch.service'
>>>>>>> es-dep
systemctl daemon-reload
systemctl enable opendistro-performance-analyzer.service || true

Expand Down
4 changes: 4 additions & 0 deletions packaging/opendistro-performance-analyzer.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[Unit]
<<<<<<< HEAD
Description=Opendistro for Elasticsearch Performance Analyzer
=======
Description=OpenSearch Performance Analyzer
>>>>>>> es-dep
PartOf=opensearch.service

[Service]
Expand Down
11 changes: 11 additions & 0 deletions packaging/rpm/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ chown opensearch /var/lib/opensearch/rca_enabled.conf
chown -R opensearch "$OPENSEARCH_HOME/performance-analyzer-rca"
chmod a+rw /tmp

<<<<<<< HEAD
if ! grep -q '## OpenDistro Performance Analyzer' /etc/opensearch/jvm.options; then
CLK_TCK=`/usr/bin/getconf CLK_TCK`
echo >> /etc/opensearch/jvm.options
echo '## OpenDistro Performance Analyzer' >> /etc/opensearch/jvm.options
=======
if ! grep -q '## OpenSearch Performance Analyzer' /etc/opensearch/jvm.options; then
CLK_TCK=`/usr/bin/getconf CLK_TCK`
echo >> /etc/opensearch/jvm.options
echo '## OpenSearch Performance Analyzer' >> /etc/opensearch/jvm.options
>>>>>>> es-dep
echo "-Dclk.tck=$CLK_TCK" >> /etc/opensearch/jvm.options
echo "-Djdk.attach.allowAttachSelf=true" >> /etc/opensearch/jvm.options
echo "-Djava.security.policy=file:///usr/share/opensearch/plugins/opendistro-performance-analyzer/pa_config/opensearch_security.policy" >> /etc/opensearch/jvm.options
Expand All @@ -57,7 +64,11 @@ esac

if [ "x$IS_UPGRADE" != "xtrue" ]; then
if command -v systemctl > /dev/null; then
<<<<<<< HEAD
echo '# Enabling opendistro performance analyzer to start and stop along with opensearch.service'
=======
echo '# Enabling OpenSearch performance analyzer to start and stop along with opensearch.service'
>>>>>>> es-dep
systemctl daemon-reload
systemctl enable opendistro-performance-analyzer.service || true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,12 @@ public PerformanceAnalyzerPlugin(final Settings settings, final java.nio.file.Pa
scheduledMetricCollectorsExecutor.addScheduledMetricCollector(
new AdmissionControlMetricsCollector());
scheduledMetricCollectorsExecutor.addScheduledMetricCollector(
<<<<<<< HEAD:src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/PerformanceAnalyzerPlugin.java
new ElectionTermCollector(
performanceAnalyzerController,configOverridesWrapper));
=======
new ElectionTermCollector(performanceAnalyzerController, configOverridesWrapper));
>>>>>>> es-dep:src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/PerformanceAnalyzerPlugin.java
try {
Class.forName(ShardIndexingPressureMetricsCollector.SHARD_INDEXING_PRESSURE_CLASS_NAME);
scheduledMetricCollectorsExecutor.addScheduledMetricCollector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public Object getClusterApplierServiceStats()
Method method =
ClusterApplierService.class.getMethod(
GET_CLUSTER_APPLIER_SERVICE_STATS_METHOD_NAME);
<<<<<<< HEAD:src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/collectors/ClusterApplierServiceStatsCollector.java
return method.invoke(OpenSearchResources.INSTANCE.getClusterService().getClusterApplierService());
}

Expand All @@ -143,6 +144,17 @@ public Object getClusterApplierServiceStats()
* the number of times it has failed. To calculate point in time metric, we will have to store
* its previous state and calculate the diff to get the point in time latency. This might return
* as 0 if there is no cluster update since last retrieval.
=======
return method.invoke(
OpenSearchResources.INSTANCE.getClusterService().getClusterApplierService());
}
/**
* ClusterApplierServiceStats is OpenSearch is a tracker for total time taken to apply cluster
* state and the number of times it has failed. To calculate point in time metric, we will have
* to store its previous state and calculate the diff to get the point in time latency. This
* might return as 0 if there is no cluster update since last retrieval.
>>>>>>> es-dep:src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/collectors/ClusterApplierServiceStatsCollector.java
*
* @param currentMetrics Current Cluster update stats in OpenSearch
* @return point in time latency.
Expand All @@ -161,10 +173,17 @@ private double computeRate(final double currentTotalCount) {
}

/**
<<<<<<< HEAD:src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/collectors/ClusterApplierServiceStatsCollector.java
* ClusterApplierServiceStats is OpenSearch is a tracker for total time taken to apply cluster state and
* the number of times it has failed. To calculate point in time metric, we will have to store
* its previous state and calculate the diff to get the point in time failure. This might return
* as 0 if there is no cluster update since last retrieval.
=======
* ClusterApplierServiceStats is OpenSearch is a tracker for total time taken to apply cluster
* state and the number of times it has failed. To calculate point in time metric, we will have
* to store its previous state and calculate the diff to get the point in time failure. This
* might return as 0 if there is no cluster update since last retrieval.
>>>>>>> es-dep:src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/collectors/ClusterApplierServiceStatsCollector.java
*
* @param currentMetrics Current Cluster update stats in OpenSearch
* @return point in time failure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

package com.amazon.opendistro.opensearch.performanceanalyzer.collectors;

<<<<<<< HEAD:src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/collectors/ElectionTermCollector.java
=======

>>>>>>> es-dep:src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/collectors/ElectionTermCollector.java
import com.amazon.opendistro.opensearch.performanceanalyzer.OpenSearchResources;
import com.amazon.opendistro.opensearch.performanceanalyzer.PerformanceAnalyzerApp;
import com.amazon.opendistro.opensearch.performanceanalyzer.config.PerformanceAnalyzerController;
Expand All @@ -32,16 +36,19 @@
/**
* This class starts publishing election term metric. These metric is emitted from cluster state.
*/
public class ElectionTermCollector extends PerformanceAnalyzerMetricsCollector implements MetricsProcessor {
public static final int SAMPLING_TIME_INTERVAL = MetricsConfiguration.CONFIG_MAP.get(ElectionTermCollector.class).samplingInterval;
public class ElectionTermCollector extends PerformanceAnalyzerMetricsCollector
implements MetricsProcessor {
public static final int SAMPLING_TIME_INTERVAL =
MetricsConfiguration.CONFIG_MAP.get(ElectionTermCollector.class).samplingInterval;
private static final Logger LOG = LogManager.getLogger(ElectionTermCollector.class);
private static final int KEYS_PATH_LENGTH = 0;
private final ConfigOverridesWrapper configOverridesWrapper;
private final PerformanceAnalyzerController controller;
private StringBuilder value;

public ElectionTermCollector(PerformanceAnalyzerController controller,
ConfigOverridesWrapper configOverridesWrapper) {
public ElectionTermCollector(
PerformanceAnalyzerController controller,
ConfigOverridesWrapper configOverridesWrapper) {
super(SAMPLING_TIME_INTERVAL, "ElectionTermCollector");
value = new StringBuilder();
this.controller = controller;
Expand All @@ -55,7 +62,8 @@ public String getMetricsPath(long startTime, String... keysPath) {
throw new RuntimeException("keys length should be " + KEYS_PATH_LENGTH);
}

return PerformanceAnalyzerMetrics.generatePath(startTime, PerformanceAnalyzerMetrics.sElectionTermPath);
return PerformanceAnalyzerMetrics.generatePath(
startTime, PerformanceAnalyzerMetrics.sElectionTermPath);
}

@Override
Expand All @@ -73,21 +81,32 @@ public void collectMetrics(long startTime) {
value.setLength(0);
value.append(PerformanceAnalyzerMetrics.getJsonCurrentMilliSeconds())
.append(PerformanceAnalyzerMetrics.sMetricNewLineDelimitor);
<<<<<<< HEAD:src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/collectors/ElectionTermCollector.java
value.append(new ElectionTermMetrics(
OpenSearchResources.INSTANCE.getClusterService().state()
.term()).serialize());
=======
value.append(
new ElectionTermMetrics(
OpenSearchResources.INSTANCE.getClusterService().state().term())
.serialize());
>>>>>>> es-dep:src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/collectors/ElectionTermCollector.java
saveMetricValues(value.toString(), startTime);

PerformanceAnalyzerApp.WRITER_METRICS_AGGREGATOR.updateStat(
WriterMetrics.ELECTION_TERM_COLLECTOR_EXECUTION_TIME, "",
WriterMetrics.ELECTION_TERM_COLLECTOR_EXECUTION_TIME,
"",
System.currentTimeMillis() - mCurrT);

} catch (Exception ex) {
PerformanceAnalyzerApp.ERRORS_AND_EXCEPTIONS_AGGREGATOR.updateStat(
ExceptionsAndErrors.ELECTION_TERM_COLLECTOR_ERROR, "",
ExceptionsAndErrors.ELECTION_TERM_COLLECTOR_ERROR,
"",
System.currentTimeMillis() - mCurrT);
LOG.debug("Exception in Collecting Election term Metrics: {} for startTime {}",
() -> ex.toString(), () -> startTime);
LOG.debug(
"Exception in Collecting Election term Metrics: {} for startTime {}",
() -> ex.toString(),
() -> startTime);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ public String getMetricsPath(long startTime, String... keysPath) {
public void collectMetrics(long startTime) {
try {
if (OpenSearchResources.INSTANCE.getClusterService() == null
<<<<<<< HEAD
|| OpenSearchResources.INSTANCE.getClusterService().getMasterService() == null) {
=======
|| OpenSearchResources.INSTANCE.getClusterService().getMasterService()
== null) {
>>>>>>> es-dep
return;
}

Expand Down Expand Up @@ -194,7 +199,12 @@ Field getMasterServiceTPExecutorField() throws Exception {

// - Separated to have a unit test; and catch any code changes around this field
Field getPrioritizedTPExecutorCurrentField() throws Exception {
<<<<<<< HEAD
Field currentField = PrioritizedOpenSearchThreadPoolExecutor.class.getDeclaredField("current");
=======
Field currentField =
PrioritizedOpenSearchThreadPoolExecutor.class.getDeclaredField("current");
>>>>>>> es-dep
currentField.setAccessible(true);
return currentField;
}
Expand All @@ -213,7 +223,12 @@ Method getPrioritizedTPExecutorAddPendingMethod() throws Exception {
classArray[1] = List.class;
classArray[2] = boolean.class;
Method addPendingMethod =
<<<<<<< HEAD
PrioritizedOpenSearchThreadPoolExecutor.class.getDeclaredMethod("addPending", classArray);
=======
PrioritizedOpenSearchThreadPoolExecutor.class.getDeclaredMethod(
"addPending", classArray);
>>>>>>> es-dep
addPendingMethod.setAccessible(true);
return addPendingMethod;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ public void collectMetrics(long startTime) {
try {
long mCurrT = System.currentTimeMillis();
if (OpenSearchResources.INSTANCE.getClusterService() == null
<<<<<<< HEAD:src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/collectors/MasterThrottlingMetricsCollector.java
|| OpenSearchResources.INSTANCE.getClusterService().getMasterService() == null) {
=======
|| OpenSearchResources.INSTANCE.getClusterService().getMasterService()
== null) {
>>>>>>> es-dep:src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/collectors/MasterThrottlingMetricsCollector.java
return;
}
if (!isMasterThrottlingFeatureAvailable()) {
Expand Down Expand Up @@ -114,7 +119,12 @@ private boolean isMasterThrottlingFeatureAvailable() {

private long getTotalMasterThrottledTaskCount() throws Exception {
Method method = MasterService.class.getMethod(THROTTLED_PENDING_TASK_COUNT_METHOD_NAME);
<<<<<<< HEAD:src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/collectors/MasterThrottlingMetricsCollector.java
return (long) method.invoke(OpenSearchResources.INSTANCE.getClusterService().getMasterService());
=======
return (long)
method.invoke(OpenSearchResources.INSTANCE.getClusterService().getMasterService());
>>>>>>> es-dep:src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/collectors/MasterThrottlingMetricsCollector.java
}

private long getRetryingPendingTaskCount() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ public void collectMetrics(long startTime) {
}
value.append(PerformanceAnalyzerMetrics.sMetricNewLineDelimitor);

<<<<<<< HEAD:src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/collectors/NodeDetailsCollector.java
DiscoveryNodes discoveryNodes = OpenSearchResources.INSTANCE.getClusterService().state().nodes();
=======
DiscoveryNodes discoveryNodes =
OpenSearchResources.INSTANCE.getClusterService().state().nodes();
>>>>>>> es-dep:src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/collectors/NodeDetailsCollector.java

DiscoveryNode masterNode = discoveryNodes.getMasterNode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
<<<<<<< HEAD
import org.opensearch.cluster.service.ClusterService;
import org.jooq.tools.json.JSONObject;
import org.jooq.tools.json.JSONParser;
import org.jooq.tools.json.ParseException;
=======
import org.jooq.tools.json.JSONObject;
import org.jooq.tools.json.JSONParser;
import org.jooq.tools.json.ParseException;
import org.opensearch.cluster.service.ClusterService;
>>>>>>> es-dep

public class ShardIndexingPressureMetricsCollector extends PerformanceAnalyzerMetricsCollector
implements MetricsProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,21 @@
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
<<<<<<< HEAD:src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/collectors/ShardStateCollector.java
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.routing.RoutingTable;
import org.opensearch.cluster.routing.ShardRouting;
import org.opensearch.cluster.routing.ShardRoutingState;
import org.jooq.tools.StringUtils;
import org.jooq.tools.json.JSONObject;
=======
import org.jooq.tools.StringUtils;
import org.jooq.tools.json.JSONObject;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.routing.RoutingTable;
import org.opensearch.cluster.routing.ShardRouting;
import org.opensearch.cluster.routing.ShardRoutingState;
>>>>>>> es-dep:src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/collectors/ShardStateCollector.java

public class ShardStateCollector extends PerformanceAnalyzerMetricsCollector
implements MetricsProcessor {
Expand Down
Loading

0 comments on commit 141fc16

Please sign in to comment.