From 60503b7372c9da28a5e2815490b41aba5ac85306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Henning?= <soeren.henning@email.uni-kiel.de> Date: Tue, 18 Jan 2022 21:21:34 +0100 Subject: [PATCH] Fix QA issues --- .../commons/workloadgeneration/HttpRecordSender.java | 6 ++++-- .../commons/workloadgeneration/LoadGenerator.java | 2 +- .../commons/workloadgeneration/LoadGeneratorTarget.java | 6 +++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/HttpRecordSender.java b/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/HttpRecordSender.java index baa230b76..6b7a5db06 100644 --- a/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/HttpRecordSender.java +++ b/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/HttpRecordSender.java @@ -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); diff --git a/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/LoadGenerator.java b/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/LoadGenerator.java index 206a7acd2..9e467864f 100644 --- a/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/LoadGenerator.java +++ b/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/LoadGenerator.java @@ -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) { diff --git a/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/LoadGeneratorTarget.java b/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/LoadGeneratorTarget.java index 567c0388a..086e4de36 100644 --- a/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/LoadGeneratorTarget.java +++ b/theodolite-benchmarks/load-generator-commons/src/main/java/theodolite/commons/workloadgeneration/LoadGeneratorTarget.java @@ -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)) -- GitLab