From 176bd4112a7511dcf560ba1b8d052242d636bc45 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Thu, 24 Oct 2024 10:37:31 -0400 Subject: [PATCH] Include createContext fix Signed-off-by: Craig Perkins --- .../performanceanalyzer/core/Util.java | 2 +- .../rca/RcaController.java | 32 ++++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opensearch/performanceanalyzer/core/Util.java b/src/main/java/org/opensearch/performanceanalyzer/core/Util.java index 1f9a6641d..bebc19233 100644 --- a/src/main/java/org/opensearch/performanceanalyzer/core/Util.java +++ b/src/main/java/org/opensearch/performanceanalyzer/core/Util.java @@ -17,7 +17,7 @@ public class Util { private static final Logger LOG = LogManager.getLogger(Util.class); public static final String PA_BASE_URL = "/_plugins/_performanceanalyzer"; - public static final String LEGACY_OPENDISTRO_PA_BASE_URL = PA_BASE_URL; + public static final String LEGACY_OPENDISTRO_PA_BASE_URL = "/_opendistro/_performanceanalyzer"; public static final String METRICS_QUERY_URL = PA_BASE_URL + "/metrics"; public static final String LEGACY_OPENDISTRO_METRICS_QUERY_URL = diff --git a/src/main/java/org/opensearch/performanceanalyzer/rca/RcaController.java b/src/main/java/org/opensearch/performanceanalyzer/rca/RcaController.java index 144fc37cc..0a79a2203 100644 --- a/src/main/java/org/opensearch/performanceanalyzer/rca/RcaController.java +++ b/src/main/java/org/opensearch/performanceanalyzer/rca/RcaController.java @@ -527,14 +527,36 @@ public RCAScheduler getRcaScheduler() { } private void addRcaRequestHandler() { - httpServer.createContext(Util.RCA_QUERY_URL, queryRcaRequestHandler); - httpServer.createContext(Util.LEGACY_OPENDISTRO_RCA_QUERY_URL, queryRcaRequestHandler); + try { + httpServer.createContext(Util.RCA_QUERY_URL, queryRcaRequestHandler); + } catch (IllegalArgumentException e) { + LOG.error("unable to create context in http server for URL: " + Util.RCA_QUERY_URL); + } + + try { + httpServer.createContext(Util.LEGACY_OPENDISTRO_RCA_QUERY_URL, queryRcaRequestHandler); + } catch (IllegalArgumentException e) { + LOG.error( + "unable to create context in http server for URL: " + + Util.LEGACY_OPENDISTRO_RCA_QUERY_URL); + } } private void addActionsRequestHandler() { - httpServer.createContext(Util.ACTIONS_QUERY_URL, queryActionRequestHandler); - httpServer.createContext( - Util.LEGACY_OPENDISTRO_ACTIONS_QUERY_URL, queryActionRequestHandler); + try { + httpServer.createContext(Util.ACTIONS_QUERY_URL, queryActionRequestHandler); + } catch (IllegalArgumentException e) { + LOG.error("unable to create context in http server for URL: " + Util.ACTIONS_QUERY_URL); + } + + try { + httpServer.createContext( + Util.LEGACY_OPENDISTRO_ACTIONS_QUERY_URL, queryActionRequestHandler); + } catch (IllegalArgumentException e) { + LOG.error( + "unable to create context in http server for URL: " + + Util.LEGACY_OPENDISTRO_ACTIONS_QUERY_URL); + } } public void setDeliberateInterrupt() {