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

Fix code indentation

parent b86ba381
No related branches found
No related tags found
No related merge requests found
...@@ -23,15 +23,19 @@ public class LoadGenerator { ...@@ -23,15 +23,19 @@ public class LoadGenerator {
final String hierarchy = Objects.requireNonNullElse(System.getenv("HIERARCHY"), "deep"); final String hierarchy = Objects.requireNonNullElse(System.getenv("HIERARCHY"), "deep");
final int numNestedGroups = Integer final int numNestedGroups = Integer
.parseInt(Objects.requireNonNullElse(System.getenv("NUM_NESTED_GROUPS"), "1")); .parseInt(Objects.requireNonNullElse(System.getenv("NUM_NESTED_GROUPS"), "1"));
final int numSensor = Integer.parseInt(Objects.requireNonNullElse(System.getenv("NUM_SENSORS"), "1")); final int numSensor =
final int periodMs = Integer.parseInt(Objects.requireNonNullElse(System.getenv("PERIOD_MS"), "1000")); Integer.parseInt(Objects.requireNonNullElse(System.getenv("NUM_SENSORS"), "1"));
final int periodMs =
Integer.parseInt(Objects.requireNonNullElse(System.getenv("PERIOD_MS"), "1000"));
final int value = Integer.parseInt(Objects.requireNonNullElse(System.getenv("VALUE"), "10")); final int value = Integer.parseInt(Objects.requireNonNullElse(System.getenv("VALUE"), "10"));
final boolean sendRegistry = Boolean final boolean sendRegistry = Boolean
.parseBoolean(Objects.requireNonNullElse(System.getenv("SEND_REGISTRY"), "true")); .parseBoolean(Objects.requireNonNullElse(System.getenv("SEND_REGISTRY"), "true"));
final int threads = Integer.parseInt(Objects.requireNonNullElse(System.getenv("THREADS"), "4")); final int threads = Integer.parseInt(Objects.requireNonNullElse(System.getenv("THREADS"), "4"));
final String kafkaBootstrapServers = Objects.requireNonNullElse(System.getenv("KAFKA_BOOTSTRAP_SERVERS"), final String kafkaBootstrapServers =
Objects.requireNonNullElse(System.getenv("KAFKA_BOOTSTRAP_SERVERS"),
"localhost:9092"); "localhost:9092");
final String kafkaInputTopic = Objects.requireNonNullElse(System.getenv("KAFKA_INPUT_TOPIC"), "input"); final String kafkaInputTopic =
Objects.requireNonNullElse(System.getenv("KAFKA_INPUT_TOPIC"), "input");
final String kafkaBatchSize = System.getenv("KAFKA_BATCH_SIZE"); final String kafkaBatchSize = System.getenv("KAFKA_BATCH_SIZE");
final String kafkaLingerMs = System.getenv("KAFKA_LINGER_MS"); final String kafkaLingerMs = System.getenv("KAFKA_LINGER_MS");
final String kafkaBufferMemory = System.getenv("KAFKA_BUFFER_MEMORY"); final String kafkaBufferMemory = System.getenv("KAFKA_BUFFER_MEMORY");
...@@ -51,11 +55,13 @@ public class LoadGenerator { ...@@ -51,11 +55,13 @@ public class LoadGenerator {
throw new IllegalStateException(); throw new IllegalStateException();
} }
final List<String> sensors = sensorRegistry.getMachineSensors().stream().map(s -> s.getIdentifier()) final List<String> sensors =
sensorRegistry.getMachineSensors().stream().map(s -> s.getIdentifier())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (sendRegistry) { if (sendRegistry) {
final ConfigPublisher configPublisher = new ConfigPublisher(kafkaBootstrapServers, "configuration"); final ConfigPublisher configPublisher =
new ConfigPublisher(kafkaBootstrapServers, "configuration");
configPublisher.publish(Event.SENSOR_REGISTRY_CHANGED, sensorRegistry.toJson()); configPublisher.publish(Event.SENSOR_REGISTRY_CHANGED, sensorRegistry.toJson());
configPublisher.close(); configPublisher.close();
System.out.println("Configuration sent."); System.out.println("Configuration sent.");
...@@ -70,7 +76,8 @@ public class LoadGenerator { ...@@ -70,7 +76,8 @@ public class LoadGenerator {
kafkaProperties.compute(ProducerConfig.BATCH_SIZE_CONFIG, (k, v) -> kafkaBatchSize); kafkaProperties.compute(ProducerConfig.BATCH_SIZE_CONFIG, (k, v) -> kafkaBatchSize);
kafkaProperties.compute(ProducerConfig.LINGER_MS_CONFIG, (k, v) -> kafkaLingerMs); kafkaProperties.compute(ProducerConfig.LINGER_MS_CONFIG, (k, v) -> kafkaLingerMs);
kafkaProperties.compute(ProducerConfig.BUFFER_MEMORY_CONFIG, (k, v) -> kafkaBufferMemory); kafkaProperties.compute(ProducerConfig.BUFFER_MEMORY_CONFIG, (k, v) -> kafkaBufferMemory);
final KafkaRecordSender<ActivePowerRecord> kafkaRecordSender = new KafkaRecordSender<>(kafkaBootstrapServers, final KafkaRecordSender<ActivePowerRecord> kafkaRecordSender =
new KafkaRecordSender<>(kafkaBootstrapServers,
kafkaInputTopic, r -> r.getIdentifier(), r -> r.getTimestamp(), kafkaProperties); kafkaInputTopic, r -> r.getIdentifier(), r -> r.getTimestamp(), kafkaProperties);
final ScheduledExecutorService executor = Executors.newScheduledThreadPool(threads); final ScheduledExecutorService executor = Executors.newScheduledThreadPool(threads);
...@@ -89,14 +96,16 @@ public class LoadGenerator { ...@@ -89,14 +96,16 @@ public class LoadGenerator {
} }
private static int addChildren(final MutableAggregatedSensor parent, final int numChildren, final int lvl, private static int addChildren(final MutableAggregatedSensor parent, final int numChildren,
final int lvl,
final int maxLvl, int nextId) { final int maxLvl, int nextId) {
for (int c = 0; c < numChildren; c++) { for (int c = 0; c < numChildren; c++) {
if (lvl == maxLvl) { if (lvl == maxLvl) {
parent.addChildMachineSensor("s_" + nextId); parent.addChildMachineSensor("s_" + nextId);
nextId++; nextId++;
} else { } else {
final MutableAggregatedSensor newParent = parent.addChildAggregatedSensor("g_" + lvl + '_' + nextId); final MutableAggregatedSensor newParent =
parent.addChildAggregatedSensor("g_" + lvl + '_' + nextId);
nextId++; nextId++;
nextId = addChildren(newParent, numChildren, lvl + 1, maxLvl, nextId); nextId = addChildren(newParent, numChildren, lvl + 1, maxLvl, nextId);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment