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

Add some documentation

parent 7bd7925f
No related branches found
No related tags found
No related merge requests found
package theodolite.commons.workloadgeneration.functions; package theodolite.commons.workloadgeneration.functions;
/**
* Interface representing a message generator, which sends messages for given keys to some
* destination.
*/
@FunctionalInterface @FunctionalInterface
public interface MessageGenerator { public interface MessageGenerator {
......
package theodolite.commons.workloadgeneration.functions; package theodolite.commons.workloadgeneration.functions;
/** /**
* This interface describes a function that takes meta information from a string (e.g. an ID) and * This interface describes a function that takes meta information from a string key and produces an
* produces an object of type T. * object of type T.
* *
* @param <T> the type of the objects that will be generated by the function. * @param <T> the type of the objects that will be generated by the function.
*/ */
......
...@@ -4,6 +4,10 @@ import java.util.Properties; ...@@ -4,6 +4,10 @@ import java.util.Properties;
import theodolite.commons.workloadgeneration.communication.kafka.KafkaRecordSender; import theodolite.commons.workloadgeneration.communication.kafka.KafkaRecordSender;
import titan.ccp.model.records.ActivePowerRecord; import titan.ccp.model.records.ActivePowerRecord;
/**
* A factory for creating {@link MessageGenerator}s that creates Titan {@link ActivePowerRecord}s
* and sends them via Kafka.
*/
public final class TitanMessageGeneratorFactory { public final class TitanMessageGeneratorFactory {
private final RecordSender<ActivePowerRecord> recordSender; private final RecordSender<ActivePowerRecord> recordSender;
...@@ -12,12 +16,19 @@ public final class TitanMessageGeneratorFactory { ...@@ -12,12 +16,19 @@ public final class TitanMessageGeneratorFactory {
this.recordSender = recordSender; this.recordSender = recordSender;
} }
/**
* Create a {@link MessageGenerator} that generates Titan {@link ActivePowerRecord}s with a
* constant value.
*/
public MessageGenerator forConstantValue(final double value) { public MessageGenerator forConstantValue(final double value) {
return MessageGenerator.from( return MessageGenerator.from(
sensor -> new ActivePowerRecord(sensor, System.currentTimeMillis(), value), sensor -> new ActivePowerRecord(sensor, System.currentTimeMillis(), value),
this.recordSender); this.recordSender);
} }
/**
* Create a new TitanMessageGeneratorFactory for the given Kafka configuration.
*/
public static TitanMessageGeneratorFactory withKafkaConfig( public static TitanMessageGeneratorFactory withKafkaConfig(
final String bootstrapServers, final String bootstrapServers,
final String topic, final String topic,
...@@ -25,6 +36,9 @@ public final class TitanMessageGeneratorFactory { ...@@ -25,6 +36,9 @@ public final class TitanMessageGeneratorFactory {
return withKafkaConfig(bootstrapServers, topic, schemaRegistryUrl, new Properties()); return withKafkaConfig(bootstrapServers, topic, schemaRegistryUrl, new Properties());
} }
/**
* Create a new TitanMessageGeneratorFactory for the given Kafka configuration.
*/
public static TitanMessageGeneratorFactory withKafkaConfig( public static TitanMessageGeneratorFactory withKafkaConfig(
final String bootstrapServers, final String bootstrapServers,
final String topic, final String topic,
......
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