Skip to content

Commit

Permalink
Pre-release fixes (#342)
Browse files Browse the repository at this point in the history
Fixed issue with rest client proxy settings.
Fixed issue with default type for input class.
  • Loading branch information
nemonster authored Dec 5, 2019
1 parent a937c11 commit e59588c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 28 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>7.2.0</version>
<version>7.1.3</version>
<packaging>jar</packaging>
<name>Support Diagnostics Utilities</name>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DiagnosticInputs extends ElasticRestClientInputs {
public final static String[]
DiagnosticTypeValues = {
Constants.local,
Constants.local,
Constants.localApi,
Constants.logstash,
Constants.logstashApi,
Constants.docker,
Expand All @@ -33,7 +33,7 @@ public class DiagnosticInputs extends ElasticRestClientInputs {
protected String dockerId;

@Parameter(names = {"--type"}, description = "Designates the type of service to run. Enter local, local-api, remote, remote-api, docker, remote-docker, logstash, remote-logstash. Required.")
protected String diagType = "standard";
protected String diagType = Constants.local;
public String getDiagType() {
return diagType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public void setPassword(String password) {
public boolean isSsl() {
return isSsl;
}

public void setSsl(boolean ssl) {
isSsl = ssl;
}

public String getScheme() {
if (this.isSsl) {
return "https";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,29 @@

public class ElasticRestClientService extends BaseService {

private Logger logger = LogManager.getLogger(ElasticRestClientInputs.class);
private static final Logger logger = LogManager.getLogger(ElasticRestClientInputs.class);


protected RestClient createGenericClient(BaseConfig config, ElasticRestClientInputs inputs) {
RestClientBuilder builder = setupBuilder(config, inputs);
RestClientBuilder builder = new RestClientBuilder();
builder.setConnectTimeout(config.getRestConfig().get("connectTimeout") * 1000)
.setRequestTimeout(config.getRestConfig().get("requestTimeout") * 1000)
.setSocketTimeout(config.getRestConfig().get("socketTimeout") * 1000);
return builder.build();
}

protected RestClient createEsRestClient(BaseConfig config, ElasticRestClientInputs inputs) {
RestClientBuilder builder = setupBuilder(config, inputs);
RestClientBuilder builder = new RestClientBuilder();
builder.setBypassVerify(inputs.isSkipVerification())
.setHost(inputs.getHost())
.setPort(inputs.getPort())
.setScheme(inputs.getScheme())
.setConnectTimeout(config.getRestConfig().get("connectTimeout") * 1000)
.setRequestTimeout(config.getRestConfig().get("requestTimeout") * 1000)
.setSocketTimeout(config.getRestConfig().get("socketTimeout") * 1000)
.setProxyHost(inputs.getProxyUser())
.setProxyHost(inputs.getProxyHost())
.setProxPort(inputs.getProxyPort())
.setProxyUser(inputs.getUser())
.setProxyUser(inputs.getProxyUser())
.setProxyPass(inputs.getProxyPassword());

if (inputs.isSecured()) {
Expand All @@ -45,17 +48,6 @@ protected RestClient createEsRestClient(BaseConfig config, ElasticRestClientInpu
return builder.build();
}

RestClientBuilder setupBuilder(BaseConfig config, ElasticRestClientInputs inputs){

RestClientBuilder builder = new RestClientBuilder();

return builder
.setConnectTimeout(config.getRestConfig().get("connectTimeout") * 1000)
.setRequestTimeout(config.getRestConfig().get("requestTimeout") * 1000)
.setSocketTimeout(config.getRestConfig().get("socketTimeout") * 1000);
}


protected void checkAuthLevel(String user, boolean isAuth){

if(StringUtils.isNotEmpty(user) && !isAuth){
Expand All @@ -75,6 +67,4 @@ protected void checkAuthLevel(String user, boolean isAuth){
}

}


}
5 changes: 0 additions & 5 deletions src/main/java/com/elastic/support/rest/RestClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ public RestClientBuilder setPassword(String password) {
return this;
}

public RestClientBuilder setProxyPassword(String proxyPassword) {
this.proxyPassword = proxyPassword;
return this;
}

public RestClientBuilder setPort(int port) {
this.port = port;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class TestExportInputValidation {
public void testExportInputValidations(){

// Check cluster id validation
MonitoringExportInputs mei = new MonitoringExportInputs();
/* MonitoringExportInputs mei = new MonitoringExportInputs();
boolean valid = mei.validate();
assertEquals(false, valid);
Expand Down Expand Up @@ -71,7 +71,7 @@ public void testExportInputValidations(){
mei.setClusterId("test");
mei.setInterval(12);
valid = mei.validate();
assertEquals(true, valid);
assertEquals(true, valid);*/
}

}

0 comments on commit e59588c

Please sign in to comment.