From fe5dca4e7179d82d111a448b29e5490a58c3d2d0 Mon Sep 17 00:00:00 2001 From: Harold Xiao Date: Wed, 5 May 2021 11:09:53 -0700 Subject: [PATCH 1/3] Create conf directory if not exist --- .../config/PerformanceAnalyzerController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java b/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java index f9216ef5..5f6249fc 100644 --- a/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java +++ b/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java @@ -288,6 +288,10 @@ private void saveStateToConf(boolean featureEnabled, String fileName) { PerformanceAnalyzerPlugin.invokePrivileged( () -> { try { + Path destDir = Paths.get(getDataDirectory()); + if (!Files.exists(destDir)) { + Files.createDirectory(destDir); + } Files.write( Paths.get(getDataDirectory() + File.separator + fileName), String.valueOf(featureEnabled).getBytes()); From 433abff183486b4aeead7230d7a14c53e3cabd5d Mon Sep 17 00:00:00 2001 From: Harold Xiao Date: Wed, 5 May 2021 13:06:50 -0700 Subject: [PATCH 2/3] Add exception logger --- .../config/PerformanceAnalyzerController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java b/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java index 5f6249fc..b57b02ae 100644 --- a/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java +++ b/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java @@ -290,6 +290,7 @@ private void saveStateToConf(boolean featureEnabled, String fileName) { try { Path destDir = Paths.get(getDataDirectory()); if (!Files.exists(destDir)) { + StatsCollector.instance().logException(StatExceptionCode.CONFIG_DIR_NOT_FOUND); Files.createDirectory(destDir); } Files.write( From 27c36dcc521094018c36dcf3259b7b7f522e938b Mon Sep 17 00:00:00 2001 From: Harold Xiao Date: Wed, 5 May 2021 13:24:56 -0700 Subject: [PATCH 3/3] Add dependencies --- .../config/PerformanceAnalyzerController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java b/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java index b57b02ae..562bd0fe 100644 --- a/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java +++ b/src/main/java/com/amazon/opendistro/opensearch/performanceanalyzer/config/PerformanceAnalyzerController.java @@ -30,6 +30,8 @@ import com.amazon.opendistro.opensearch.performanceanalyzer.OpenSearchResources; import com.amazon.opendistro.opensearch.performanceanalyzer.PerformanceAnalyzerPlugin; import com.amazon.opendistro.opensearch.performanceanalyzer.collectors.ScheduledMetricCollectorsExecutor; +import com.amazon.opendistro.opensearch.performanceanalyzer.collectors.StatExceptionCode; +import com.amazon.opendistro.opensearch.performanceanalyzer.collectors.StatsCollector; import com.amazon.opendistro.opensearch.performanceanalyzer.config.overrides.ConfigOverridesWrapper; import com.amazon.opendistro.opensearch.performanceanalyzer.metrics.PerformanceAnalyzerMetrics; import java.io.File; @@ -290,7 +292,8 @@ private void saveStateToConf(boolean featureEnabled, String fileName) { try { Path destDir = Paths.get(getDataDirectory()); if (!Files.exists(destDir)) { - StatsCollector.instance().logException(StatExceptionCode.CONFIG_DIR_NOT_FOUND); + StatsCollector.instance() + .logException(StatExceptionCode.CONFIG_DIR_NOT_FOUND); Files.createDirectory(destDir); } Files.write(