Skip to content

Commit

Permalink
Now including only requested directors into the console and WebUI (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
climategadgets committed Sep 13, 2023
1 parent 196a732 commit 254cb6d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.Map;
import java.util.Optional;
import java.util.Set;

public abstract class ConfigurationContextAware {

Expand Down Expand Up @@ -121,4 +122,8 @@ protected final UnitController getUnitController(String address) {
logger.debug("getUnitController({}) = {}", address, result);
return result;
}

protected final boolean isConfigured(Set<String> names, Map.Entry<String, ?> d) {
return names.contains(d.getKey());
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package net.sf.dz3r.runtime.config.model;

import net.sf.dz3r.instrumentation.InstrumentCluster;
import net.sf.dz3r.runtime.config.ConfigurationContext;
import net.sf.dz3r.runtime.config.ConfigurationContextAware;
import net.sf.dz3r.instrumentation.InstrumentCluster;
import net.sf.dz3r.signal.Signal;
import net.sf.dz3r.view.swing.ReactiveConsole;
import reactor.core.publisher.Flux;

import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

public class ConsoleConfigurationParser extends ConfigurationContextAware {
Expand All @@ -32,6 +29,7 @@ public ReactiveConsole parse(String instance, ConsoleConfig cf) {
var directors = context
.directors
.getFlux()
.filter(d -> isConfigured(cf.directors(), d))
.map(Map.Entry::getValue)
.collect(Collectors.toSet())
.block();
Expand All @@ -54,8 +52,4 @@ public ReactiveConsole parse(String instance, ConsoleConfig cf) {
return null;
}
}

private boolean isConfigured(Set<String> sensors, Map.Entry<String, Flux<Signal<Double, Void>>> s) {
return sensors.contains(s.getKey());
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package net.sf.dz3r.runtime.config.model;

import net.sf.dz3r.instrumentation.InstrumentCluster;
import net.sf.dz3r.runtime.config.ConfigurationContext;
import net.sf.dz3r.runtime.config.ConfigurationContextAware;
import net.sf.dz3r.instrumentation.InstrumentCluster;
import net.sf.dz3r.view.webui.v2.WebUI;

import java.util.Map;
Expand All @@ -26,6 +26,7 @@ public WebUI parse(WebUiConfig cf) {
var directors = context
.directors
.getFlux()
.filter(d -> isConfigured(cf.directors(), d))
.map(Map.Entry::getValue)
.map(Object.class::cast)
.collect(Collectors.toSet())
Expand Down

0 comments on commit 254cb6d

Please sign in to comment.