Skip to content

Commit

Permalink
Add Content-Type for PA disable
Browse files Browse the repository at this point in the history
  • Loading branch information
khushbr committed Sep 6, 2023
1 parent 7451fc4 commit 8696f57
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 208 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ dependencies {
}
def versions = VersionProperties.versions

def commonslangVersion = "${versions.commonslang}"
def jacksonVersion = "${versions.jackson}"
def jacksonDataBindVersion = "${versions.jackson_databind}"
def nettyVersion = "${versions.netty}"
Expand All @@ -349,7 +350,7 @@ dependencies {
implementation "org.opensearch:performance-analyzer-commons:1.0.0-SNAPSHOT"
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: "${log4jVersion}"
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: "${log4jVersion}"
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: "${commonslangVersion}"
implementation group: 'commons-io', name: 'commons-io', version: '2.7'
implementation group: 'com.google.errorprone', name: 'error_prone_annotations', version: '2.9.0'
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: "${protobufVersion}"
Expand Down
202 changes: 0 additions & 202 deletions licenses/commons-lang3-LICENSE.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ public static void disablePA() throws InterruptedException {
stream.writeBytes(PA_DISABLE_PAYLOAD);
stream.flush();
stream.close();
LOG.info(
"PA Disable Response: "
+ connection.getResponseCode()
+ " "
+ connection.getResponseMessage());
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
return;
}
} catch (Exception e) {
LOG.info("PA Disable Request failed: " + e.getMessage(), e);
LOG.error("PA Disable Request failed: " + e.getMessage(), e);
} finally {
if (connection != null) {
connection.disconnect();
Expand All @@ -46,15 +51,16 @@ public static void disablePA() throws InterruptedException {
--retryCount;
Thread.sleep((int) (5000 * (Math.random() * 2) + 100));
}
throw new RuntimeException("Failed to disable PA after " + retryCount + " attempts");
throw new RuntimeException("Failed to disable PA after 3 attempts");
}

private static HttpURLConnection createHTTPConnection(String path, HttpMethod httpMethod) {
try {
String endPoint = "https://localhost:9200" + path;
String endPoint = "http://localhost:9200" + path;
URL endpointUrl = new URL(endPoint);
HttpURLConnection connection = (HttpURLConnection) endpointUrl.openConnection();
connection.setRequestMethod(httpMethod.toString());
connection.setRequestProperty("Content-Type", "application/json");

connection.setConnectTimeout(TIMEOUT_MILLIS);
connection.setReadTimeout(TIMEOUT_MILLIS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private static void handleReaderThreadFailed() {
StatsCollector.instance()
.logException(StatExceptionCode.READER_ERROR_PA_DISABLE_SUCCESS);
} catch (Throwable e) {
LOG.info(e.getMessage());
LOG.error(e.getMessage());
StatsCollector.instance()
.logException(StatExceptionCode.READER_ERROR_PA_DISABLE_FAILED);
} finally {
Expand All @@ -298,7 +298,7 @@ private static void handleReaderThreadFailed() {
}

private static void cleanupAndExit() {
LOG.info("Reader thread not coming up successfully - Shutting down RCA Runtime");
LOG.error("Reader thread not coming up successfully - Shutting down RCA Runtime");
StatsCollector.instance().logException(StatExceptionCode.READER_ERROR_RCA_AGENT_STOPPED);

// Terminate Java Runtime, executes {@link #shutDownGracefully(ClientServers clientServers)}
Expand Down

0 comments on commit 8696f57

Please sign in to comment.