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

Update directory names and remove jar for integTest #187

Merged
merged 2 commits into from
Apr 15, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.idea/
/build/
*.iml
/src/test/resources/org/opensearch/performanceanalyzer/bwc/1.13.0.0/*.zip
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export JAVA_HOME=$JAVA_HOME
# We need to change this file: https://github.com/opensearch-project/opensearch-build/blob/main/release/docker/config/opensearch/opensearch-docker-entrypoint.sh

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

pid=$!
Expand Down
22 changes: 14 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,11 @@ tasks.withType(Test) {

bundlePlugin {
dependsOn 'unpackRca'
from("$rcaArtifactsDir/pa_config") {
into "pa_config"
}
from("$rcaArtifactsDir/pa_bin") {
into "pa_bin"
include "performance-analyzer-agent"
from("$rcaArtifactsDir/config") {
into "config"
}
from("$rcaArtifactsDir/pa_bin") {
into "extensions"
from("$rcaArtifactsDir/bin") {
into "bin"
include "performance-analyzer-agent"
}
from("$rcaArtifactsDir") {
Expand Down Expand Up @@ -541,6 +537,8 @@ task integTestRemote(type: RestIntegTestTask) {
String bwcVersion = "1.13.0.0"
String baseName = "paBwcCluster"
String bwcFilePath = "src/test/resources/org/opensearch/performanceanalyzer/bwc/"
String bwcRemoteFile = "https://d3g5vo6xdbdb9a.cloudfront.net/downloads/elasticsearch-plugins/performance-analyzer/opendistro-performance-analyzer-1.13.0.0.zip"
String bwcOpenDistroPlugin = "opendistro-performance-analyzer-1.13.0.0.zip"

2.times {i ->
testClusters {
Expand All @@ -554,6 +552,14 @@ String bwcFilePath = "src/test/resources/org/opensearch/performanceanalyzer/bwc/
return new RegularFile() {
@Override
File getAsFile() {
File dir = new File(bwcFilePath + bwcVersion)
if (!dir.exists()) {
dir.mkdirs()
}
File f = new File(bwcFilePath + bwcVersion + "/" + bwcOpenDistroPlugin)
if (!f.exists()) {
new URL(bwcRemoteFile).withInputStream{ ins -> f.withOutputStream{ it << ins }}
}
return fileTree(bwcFilePath + bwcVersion).getSingleFile()
}
}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ grant codeBase "jrt:/jdk.attach" {
grant codeBase "jrt:/jdk.internal.jvmstat" {
permission java.security.AllPermission;
};

File renamed without changes.
2 changes: 1 addition & 1 deletion pa_config/supervisord.conf → 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/opensearch/plugins/opensearch-performance-analyzer/pa_bin/performance-analyzer-agent /usr/share/opensearch
command=/usr/share/opensearch/plugins/opensearch-performance-analyzer/bin/performance-analyzer-agent /usr/share/opensearch
user=1000
1 change: 1 addition & 0 deletions licenses/commons-lang3-3.12.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c6842c86792ff03b9f1d1fe2aab8dc23aa6c6f0e
1 change: 0 additions & 1 deletion licenses/commons-lang3-3.9.jar.sha1

This file was deleted.

1 change: 0 additions & 1 deletion licenses/paranamer-2.8.jar.sha1

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
7461afd1624f81989227c761f45d07ded9d7a326
8c91b98548b421d60af43b4a6277614b0fb7000d
4 changes: 2 additions & 2 deletions packaging/deb/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if ! grep -q '## OpenSearch Performance Analyzer' /etc/opensearch/jvm.options; t
echo '## OpenSearch 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/opensearch-performance-analyzer/pa_config/opensearch_security.policy" >> /etc/opensearch/jvm.options
echo "-Djava.security.policy=file:///usr/share/opensearch/plugins/opensearch-performance-analyzer/config/opensearch_security.policy" >> /etc/opensearch/jvm.options
fi

IS_UPGRADE=false
Expand All @@ -53,7 +53,7 @@ if [ "x$IS_UPGRADE" != "xtrue" ]; then

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/opensearch/plugins/opensearch-performance-analyzer/pa_bin/performance-analyzer-agent /usr/share/opensearch -d"
echo "sh /usr/share/opensearch/plugins/opensearch-performance-analyzer/bin/performance-analyzer-agent /usr/share/opensearch -d"
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion packaging/performance-analyzer-agent-cli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

PA_AGENT_JAVA_OPTS="-Dlog4j.configurationFile=$OPENSEARCH_HOME/plugins/opensearch-performance-analyzer/pa_config/log4j2.xml \
PA_AGENT_JAVA_OPTS="-Dlog4j.configurationFile=$OPENSEARCH_HOME/plugins/opensearch-performance-analyzer/config/log4j2.xml \
-Xms64M -Xmx64M -XX:+UseSerialGC -XX:CICompilerCount=1 -XX:-TieredCompilation -XX:InitialCodeCacheSize=4096 \
-XX:MaxRAM=400m"

Expand Down
4 changes: 2 additions & 2 deletions packaging/rpm/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if ! grep -q '## OpenSearch Performance Analyzer' /etc/opensearch/jvm.options; t
echo '## OpenSearch 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/opensearch-performance-analyzer/pa_config/opensearch_security.policy" >> /etc/opensearch/jvm.options
echo "-Djava.security.policy=file:///usr/share/opensearch/plugins/opensearch-performance-analyzer/config/opensearch_security.policy" >> /etc/opensearch/jvm.options
fi

IS_UPGRADE=false
Expand Down Expand Up @@ -63,6 +63,6 @@ if [ "x$IS_UPGRADE" != "xtrue" ]; then

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/opensearch/plugins/opensearch-performance-analyzer/pa_bin/performance-analyzer-agent /usr/share/opensearch -d"
echo "sh /usr/share/opensearch/plugins/opensearch-performance-analyzer/bin/performance-analyzer-agent /usr/share/opensearch -d"
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class PerformanceAnalyzerController {
// This file should contain "true" or "false", indicating whether batch metrics is currently
// enabled or not.
private static final String BATCH_METRICS_ENABLED_CONF = "batch_metrics_enabled.conf";
private static final String THREAD_CONTENTION_MONITORING_ENABLED_CONF = "thread_contention_monitoring_enabled.conf";
private static final String THREAD_CONTENTION_MONITORING_ENABLED_CONF =
"thread_contention_monitoring_enabled.conf";
private static final Logger LOG = LogManager.getLogger(PerformanceAnalyzerController.class);
public static final int DEFAULT_NUM_OF_SHARDS_PER_COLLECTION = 0;

Expand Down Expand Up @@ -177,18 +178,20 @@ public void updateBatchMetricsState(final boolean shouldEnable) {
/**
* Updates the state of the thread contention monitoring api.
*
* @param shouldEnable The desired state of the thread contention monitoring api. False to disable, and true to
* enable.
* @param shouldEnable The desired state of the thread contention monitoring api. False to
* disable, and true to enable.
*/
public void updateThreadContentionMonitoringState(final boolean shouldEnable) {
if (shouldEnable && !isPerformanceAnalyzerEnabled()) {
return;
}
this.threadContentionMonitoringEnabled = shouldEnable;
if (scheduledMetricCollectorsExecutor != null) {
scheduledMetricCollectorsExecutor.setThreadContentionMonitoringEnabled(threadContentionMonitoringEnabled);
scheduledMetricCollectorsExecutor.setThreadContentionMonitoringEnabled(
threadContentionMonitoringEnabled);
}
saveStateToConf(this.threadContentionMonitoringEnabled, THREAD_CONTENTION_MONITORING_ENABLED_CONF);
saveStateToConf(
this.threadContentionMonitoringEnabled, THREAD_CONTENTION_MONITORING_ENABLED_CONF);
}

