Skip to content
Snippets Groups Projects
Commit f643036f authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

Merge branch 'master' of git.se.informatik.uni-kiel.de:she/theodolite into introduce-actionCommands

parents 276d9ebb 7c2acb21
No related branches found
No related tags found
1 merge request!201Introduce action commands
......@@ -4,46 +4,33 @@ import java.util.Properties;
import titan.ccp.model.records.ActivePowerRecord;
/**
* A factory for creating {@link MessageGenerator}s that creates Titan {@link ActivePowerRecord}s
* and sends them via Kafka.
* A factory for creating {@link KafkaRecordSender}s that sends Titan {@link ActivePowerRecord}s.
*/
public final class TitanMessageGeneratorFactory {
public final class TitanKafkaSenderFactory {
private final RecordSender<ActivePowerRecord> recordSender;
private TitanMessageGeneratorFactory(final RecordSender<ActivePowerRecord> recordSender) {
this.recordSender = recordSender;
}
private TitanKafkaSenderFactory() {}
/**
* Create a {@link MessageGenerator} that generates Titan {@link ActivePowerRecord}s with a
* constant value.
* Create a new KafkaRecordSender for {@link ActivePowerRecord}s for the given Kafka
* configuration.
*/
public MessageGenerator forConstantValue(final double value) {
return MessageGenerator.from(
sensor -> new ActivePowerRecord(sensor, System.currentTimeMillis(), value),
this.recordSender);
}
/**
* Create a new TitanMessageGeneratorFactory for the given Kafka configuration.
*/
public static TitanMessageGeneratorFactory withKafkaConfig(
public static KafkaRecordSender<ActivePowerRecord> forKafkaConfig(
final String bootstrapServers,
final String topic,
final String schemaRegistryUrl) {
return withKafkaConfig(bootstrapServers, topic, schemaRegistryUrl, new Properties());
return forKafkaConfig(bootstrapServers, topic, schemaRegistryUrl, new Properties());
}
/**
* Create a new TitanMessageGeneratorFactory for the given Kafka configuration.
* Create a new KafkaRecordSender for {@link ActivePowerRecord}s for the given Kafka
* configuration.
*/
public static TitanMessageGeneratorFactory withKafkaConfig(
public static KafkaRecordSender<ActivePowerRecord> forKafkaConfig(
final String bootstrapServers,
final String topic,
final String schemaRegistryUrl,
final Properties properties) {
final KafkaRecordSender<ActivePowerRecord> kafkaRecordSender = KafkaRecordSender
return KafkaRecordSender
.<ActivePowerRecord>builder(
bootstrapServers,
topic,
......@@ -51,7 +38,5 @@ public final class TitanMessageGeneratorFactory {
.keyAccessor(r -> r.getIdentifier())
.timestampAccessor(r -> r.getTimestamp())
.build();
return new TitanMessageGeneratorFactory(kafkaRecordSender);
}
}
package theodolite.commons.workloadgeneration;
import titan.ccp.model.records.ActivePowerRecord;
/**
* A factory for creating {@link RecordGenerator}s that creates Titan {@link ActivePowerRecord}s.
*/
public final class TitanRecordGeneratorFactory {
private TitanRecordGeneratorFactory() {}
/**
* Create a {@link RecordGenerator} that generates Titan {@link ActivePowerRecord}s with a
* constant value.
*/
public static RecordGenerator<ActivePowerRecord> forConstantValue(final double value) {
return sensor -> new ActivePowerRecord(sensor, System.currentTimeMillis(), value);
}
}
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