Skip to content

Commit

Permalink
Merge pull request #1 from kkhatua/es-dep-fork
Browse files Browse the repository at this point in the history
Rebranded to OpenSearch (Ver1)
  • Loading branch information
kkhatua authored Apr 6, 2021
2 parents 130a494 + 6419c05 commit ec5a371
Show file tree
Hide file tree
Showing 155 changed files with 8,820 additions and 7,604 deletions.
45 changes: 24 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
buildscript {

ext {
es_version = System.getProperty("es.version", "7.10.2")
opensearch_version = System.getProperty("opensearch.version", "7.10.3")
}
// This isn't applying from repositories.gradle so repeating it here
repositories {
Expand All @@ -25,7 +25,7 @@ buildscript {
}

dependencies {
classpath "org.elasticsearch.gradle:build-tools:${es_version}"
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
classpath 'org.ajoberstar:gradle-git:0.2.3'
}
}
Expand Down Expand Up @@ -64,7 +64,7 @@ if (isSnapshot) {
version += "-SNAPSHOT"
}

apply plugin: 'elasticsearch.esplugin'
apply plugin: 'opensearch.opensearchplugin'

ext {
projectSubstitutions = [:]
Expand Down Expand Up @@ -101,10 +101,10 @@ validateNebulaPom.enabled = false

loggerUsageCheck.enabled = false

esplugin {
opensearchplugin {
name 'opendistro-performance-analyzer'
description 'Performance Analyzer Plugin'
classname 'com.amazon.opendistro.elasticsearch.performanceanalyzer.PerformanceAnalyzerPlugin'
classname 'com.amazon.opendistro.opensearch.performanceanalyzer.PerformanceAnalyzerPlugin'
}

sourceCompatibility = 1.8
Expand Down Expand Up @@ -163,7 +163,7 @@ jacocoTestReport {
classDirectories.from = files(classDirectories.files.collect {
fileTree(dir: it,
include: [
'**/com/amazon/opendistro/elasticsearch/performanceanalyzer/**',
'**/com/amazon/opendistro/opensearch/performanceanalyzer/**',
],
exclude: [
'**/FaultDetectionMetricsCollector.class',
Expand All @@ -180,7 +180,7 @@ jacocoTestCoverageVerification {
classDirectories.from = files(classDirectories.files.collect {
fileTree(dir: it,
include: [
'**/com/amazon/opendistro/elasticsearch/performanceanalyzer/**',
'**/com/amazon/opendistro/opensearch/performanceanalyzer/**',
],
exclude: [
])
Expand Down Expand Up @@ -210,6 +210,8 @@ dependencies {
configurations {
// jarHell reports class name conflicts between securemock and mockito-core
// has to disable one of them.
// Need to continue exclude this group until we figure out how to get rid of
// this exclusion with opensearch
all*.exclude group: "org.elasticsearch", module: "securemock"
}

Expand All @@ -231,7 +233,7 @@ dependencies {
compile 'org.apache.commons:commons-lang3:3.9'
compile 'org.bouncycastle:bcprov-jdk15on:1.68'
compile 'org.bouncycastle:bcpkix-jdk15on:1.68'
compile 'com.amazon.opendistro.elasticsearch:performanceanalyzer-rca:1.13'
compile 'com.amazon.opendistro.opensearch:performanceanalyzer-rca:1.13'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.10.5'
compile 'com.fasterxml.jackson.core:jackson-databind:2.10.5.1'
compile 'com.fasterxml.jackson.module:jackson-module-paranamer:2.10.5'
Expand Down Expand Up @@ -284,7 +286,7 @@ gradle.startParameter.excludedTaskNames += [ "forbiddenApisMain",
"testingConventions"]
import java.nio.file.Paths
import org.ajoberstar.gradle.git.tasks.GitClone
import org.elasticsearch.gradle.test.RestIntegTestTask
import org.opensearch.gradle.test.RestIntegTestTask

String rcaDir
String rcaArtifactsDir
Expand All @@ -293,7 +295,7 @@ static def propEnabled(property) {
return System.getProperty(property) != null && System.getProperty(property).toLowerCase().equals("true")
}

// The following Gradle tasks are used to create a PA/RCA enabled Elasticsearch cluster
// The following Gradle tasks are used to create a PA/RCA enabled OpenSearch cluster
// Pass the -Dtests.enableIT property to Gradle to run ITs
/**
* cloneGitRepo clones the performance-analyzer-rca repo if the -Dtests.enableIT=true flag is passed
Expand Down Expand Up @@ -377,7 +379,7 @@ bundlePlugin {
* setupESCluster spins up a local 2 node ES cluster using the enableRca task in the performance-analyzer-rca
* repo. The performance-analyzer-rca repo is cloned as part of the cloneGitRepo task.
*/
task setupEsCluster() {
task setupOpenSearchCluster() {
dependsOn(cloneGitRepo)
onlyIf = {
propEnabled("tests.enableIT")
Expand All @@ -392,18 +394,18 @@ task setupEsCluster() {
}

/**
* integTest is a task provided by the ES test framework, which allows us to spin up clients
* and test API calls against a local or remote Elasticsearch cluster.
* integTest is a task provided by the OpenSearch test framework, which allows us to spin up clients
* and test API calls against a local or remote OpenSearch cluster.
*
* The simplest way to run this task in a way that "just works" is to invoke
* ./gradlew integTest -Dtests.enableIT=true -Dtests.useDockerCluster=true
* which will spin up a local 2 node ES cluster on your machine, then execute the test suite against it
* which will spin up a local 2 node OpenSearch cluster on your machine, then execute the test suite against it
*
* A full list of options is provided below. Check our gradle.properties file for the defaults for
* each of these properties.
*
* -Dtests.rest.cluster the Elasticsearch REST endpoint that test clients should hit
* -Dtests.cluster the Elasticsearch <a href="https://discuss.elastic.co/t/transport-client-vs-rest-client/13936">transport</a>
* -Dtests.rest.cluster the OpenSearch REST endpoint that test clients should hit
* -Dtests.cluster the OpenSearch <a href="https://discuss.elastic.co/t/transport-client-vs-rest-client/13936">transport</a>
* endpoint that test clients should hit
* -Dtests.enableIT a flag to enable integration testing, by default this is false
* -Dtests.useDockerCluster if true, spin up a local 2 node cluster before executing tests
Expand Down Expand Up @@ -435,9 +437,9 @@ afterEvaluate {
release = isSnapshot ? "0.1" : '1'
version = "${project.version}" - "-SNAPSHOT"

into '/usr/share/elasticsearch/plugins'
into '/usr/share/opensearch/plugins'
from(zipTree(bundlePlugin.archivePath)) {
into esplugin.name
into opensearchplugin.name
}

configurationFile '/usr/lib/systemd/system/opendistro-elasticsearch.service'
Expand All @@ -446,7 +448,7 @@ afterEvaluate {
from "packaging/opendistro-performance-analyzer.service"
fileMode 0644
}
into('/usr/share/elasticsearch/bin') {
into('/usr/share/opensearch/bin') {
from ('packaging/performance-analyzer-agent-cli') {
fileMode 0755
}
Expand All @@ -457,7 +459,7 @@ afterEvaluate {
fileMode 0644
dirMode 0755

requires('elasticsearch-oss', versions.elasticsearch, EQUAL)
requires('opensearch', versions.opensearch, EQUAL)
packager = 'Amazon'
vendor = 'Amazon'
os = 'LINUX'
Expand All @@ -467,7 +469,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 Elasticsearch.
Performance Analyzer plugin for OpenDistro for OpenSearch.
Reference documentation can be found at https://opendistro.github.io/for-elasticsearch-docs/.
'''.stripIndent().replace('\n', ' ').trim()
}
Expand Down Expand Up @@ -513,3 +515,4 @@ afterEvaluate {

bundlePlugin.mustRunAfter unpackRca
build.dependsOn unpackRca

2 changes: 1 addition & 1 deletion checkstyle/findbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Bug pattern="DM_DEFAULT_ENCODING" />
</Match>
<Match>
<Class name="com.amazon.opendistro.elasticsearch.performanceanalyzer.collectors.ThreadPoolMetricsCollector"/>
<Class name="com.amazon.opendistro.opensearch.performanceanalyzer.collectors.ThreadPoolMetricsCollector"/>
<Bug pattern="REC_CATCH_EXCEPTION"/>
</Match>
</FindBugsFilter>
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# The following 3 properties are used for integration testing with Elasticsearch
# The following 3 properties are used for integration testing with OpenSearch
# The "enablePaAndRca" gradle task in the performance-analyzer-rca repository contains logic to spin up a 2-node
# Elasticsearch cluster with the PA and RCA components enabled. The cluster endpoint for this cluster is localhost:9300
# OpenSearch cluster with the PA and RCA components enabled. The cluster endpoint for this cluster is localhost:9300
# and the REST endpoint is localhost:9200.

# The Elasticsearch cluster endpoint to use for test REST requests
# The OpenSearch cluster endpoint to use for test REST requests
systemProp.tests.rest.cluster=localhost:9200
# The Elasticsearch cluster node communication endpoint
# The OpenSearch cluster node communication endpoint
systemProp.tests.cluster=localhost:9300

# The Elasticsearch cluster name for integ tests
# The OpenSearch cluster name for integ tests
systemProp.tests.clustername=IntegTestCluster

# Set this to true if you want a cluster spun up for integration testing
Expand Down
18 changes: 9 additions & 9 deletions pa_bin/performance-analyzer-agent
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ if [ "$START_PERF_ANALYZER" = "false" ]; then
fi

if [ -z "$1" ]; then
if [ -z "$ES_HOME" ]; then
echo "ES_HOME needs to be set or passed in as the first parameter."
if [ -z "$OPENSEARCH_HOME" ]; then
echo "OPENSEARCH_HOME needs to be set or passed in as the first parameter."
exit 1
fi
else
ES_HOME=$1
OPENSEARCH_HOME=$1
fi

if [ -z "$2" ]; then
Expand All @@ -23,18 +23,18 @@ else
JAVA_HOME=$2
fi

# Instead of the supervisor executing peformance-analyzer-agent from the plugin location,
# Instead of the supervisor executing performance-analyzer-agent from the plugin location,
# we should move this to the reader. The entry-point script should be executing
# performance-analyzer-agent from the reader location.
# We need to change this file: https://github.com/opendistro-for-elasticsearch/elasticsearch-build/blob/6d6230e180c86c3249c7fa0786d685e48772d454/docker/build/elasticsearch/bin/docker-entrypoint.sh#L94
# We need to change this file: https://github.com/opendistro-for-elasticsearch/opendistro-build/blob/main/opensearch/docker/config/docker-entrypoint.sh

if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' >/dev/null; then
export JAVA_OPTS=-Des.path.home=$ES_HOME\ -Dlog4j.configurationFile=$ES_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/pa_config/log4j2.xml
exec $ES_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/bin/performance-analyzer-rca
export JAVA_OPTS=-Des.path.home=$OPENSEARCH_HOME\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/pa_config/log4j2.xml
exec $OPENSEARCH_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/bin/performance-analyzer-rca
else
echo 'Starting deamon'
export JAVA_OPTS=-Des.path.home=$ES_HOME\ -Dlog4j.configurationFile=$ES_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/pa_config/log4j2.xml
exec $ES_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/bin/performance-analyzer-rca &
export JAVA_OPTS=-Des.path.home=$OPENSEARCH_HOME\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/pa_config/log4j2.xml
exec $OPENSEARCH_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/bin/performance-analyzer-rca &

pid=$!
PID_LOC=/tmp/performance-analyzer-agent
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pa_config/performance-analyzer.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ======================== Elasticsearch performance analyzer plugin config =========================
# ======================== OpenSearch performance analyzer plugin config =========================

# NOTE: this is an example for Linux. Please modify the config accordingly if you are using it under other OS.

Expand Down
2 changes: 1 addition & 1 deletion pa_config/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ serverurl=/usr/share/supervisord.sock
files = /etc/supervisor/conf.d/*.conf

[program:performance_analyzer]
command=/usr/share/elasticsearch/plugins/opendistro-performance-analyzer/pa_bin/performance-analyzer-agent /usr/share/elasticsearch
command=/usr/share/opensearch/plugins/opendistro-performance-analyzer/pa_bin/performance-analyzer-agent /usr/share/opensearch
user=1000
48 changes: 24 additions & 24 deletions packaging/deb/postinst
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
#!/bin/sh
set -e

# Make sure the ES_HOME environment variable is set
if [ -z "$ES_HOME" ]; then
ES_HOME=/usr/share/elasticsearch
# Make sure the OPENSEARCH_HOME environment variable is set
if [ -z "$OPENSEARCH_HOME" ]; then
OPENSEARCH_HOME=/usr/share/opensearch
fi

# Prepare the RCA reader process for execution
cp -r "$ES_HOME"/plugins/opendistro-performance-analyzer/performance-analyzer-rca $ES_HOME
if [ -f "$ES_HOME"/bin/opendistro-performance-analyzer/performance-analyzer-agent-cli ]; then
mv "$ES_HOME"/bin/opendistro-performance-analyzer/performance-analyzer-agent-cli "$ES_HOME"/bin
rm -rf "$ES_HOME"/bin/opendistro-performance-analyzer
cp -r "$OPENSEARCH_HOME"/plugins/opendistro-performance-analyzer/performance-analyzer-rca $OPENSEARCH_HOME
if [ -f "$OPENSEARCH_HOME"/bin/opendistro-performance-analyzer/performance-analyzer-agent-cli ]; then
mv "$OPENSEARCH_HOME"/bin/opendistro-performance-analyzer/performance-analyzer-agent-cli "$OPENSEARCH_HOME"/bin
rm -rf "$OPENSEARCH_HOME"/bin/opendistro-performance-analyzer
fi
mkdir -p "$ES_HOME"/data
mkdir -p "/var/lib/elasticsearch"
touch "$ES_HOME"/data/rca_enabled.conf
echo 'true' > "$ES_HOME"/data/rca_enabled.conf
echo 'true' > /var/lib/elasticsearch/performance_analyzer_enabled.conf
echo 'true' > /var/lib/elasticsearch/rca_enabled.conf
chown elasticsearch /var/lib/elasticsearch/performance_analyzer_enabled.conf
chown elasticsearch /var/lib/elasticsearch/rca_enabled.conf
chown -R elasticsearch "$ES_HOME/performance-analyzer-rca"
mkdir -p "$OPENSEARCH_HOME"/data
mkdir -p "/var/lib/opensearch"
touch "$OPENSEARCH_HOME"/data/rca_enabled.conf
echo 'true' > "$OPENSEARCH_HOME"/data/rca_enabled.conf
echo 'true' > /var/lib/opensearch/performance_analyzer_enabled.conf
echo 'true' > /var/lib/opensearch/rca_enabled.conf
chown opensearch /var/lib/opensearch/performance_analyzer_enabled.conf
chown opensearch /var/lib/opensearch/rca_enabled.conf
chown -R opensearch "$OPENSEARCH_HOME/performance-analyzer-rca"
chmod a+rw /tmp

if ! grep -q '## OpenDistro Performance Analyzer' /etc/elasticsearch/jvm.options; then
if ! grep -q '## OpenDistro Performance Analyzer' /etc/opensearch/jvm.options; then
CLK_TCK=`/usr/bin/getconf CLK_TCK`
echo >> /etc/elasticsearch/jvm.options
echo '## OpenDistro Performance Analyzer' >> /etc/elasticsearch/jvm.options
echo "-Dclk.tck=$CLK_TCK" >> /etc/elasticsearch/jvm.options
echo "-Djdk.attach.allowAttachSelf=true" >> /etc/elasticsearch/jvm.options
echo "-Djava.security.policy=file:///usr/share/elasticsearch/plugins/opendistro-performance-analyzer/pa_config/es_security.policy" >> /etc/elasticsearch/jvm.options
echo >> /etc/opensearch/jvm.options
echo '## OpenDistro Performance Analyzer' >> /etc/opensearch/jvm.options
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
fi

IS_UPGRADE=false
Expand All @@ -47,13 +47,13 @@ fi

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

elif command -v chkconfig >/dev/null; then
echo "### Non systemd distro. Please start and stop performance analyzer manually using the command: "
echo "sh /usr/share/elasticsearch/plugins/opendistro-performance-analyzer/pa_bin/performance-analyzer-agent /usr/share/elasticsearch -d"
echo "sh /usr/share/opensearch/plugins/opendistro-performance-analyzer/pa_bin/performance-analyzer-agent /usr/share/opensearch -d"
fi
fi

Expand Down
34 changes: 17 additions & 17 deletions packaging/deb/postrm
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
#!/bin/sh

# Make sure the ES_HOME environment variable is set
if [ -z "$ES_HOME" ]; then
ES_HOME=/usr/share/elasticsearch
# Make sure the OPENSEARCH_HOME environment variable is set
if [ -z "$OPENSEARCH_HOME" ]; then
OPENSEARCH_HOME=/usr/share/opensearch
fi

echo "ES_HOME is $ES_HOME"
echo "OPENSEARCH_HOME is $OPENSEARCH_HOME"

# Cleanup files
if [ -d $ES_HOME/performance-analyzer-rca ]; then
rm -rf $ES_HOME/performance-analyzer-rca
if [ -d $OPENSEARCH_HOME/performance-analyzer-rca ]; then
rm -rf $OPENSEARCH_HOME/performance-analyzer-rca
fi

if [ -f $ES_HOME/bin/performance-analyzer-agent-cli ]; then
rm $ES_HOME/bin/performance-analyzer-agent-cli
if [ -f $OPENSEARCH_HOME/bin/performance-analyzer-agent-cli ]; then
rm $OPENSEARCH_HOME/bin/performance-analyzer-agent-cli
fi

if [ -f "$ES_HOME"/data/rca_enabled.conf ]; then
rm "$ES_HOME"/data/rca_enabled.conf
if [ -f "$OPENSEARCH_HOME"/data/rca_enabled.conf ]; then
rm "$OPENSEARCH_HOME"/data/rca_enabled.conf
fi

if [ -f /var/lib/elasticsearch/performance_analyzer_enabled.conf ]; then
rm /var/lib/elasticsearch/performance_analyzer_enabled.conf
if [ -f /var/lib/opensearch/performance_analyzer_enabled.conf ]; then
rm /var/lib/opensearch/performance_analyzer_enabled.conf
fi

if [ -f /var/lib/elasticsearch/rca_enabled.conf ]; then
rm /var/lib/elasticsearch/rca_enabled.conf
if [ -f /var/lib/opensearch/rca_enabled.conf ]; then
rm /var/lib/opensearch/rca_enabled.conf
fi

if [ -f /usr/lib/systemd/system/opendistro-elasticsearch.service ]; then
rm /usr/lib/systemd/system/opendistro-elasticsearch.service
fi
if [ -f /usr/lib/systemd/system/opendistro-opensearch.service ]; then
rm /usr/lib/systemd/system/opendistro-opensearch.service
fi
Loading

0 comments on commit ec5a371

Please sign in to comment.