private void initPerformanceAnalyzerStateFromConf() {
Expand Down Expand Up @@ -284,16 +287,23 @@ private void initThreadContentionMonitoringStateFromConf() {
} catch (NoSuchFileException e) {
LOG.debug("Error reading Performance Analyzer state from Conf file", e);
saveStateToConf(
threadContentionMonitoringEnabledDefaultValue, THREAD_CONTENTION_MONITORING_ENABLED_CONF);
threadContentionMonitoringEnabledFromConf = threadContentionMonitoringEnabledDefaultValue;
threadContentionMonitoringEnabledDefaultValue,
THREAD_CONTENTION_MONITORING_ENABLED_CONF);
threadContentionMonitoringEnabledFromConf =
threadContentionMonitoringEnabledDefaultValue;
} catch (Exception e) {
LOG.debug("Error reading thread contention monitoring state from Conf file", e);
threadContentionMonitoringEnabledFromConf = threadContentionMonitoringEnabledDefaultValue;
LOG.debug(
"Error reading thread contention monitoring state from Conf file",
e);
threadContentionMonitoringEnabledFromConf =
threadContentionMonitoringEnabledDefaultValue;
}

// For thread contention monitoring to be enabled, both PA and thread contention monitoring
// For thread contention monitoring to be enabled, both PA and thread contention
// monitoring
// need to enabled.
updateThreadContentionMonitoringState(paEnabled && threadContentionMonitoringEnabledFromConf);
updateThreadContentionMonitoringState(
paEnabled && threadContentionMonitoringEnabledFromConf);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class PerformanceAnalyzerClusterSettingHandler implements ClusterSettingL
PerformanceAnalyzerClusterSettings.PerformanceAnalyzerFeatureBits.BATCH_METRICS_BIT
.ordinal();
private static final int THREAD_CONTENTION_MONITORING_ENABLED_BIT_POS =
PerformanceAnalyzerClusterSettings.PerformanceAnalyzerFeatureBits.THREAD_CONTENTION_MONITORING_BIT
PerformanceAnalyzerClusterSettings.PerformanceAnalyzerFeatureBits
.THREAD_CONTENTION_MONITORING_BIT
.ordinal();

