Skip to content
Snippets Groups Projects
Commit 60503b73 authored by Sören Henning's avatar Sören Henning
Browse files

Fix QA issues

parent 406da094
No related branches found
No related tags found
1 merge request!202Add option to generate load via HTTP
Pipeline #6069 passed
......@@ -21,6 +21,8 @@ import org.slf4j.LoggerFactory;
*/
public class HttpRecordSender<T extends SpecificRecord> implements RecordSender<T> {
private static final int HTTP_OK = 200;
private static final Logger LOGGER = LoggerFactory.getLogger(HttpRecordSender.class);
private final Gson gson = new Gson();
......@@ -39,7 +41,7 @@ public class HttpRecordSender<T extends SpecificRecord> implements RecordSender<
* @param uri the {@link URI} records should be sent to
*/
public HttpRecordSender(final URI uri) {
this(uri, true, List.of(200));
this(uri, true, List.of(HTTP_OK));
}
/**
......@@ -70,7 +72,7 @@ public class HttpRecordSender<T extends SpecificRecord> implements RecordSender<
this.httpClient.sendAsync(request, bodyHandler)
.whenComplete((response, exception) -> {
if (exception != null) { // NOPMD
LOGGER.warn("Couldn't send request to {}.", this.uri, exception);
LOGGER.warn("Couldn't send request to {}.", this.uri, exception); // NOPMD false-p.
} else if (!this.validStatusCodes.contains(response.statusCode())) { // NOPMD
LOGGER.warn("Received status code {} for request to {}.", response.statusCode(),
this.uri);
......
......@@ -140,7 +140,7 @@ public final class LoadGenerator {
final LoadGeneratorTarget target = LoadGeneratorTarget.from(
Objects.requireNonNullElse(System.getenv(ConfigurationKeys.TARGET),
TARGET_DEFAULT.value));
TARGET_DEFAULT.getValue()));
final RecordSender<ActivePowerRecord> recordSender; // NOPMD
if (target == LoadGeneratorTarget.KAFKA) {
......
......@@ -6,12 +6,16 @@ enum LoadGeneratorTarget {
KAFKA("kafka"), HTTP("http");
final String value;
private final String value;
LoadGeneratorTarget(final String value) {
this.value = value;
}
String getValue() {
return this.value;
}
static LoadGeneratorTarget from(final String value) {
return Stream.of(LoadGeneratorTarget.values())
.filter(t -> t.value.equals(value))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment