Skip to content
Snippets Groups Projects
Commit 47e43546 authored by Simon Ehrenstein's avatar Simon Ehrenstein
Browse files

Refactor workload generators using wg common lib

parent 94a3999e
No related branches found
No related tags found
1 merge request!6Add Distributed Workload Generator
package common.messages;
import kieker.common.record.IMonitoringRecord;
/*
* Wrapper class for messages within the messaging system.
*/
public class OutputMessage<T extends IMonitoringRecord> {
private final String key;
private final T value;
/***
* Create a new Message.
*
* @param key the key of the message.
* @param value the value of the message.
*/
public OutputMessage(final String key, final T value) {
super();
this.key = key;
this.value = value;
}
public String getKey() {
return this.key;
}
public T getValue() {
return this.value;
}
}
package common.misc;
import common.functions.MessageGenerator;
import common.messages.OutputMessage;
import kieker.common.record.IMonitoringRecord;
public class WorkloadEntity<T extends IMonitoringRecord> {
......@@ -13,7 +12,7 @@ public class WorkloadEntity<T extends IMonitoringRecord> {
this.generator = generator;
}
public OutputMessage<T> generateMessage() {
public T generateMessage() {
return this.generator.generateMessage(this.key);
}
}
......@@ -9,7 +9,6 @@ import org.apache.kafka.common.serialization.StringSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import common.functions.Transport;
import common.messages.OutputMessage;
import kieker.common.record.IMonitoringRecord;
import titan.ccp.common.kieker.kafka.IMonitoringRecordSerde;
......@@ -84,9 +83,8 @@ public class KafkaRecordSender<T extends IMonitoringRecord> implements Transport
}
@Override
public void transport(final OutputMessage<T> message) {
System.out.println(message.getKey());
this.write(message.getValue());
public void transport(final T message) {
this.write(message);
}
}
......@@ -143,8 +143,10 @@ public class WorkloadDistributor {
WorkloadDefinition.fromString(new String(bytes, StandardCharsets.UTF_8));
if (worker.getId() > declaration.getNumberOfWorkers() - 1) {
throw new IllegalStateException("Worker with id " + worker.getId()
+ " was too slow and is therefore not participating in the workload generation.");
LOGGER.warn("Worker with id {} was to slow and is therefore in idle state",
worker.getId());
WorkloadDistributor.this.workerAction.accept(new WorkloadDefinition(new KeySpace(0), 0),
worker); // this worker generates no workload
} else {
WorkloadDistributor.this.workerAction.accept(declaration, worker);
}
......
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