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

Add JavaDoc

parent df353559
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,9 @@ import java.util.Objects;
import java.util.Properties;
import org.apache.kafka.clients.producer.ProducerConfig;
/**
* A Theodolite load generator.
*/
public final class LoadGenerator {
private static final String SENSOR_PREFIX_DEFAULT = "s_";
......@@ -49,6 +52,9 @@ public final class LoadGenerator {
return this;
}
/**
* Run the constructed load generator until cancellation.
*/
public void run() {
Objects.requireNonNull(this.clusterConfig, "No cluster config set.");
Objects.requireNonNull(this.generatorConfig, "No generator config set.");
......@@ -64,6 +70,9 @@ public final class LoadGenerator {
runner.runBlocking();
}
/**
* Create a basic {@link LoadGenerator} from its default values.
*/
public static LoadGenerator fromDefaults() {
return new LoadGenerator()
.setClusterConfig(new ClusterConfig())
......@@ -79,6 +88,9 @@ public final class LoadGenerator {
.forConstantValue(VALUE_DEFAULT)));
}
/**
* Create a basic {@link LoadGenerator} from environment variables.
*/
public static LoadGenerator fromEnvironment() {
final String bootstrapServer = Objects.requireNonNullElse(
System.getenv(ConfigurationKeys.BOOTSTRAP_SERVER),
......@@ -137,9 +149,4 @@ public final class LoadGenerator {
.forConstantValue(value)));
}
public static void main(final String[] args) {
LoadGenerator.fromEnvironment()
.run();
}
}
package theodolite.commons.workloadgeneration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Configuration of a load generator.
*/
public class LoadGeneratorConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(LoadGeneratorConfig.class);
private final MessageGenerator messageGenerator;
private BeforeAction beforeAction = BeforeAction.doNothing();
private int threads = 1;
......@@ -17,10 +15,8 @@ public class LoadGeneratorConfig {
public LoadGeneratorConfig(
final MessageGenerator messageGenerator,
final BeforeAction beforeAction,
final int threads) {
this.messageGenerator = messageGenerator;
this.beforeAction = beforeAction;
this.threads = threads;
}
......
......@@ -7,6 +7,10 @@ import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A {@link LoadGeneratorExecution} represents the execution of load generator, i.e., it can be
* started and stopped.
*/
public class LoadGeneratorExecution {
private static final Logger LOGGER = LoggerFactory.getLogger(LoadGeneratorExecution.class);
......@@ -16,6 +20,10 @@ public class LoadGeneratorExecution {
private final MessageGenerator messageGenerator;
private final ScheduledExecutorService executor;
/**
* Create a new {@link LoadGeneratorExecution} for a given {@link WorkloadDefinition} and a
* {@link MessageGenerator}. Load is generated by the given number of threads.
*/
public LoadGeneratorExecution(
final WorkloadDefinition workloadDefinition,
final MessageGenerator messageGenerator,
......@@ -25,6 +33,9 @@ public class LoadGeneratorExecution {
this.executor = Executors.newScheduledThreadPool(threads);
}
/**
* Start the load generation and run it until it is stopped.
*/
public void start() {
LOGGER.info("Beginning of Experiment...");
LOGGER.info("Generating records for {} keys.",
......
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