Skip to content

Commit

Permalink
Update configFilePath location (#172)
Browse files Browse the repository at this point in the history
Signed-off-by: sruti1312 <srutiparthiban@gmail.com>
  • Loading branch information
sruti1312 authored Apr 27, 2022
1 parent 189f66d commit 00eac3f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
11 changes: 9 additions & 2 deletions bin/performance-analyzer-agent
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ fi
echo "Using JAVA_HOME: $JAVA_HOME"
export JAVA_HOME=$JAVA_HOME

if [[ -z "$OPENSEARCH_PATH_CONF" ]]; then
echo "OPENSEARCH_PATH_CONF needs to be set."
exit 1
fi

echo "Using OPENSEARCH_PATH_CONF: $OPENSEARCH_PATH_CONF"

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/config/log4j2.xml\ -XX:+ExitOnOutOfMemoryError
export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dopensearch.path.conf=$OPENSEARCH_PATH_CONF\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca/config/log4j2.xml\ -XX:+ExitOnOutOfMemoryError
exec $OPENSEARCH_HOME/performance-analyzer-rca/bin/performance-analyzer-rca
else
echo 'Starting deamon'
export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca/config/log4j2.xml\ -XX:+ExitOnOutOfMemoryError
export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dopensearch.path.conf=$OPENSEARCH_PATH_CONF\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca/config/log4j2.xml\ -XX:+ExitOnOutOfMemoryError
exec $OPENSEARCH_HOME/performance-analyzer-rca/bin/performance-analyzer-rca &

pid=$!
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ RUN yum update -y && \
COPY CENTOS_LICENSING.txt /root
COPY --from=prep_open_search_files --chown=1000:0 /opt/jdk-11.0.1 /opt/jdk-11.0.1
ENV OPENSEARCH_JAVA_HOME /opt/jdk-11.0.1
ENV OPENSEARCH_PATH_CONF /usr/share/opensearch/config

# Replace OpenJDK's built-in CA certificate keystore with the one from the OS
# vendor. The latter is superior in several ways.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.logging.log4j.Logger;
import org.opensearch.performanceanalyzer.PerformanceAnalyzerApp;
import org.opensearch.performanceanalyzer.config.PluginSettings;
import org.opensearch.performanceanalyzer.core.Util;
import org.opensearch.performanceanalyzer.metrics.MetricsConfiguration;
import org.opensearch.performanceanalyzer.rca.Version;
import org.opensearch.performanceanalyzer.rca.formatter.StatsCollectorFormatter;
Expand Down Expand Up @@ -146,13 +145,15 @@ private static Map<String, String> loadMetadata(String fileLocation) {

try (InputStream input =
new FileInputStream(
Util.PLUGIN_LOCATION
+ PluginSettings.CONFIG_FILES_PATH
+ fileLocation); ) {
PluginSettings.instance().getConfigFolderPath() + fileLocation); ) {
// load properties file
props.load(input);
} catch (Exception ex) {
GENERAL_LOG.error("Error in loading metadata for fileLocation: {}", fileLocation);
GENERAL_LOG.error(
"Error in loading metadata for folderLocation: {}, fileLocation: {}",
PluginSettings.instance().getConfigFolderPath(),
fileLocation,
ex);
}

props.forEach((key, value) -> retVal.put((String) key, (String) value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ public class PluginSettings {

private static PluginSettings instance;
public static final String CONFIG_FILES_PATH = "config/";
private static final String DEFAULT_CONFIG_FILE_PATH =
public static final String DEFAULT_CONFIG_FOLDER_PATH =
OPENSEARCH_HOME
+ File.separator
+ "config"
+ File.separator
+ "opensearch-performance-analyzer"
+ File.separator
+ "performance-analyzer.properties";
+ File.separator;
private static final String DEFAULT_CONFIG_FILE_PATH =
DEFAULT_CONFIG_FOLDER_PATH + "performance-analyzer.properties";
private static final String METRICS_LOCATION_KEY = "metrics-location";
private static final String METRICS_LOCATION_DEFAULT = "/dev/shm/performanceanalyzer/";
private static final String DELETION_INTERVAL_KEY = "metrics-deletion-interval";
Expand Down Expand Up @@ -64,6 +65,7 @@ public class PluginSettings {

private boolean httpsEnabled;
private Properties settings;
private final String configFolderPath;
private final String configFilePath;

/**
Expand All @@ -79,6 +81,10 @@ public class PluginSettings {
Util.invokePrivilegedAndLogError(PluginSettings::createInstance);
}

public String getConfigFolderPath() {
return configFolderPath;
}

public String getMetricsLocation() {
return metricsLocation;
}
Expand Down Expand Up @@ -170,9 +176,12 @@ private PluginSettings(String cfPath) {
rpcPort = RPC_DEFAULT_PORT;
webServicePort = WEBSERVICE_DEFAULT_PORT;
if (cfPath == null || cfPath.isEmpty()) {
this.configFolderPath = DEFAULT_CONFIG_FOLDER_PATH;
this.configFilePath = DEFAULT_CONFIG_FILE_PATH;
} else {
this.configFilePath = cfPath;
this.configFolderPath =
cfPath + File.separator + "opensearch-performance-analyzer" + File.separator;
this.configFilePath = configFolderPath + "performance-analyzer.properties";
}

settings = new Properties();
Expand Down Expand Up @@ -216,7 +225,7 @@ public static PluginSettings instance() {
}

private static void createInstance() {
String cfPath = System.getProperty("configFilePath");
String cfPath = System.getProperty("opensearch.path.conf");
instance = new PluginSettings(cfPath);
}

Expand Down

0 comments on commit 00eac3f

Please sign in to comment.