Skip to content

Commit

Permalink
Merge pull request #211 from elastic/connection-message-fix
Browse files Browse the repository at this point in the history
Connection message fix
  • Loading branch information
nemonster authored Jul 20, 2018
2 parents 1e42956 + e8b6707 commit 63786b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.elasticsearch</groupId>
<artifactId>support-diagnostics</artifactId>
<version>6.4.2</version>
<version>6.4.3</version>
<packaging>jar</packaging>
<name>Support Diagnostics Utilities</name>
<properties>
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/elastic/support/diagnostics/Diagnostic.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public class Diagnostic {
try {
jc.parse(args);

if (inputs.isHelp()) {
jc.usage();
proceedToRun = false;
return;
}

if(! inputs.getDiagType().equalsIgnoreCase(Constants.LOCAL_DIAG)){
if(StringUtils.isEmpty(inputs.getHost())){
throw new RuntimeException("Inputs error: You must enter the hostname of a running node within the cluster, preferably on the host you are running the diagnostic from.");
Expand All @@ -44,12 +50,6 @@ public class Diagnostic {
throw new RuntimeException("Inputs error: If authenticating both username and password are required.");
}

if (inputs.isHelp()) {
jc.usage();
proceedToRun = false;
return;
}

// Set up the output directory
logger.info("Creating temp directory.");
createOutputDir(ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.elastic.support.diagnostics.chain.DiagnosticContext;
import com.elastic.support.util.JsonYamlUtils;
import com.elastic.support.util.RestExec;
import com.elastic.support.util.SystemProperties;
import com.fasterxml.jackson.databind.JsonNode;

import java.util.Map;
Expand All @@ -28,9 +29,9 @@ public boolean execute(DiagnosticContext context) {
context.setClusterName(clusterName);
String versionNumber = root.path("version").path("number").asText();
context.setVersion(versionNumber);

} catch (Exception e) {
logger.info("Error retrieving Elasticsearch version - unable to continue.. Please make sure the proper connection parameters were specified", e.getMessage());
logger.info(e.getMessage());
logger.info("Error retrieving Elasticsearch version - unable to continue.. Please make sure the proper connection parameters were specified.");
rc = false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/elastic/support/util/RestExec.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public String execBasic(String url) {
response = exec(url);
return getResponseString(response);
} catch (Exception e) {
throw new RuntimeException(e);
throw new RuntimeException(e.getMessage());
} finally {
HttpClientUtils.closeQuietly(response);
}
Expand Down Expand Up @@ -91,10 +91,10 @@ protected HttpResponse exec(String url) {
}
} catch (HttpHostConnectException e) {
logger.log(SystemProperties.DIAG, "Host connection error.", e);
throw new RuntimeException("Error connecting to host " + url, e);
throw new RuntimeException("Host connection error: " + e.getMessage() );
} catch (Exception e) {
logger.log(SystemProperties.DIAG, "Error executing query.", e);
throw new RuntimeException(e);
logger.log(SystemProperties.DIAG, "Query Execution Error", e);
throw new RuntimeException("Query Execution Error: " + e.getMessage());
}

}
Expand Down

0 comments on commit 63786b9

Please sign in to comment.