diff --git a/docs/theodolite-benchmarks/load-generator.md b/docs/theodolite-benchmarks/load-generator.md index e0d35332e97452d971ee91290d167d4e5087f796..8fefa19617263784cdf102d91e93ad492adbe63c 100644 --- a/docs/theodolite-benchmarks/load-generator.md +++ b/docs/theodolite-benchmarks/load-generator.md @@ -62,6 +62,7 @@ The prebuilt container images can be configured with the following environment v | `PERIOD_MS` | The time in milliseconds between generating two messages for the same sensor. With our Theodolite benchmarks, we apply an [open workload model](https://www.usenix.org/legacy/event/nsdi06/tech/full_papers/schroeder/schroeder.pdf) in which new messages are generated at a fixed rate, without considering the think time of the target server nor the time required for generating a message. | 1000 | | `VALUE` | The constant `valueInW` of an `ActivePowerRecord`. | 10 | | `THREADS` | Number of worker threads used to generate the load. | 4 | +| `DISABLE_DNS_CACHING` | Set to `true` to disable DNS caching by the underlying JVM. You might want to do so when generating load via HTTP that should be sent to different target instances. | `false` | Please note that there are some additional configuration options for benchmark [UC4's load generator](hhttps://github.com/cau-se/theodolite/blob/master/theodolite-benchmarks/uc4-load-generator/src/main/java/rocks/theodolite/benchmarks/uc4/loadgenerator/LoadGenerator.java). diff --git a/theodolite-benchmarks/load-generator-commons/src/main/java/rocks/theodolite/benchmarks/loadgenerator/ConfigurationKeys.java b/theodolite-benchmarks/load-generator-commons/src/main/java/rocks/theodolite/benchmarks/loadgenerator/ConfigurationKeys.java index 30735a561302ff3fc2dce564aa98d1d1657164a1..3ffa7a647a308d9a8fde210ff54f32b177604c36 100644 --- a/theodolite-benchmarks/load-generator-commons/src/main/java/rocks/theodolite/benchmarks/loadgenerator/ConfigurationKeys.java +++ b/theodolite-benchmarks/load-generator-commons/src/main/java/rocks/theodolite/benchmarks/loadgenerator/ConfigurationKeys.java @@ -23,6 +23,8 @@ public final class ConfigurationKeys { public static final String THREADS = "THREADS"; + public static final String DISABLE_DNS_CACHING = "DISABLE_DNS_CACHING"; + public static final String TARGET = "TARGET"; public static final String KAFKA_BOOTSTRAP_SERVERS = "KAFKA_BOOTSTRAP_SERVERS"; @@ -45,6 +47,7 @@ public final class ConfigurationKeys { public static final String PUBSUB_EMULATOR_HOST = "PUBSUB_EMULATOR_HOST"; + private ConfigurationKeys() {} } diff --git a/theodolite-benchmarks/load-generator-commons/src/main/java/rocks/theodolite/benchmarks/loadgenerator/EnvVarLoadGeneratorFactory.java b/theodolite-benchmarks/load-generator-commons/src/main/java/rocks/theodolite/benchmarks/loadgenerator/EnvVarLoadGeneratorFactory.java index 7123cfe540b8a9010e6ae9fffc25dade5161eec9..9faa4b3bddb7b59992548d3494213f12bc21b79b 100644 --- a/theodolite-benchmarks/load-generator-commons/src/main/java/rocks/theodolite/benchmarks/loadgenerator/EnvVarLoadGeneratorFactory.java +++ b/theodolite-benchmarks/load-generator-commons/src/main/java/rocks/theodolite/benchmarks/loadgenerator/EnvVarLoadGeneratorFactory.java @@ -13,7 +13,17 @@ class EnvVarLoadGeneratorFactory { private static final Logger LOGGER = LoggerFactory.getLogger(EnvVarLoadGeneratorFactory.class); + public static final boolean DISABLE_DNS_CACHING_DEFAULT = false; + public LoadGenerator create(final LoadGenerator loadGeneratorTemplate) { + + final boolean disableDnsCaching = Boolean.parseBoolean(Objects.requireNonNullElse( + System.getenv(ConfigurationKeys.DISABLE_DNS_CACHING), + Boolean.toString(DISABLE_DNS_CACHING_DEFAULT))); + if (disableDnsCaching) { + this.disableDnsCaching(); + } + final int numSensors = Integer.parseInt(Objects.requireNonNullElse( System.getenv(ConfigurationKeys.NUM_SENSORS), Integer.toString(LoadGenerator.NUMBER_OF_KEYS_DEFAULT))); @@ -135,4 +145,9 @@ class EnvVarLoadGeneratorFactory { return recordSender; } + private void disableDnsCaching() { + LOGGER.info("Disable DNS caching."); + java.security.Security.setProperty("networkaddress.cache.ttl", "0"); + } + }