Skip to content

Commit

Permalink
Fix/http scheme config (NovatecConsulting#27)
Browse files Browse the repository at this point in the history
* Update InfluxDBConfig.java

Adding HTTP scheme to support https

* Update build.gradle

Version upgrade for https scheme fix

* Update InfluxDBConfig.java

fix bad copy paste

* Added a setter for http scheme

* fix typo in assignment
  • Loading branch information
jkdihenkar authored and AlexanderWert committed Nov 21, 2018
1 parent 2370d58 commit 5a809f2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'java'
apply plugin: 'eclipse'

sourceCompatibility = 1.7
version = '1.2x'
version = '1.2.1'
def title = 'JMeterInfluxDBListener'

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class InfluxDBConfig {
*/
public static final String DEFAULT_RETENTION_POLICY = "autogen";

/**
* Default http scheme name.
*/
public static final String DEFAULT_HTTP_SCHEME = "http";

/**
* Default port.
*/
Expand Down Expand Up @@ -55,6 +60,11 @@ public class InfluxDBConfig {
* Config key for retention policy name.
*/
public static final String KEY_RETENTION_POLICY = "retentionPolicy";

/**
* Config key for http scheme.
*/
public static final String KEY_HTTP_SCHEME = "influxHTTPScheme";

/**
* InfluxDB Host.
Expand Down Expand Up @@ -85,6 +95,11 @@ public class InfluxDBConfig {
* InfluxDB Port.
*/
private int influxDBPort;

/**
* InfluxDB database retention policy.
*/
private String influxHTTPScheme;

public InfluxDBConfig(BackendListenerContext context) {
String influxDBHost = context.getParameter(KEY_INFLUX_DB_HOST);
Expand Down Expand Up @@ -113,6 +128,13 @@ public InfluxDBConfig(BackendListenerContext context) {
influxRetentionPolicy = DEFAULT_RETENTION_POLICY;
}
setInfluxRetentionPolicy(influxRetentionPolicy);

String influxHTTPScheme = context.getParameter(KEY_HTTP_SCHEME, DEFAULT_HTTP_SCHEME);
if (StringUtils.isEmpty(influxHTTPScheme)) {
influxHTTPScheme = DEFAULT_HTTP_SCHEME;
}
// TODO: no checks but should be only "http" and "https"
setInfluxHTTPScheme(influxHTTPScheme);
}

/**
Expand All @@ -121,7 +143,7 @@ public InfluxDBConfig(BackendListenerContext context) {
* @return influxDB URL.
*/
public String getInfluxDBURL() {
return "http://" + influxDBHost + ":" + influxDBPort;
return influxHTTPScheme + "://" + influxDBHost + ":" + influxDBPort;
}

/**
Expand Down Expand Up @@ -199,6 +221,14 @@ public void setInfluxRetentionPolicy(String influxRetentionPolicy) {
this.influxRetentionPolicy = influxRetentionPolicy;
}

/**
* @param influxHTTPScheme
* the influxHTTPScheme to set
*/
public void setInfluxHTTPScheme(String influxHTTPScheme) {
this.influxHTTPScheme = influxHTTPScheme;
}

/**
* @return the influxDBPort
*/
Expand Down

0 comments on commit 5a809f2

Please sign in to comment.