private final PerformanceAnalyzerController controller;
Expand Down Expand Up @@ -121,7 +122,8 @@ public void onSettingUpdate(final Integer newSettingValue) {
controller.updateRcaState(getRcaStateFromSetting(newSettingValue));
controller.updateLoggingState(getLoggingStateFromSetting(newSettingValue));
controller.updateBatchMetricsState(getBatchMetricsStateFromSetting(newSettingValue));
controller.updateThreadContentionMonitoringState(getThreadContentionMonitoringStateFromSetting(newSettingValue));
controller.updateThreadContentionMonitoringState(
getThreadContentionMonitoringStateFromSetting(newSettingValue));
}
}

Expand Down Expand Up @@ -182,10 +184,12 @@ private boolean getPAStateFromSetting(final int settingValue) {

/**
* Converts the boolean PA state to composite cluster setting. If Performance Analyzer is being
* turned off, it will also turn off RCA, logging, batch metrics and thread contention monitoring.
* turned off, it will also turn off RCA, logging, batch metrics and thread contention
* monitoring.
*
* @param state the state of performance analyzer. Will enable performance analyzer if true,
* disables performance analyzer, RCA, logging, batch metrics and thread contention monitoring.
* disables performance analyzer, RCA, logging, batch metrics and thread contention
* monitoring.
* @return composite cluster setting as an integer.
*/
private Integer getPASettingValueFromState(final boolean state) {
Expand Down Expand Up @@ -243,7 +247,8 @@ private boolean getBatchMetricsStateFromSetting(final int settingValue) {
* @return true if the THREAD_CONTENTION_MONITORING bit is set, false otherwise.
*/
private boolean getThreadContentionMonitoringStateFromSetting(final int settingValue) {
return ((settingValue >> THREAD_CONTENTION_MONITORING_ENABLED_BIT_POS) & BIT_ONE) == ENABLED_VALUE;
return ((settingValue >> THREAD_CONTENTION_MONITORING_ENABLED_BIT_POS) & BIT_ONE)
== ENABLED_VALUE;
}

/**
Expand Down Expand Up @@ -306,11 +311,12 @@ private Integer getBatchMetricsSettingValueFromState(final boolean shouldEnable)
}

/**
* Converts the boolean thread contention monitoring state to composite cluster setting. Enables thread contention
* monitoring only if performance analyzer is also set. Otherwise, results in a no-op.
* Converts the boolean thread contention monitoring state to composite cluster setting. Enables
* thread contention monitoring only if performance analyzer is also set. Otherwise, results in
* a no-op.
*
* @param shouldEnable the state of thread contention monitoring. Will try to enable if true, disables thread
* contention monitoring if false.
* @param shouldEnable the state of thread contention monitoring. Will try to enable if true,
* disables thread contention monitoring if false.
* @return composite cluster setting as an integer.
*/
private Integer getThreadContentionMonitoringSettingValueFromState(final boolean shouldEnable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import static java.util.Collections.unmodifiableList;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -69,8 +68,7 @@ public class PerformanceAnalyzerClusterConfigAction extends BaseRestHandler {
THREAD_CONTENTION_MONITORING_CLUSTER_CONFIG_PATH),
new Route(
RestRequest.Method.POST,
THREAD_CONTENTION_MONITORING_CLUSTER_CONFIG_PATH)
));
THREAD_CONTENTION_MONITORING_CLUSTER_CONFIG_PATH)));
private static final List<ReplacedRoute> REPLACED_ROUTES =
unmodifiableList(
asList(
Expand Down Expand Up @@ -181,7 +179,8 @@ protected RestChannelConsumer prepareRequest(final RestRequest request, final No
} else if (request.path().contains(BATCH_METRICS_CLUSTER_CONFIG_PATH)
|| request.path().contains(LEGACY_BATCH_METRICS_CLUSTER_CONFIG_PATH)) {
clusterSettingHandler.updateBatchMetricsSetting((Boolean) value);
} else if (request.path().contains(THREAD_CONTENTION_MONITORING_CLUSTER_CONFIG_PATH)) {
} else if (request.path()
.contains(THREAD_CONTENTION_MONITORING_CLUSTER_CONFIG_PATH)) {
clusterSettingHandler.updateThreadContentionMonitoringSetting((Boolean) value);
} else {
clusterSettingHandler.updatePerformanceAnalyzerSetting((Boolean) value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import static java.util.Collections.unmodifiableList;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -39,7 +38,8 @@ public class PerformanceAnalyzerConfigAction extends BaseRestHandler {
public static final String RCA_ENABLED = "rcaEnabled";
public static final String PA_LOGGING_ENABLED = "loggingEnabled";
public static final String BATCH_METRICS_ENABLED = "batchMetricsEnabled";
public static final String THREAD_CONTENTION_MONITORING_ENABLED = "threadContentionMonitoringEnabled";
public static final String THREAD_CONTENTION_MONITORING_ENABLED =
"threadContentionMonitoringEnabled";
public static final String BATCH_METRICS_RETENTION_PERIOD_MINUTES =
"batchMetricsRetentionPeriodMinutes";
public static final String PERFORMANCE_ANALYZER_CONFIG_ACTION =
Expand Down Expand Up @@ -67,8 +67,7 @@ public class PerformanceAnalyzerConfigAction extends BaseRestHandler {
THREAD_CONTENTION_MONITORING_CONFIG_PATH),
new Route(
RestRequest.Method.POST,
THREAD_CONTENTION_MONITORING_CONFIG_PATH)
));
THREAD_CONTENTION_MONITORING_CONFIG_PATH)));
private static final List<ReplacedRoute> REPLACED_ROUTES =
unmodifiableList(
asList(
Expand Down Expand Up @@ -190,7 +189,8 @@ protected RestChannelConsumer prepareRequest(final RestRequest request, final No
return getChannelConsumerWithError(
"Error: PA not enabled. Enable PA before turning thread contention monitoring on");
}
performanceAnalyzerController.updateThreadContentionMonitoringState(shouldEnable);
performanceAnalyzerController.updateThreadContentionMonitoringState(
shouldEnable);
} else {
// Disabling Performance Analyzer should disable the RCA framework as well.
if (!shouldEnable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.fasterxml.jackson.module.paranamer.ParanamerModule;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.After;
import org.junit.Before;
Expand Down
Loading