Skip to content

Commit

Permalink
Added try catch block for createContext in http
Browse files Browse the repository at this point in the history
Signed-off-by: Atharva Sharma <[email protected]>
  • Loading branch information
atharvasharma61 committed Sep 10, 2024
1 parent 75579f7 commit 1ea3e3f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 1ea3e3f

Please sign in to comment.