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

Prevent unecessary objects creation

parent f0cf85e8
No related branches found
No related tags found
1 merge request!225Add option to generate load via Google PubSub
Pipeline #6653 passed
......@@ -13,7 +13,7 @@ class EnvVarLoadGeneratorFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(EnvVarLoadGeneratorFactory.class);
public LoadGenerator create() {
public LoadGenerator create(final LoadGenerator loadGeneratorTemplate) {
final int numSensors = Integer.parseInt(Objects.requireNonNullElse(
System.getenv(ConfigurationKeys.NUM_SENSORS),
Integer.toString(LoadGenerator.NUMBER_OF_KEYS_DEFAULT)));
......@@ -27,7 +27,7 @@ class EnvVarLoadGeneratorFactory {
System.getenv(ConfigurationKeys.THREADS),
Integer.toString(LoadGenerator.THREADS_DEFAULT)));
return LoadGenerator.fromDefaults()
return loadGeneratorTemplate
.setClusterConfig(this.buildClusterConfig())
.setLoadDefinition(new WorkloadDefinition(
new KeySpace(LoadGenerator.SENSOR_PREFIX_DEFAULT, numSensors),
......
......@@ -102,7 +102,7 @@ public final class LoadGenerator {
* Create a basic {@link LoadGenerator} from environment variables.
*/
public static LoadGenerator fromEnvironment() {
return new EnvVarLoadGeneratorFactory().create();
return new EnvVarLoadGeneratorFactory().create(new LoadGenerator());
}
}
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