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 baa230b76e3cfa5d166c4be396f7685dc36e7487..6b7a5db067c8117f046aa0ff1c6f5d56c35c4321 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 206a7acd2eb597a55c3c0429dcee11c29c7c88db..9e467864f89f746069aa3ca06aa087955ebc1575 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 567c0388a49e42840a9e1eab0a448231669f2e47..086e4de36301693c6873016122a47709b858a0d4 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))