Commit eff5d429 authored by Julian Zobel's avatar Julian Zobel 🦄
Browse files

Merge branch 'master' into 'cherry-pick-7698d9d7'

# Conflicts:
#   src/de/tud/kom/p2psim/impl/analyzer/metric/output/MetricOutputDAO.java
#   src/de/tud/kom/p2psim/impl/util/db/dao/DAO.java
parents 1c7f20ec 37020b44
......@@ -25,7 +25,7 @@ import java.util.List;
import com.vividsolutions.jts.geom.Geometry;
import de.tud.kom.p2psim.api.topology.views.TopologyView;
import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
/**
* An obstacle (Hosts can not run through them, and communication may be either
......
......@@ -25,7 +25,7 @@ import java.util.List;
import java.util.Map;
import de.tud.kom.p2psim.api.topology.waypoints.WaypointModel;
import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.util.Tuple;
......
......@@ -23,8 +23,8 @@ package de.tud.kom.p2psim.api.topology.placement;
import de.tud.kom.p2psim.api.topology.Topology;
import de.tud.kom.p2psim.api.topology.TopologyComponent;
import de.tud.kom.p2psim.api.topology.obstacles.Obstacle;
import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.TopologyFactory;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
/**
* Strategies and Distributions that place hosts in a {@link Topology}. These
......
......@@ -24,11 +24,13 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.jgrapht.Graph;
import org.jgrapht.graph.DefaultWeightedEdge;
import de.tud.kom.p2psim.api.topology.obstacles.ObstacleModel;
import de.tud.kom.p2psim.api.util.geo.maps.Map;
import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.DefaultWeightedEdgeRetrievableGraph;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.util.Tuple;
......@@ -80,7 +82,7 @@ public interface WaypointModel {
* @param waypoint
* @return
*/
public abstract List<Tuple<Waypoint, Path>> getConnectedWaypoints(Waypoint waypoint);
public abstract List<Tuple<Waypoint, PathEdge>> getConnectedWaypoints(Waypoint waypoint);
/**
* Returns a list of Tuple<Waypoint, Path> of a specific type that are connected to the given waypoint.
......@@ -89,14 +91,14 @@ public interface WaypointModel {
* @param type
* @return
*/
public abstract List<Tuple<Waypoint, Path>> getConnectedWaypoints(Waypoint waypoint, Class type);
public abstract List<Tuple<Waypoint, PathEdge>> getConnectedWaypoints(Waypoint waypoint, Class type);
/**
* Returns all paths that are part of the waypoint model.
*
* @return
*/
public abstract Set<Path> getPaths();
public abstract Set<PathEdge> getPaths();
/**
* Returns the shortest path between the two given waypoints.
......@@ -105,7 +107,7 @@ public interface WaypointModel {
* @param end
* @return
*/
public abstract List<Path> getShortestPath(Waypoint start, Waypoint end);
public abstract List<PathEdge> getShortestPath(Waypoint start, Waypoint end);
/**
* Returns the total number of waypoints.
......@@ -153,7 +155,7 @@ public interface WaypointModel {
/*
public abstract void setStrongWaypointStrategy(StrongWaypointStrategy strongWaypointStrategy);
*/
public DefaultWeightedEdgeRetrievableGraph<Waypoint, Path> getGraph();
public Graph<Waypoint, PathEdge> getGraph();
/**
* Indicates if this model is scaled to the required world coordinates.
......
......@@ -20,11 +20,11 @@
package de.tud.kom.p2psim.api.topology.waypoints;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
public interface WaypointModelListener {
public void addedPath(Path path);
public void addedPath(PathEdge path);
public void addedWaypoint(Waypoint waypoint);
public void modifiedWaypoints();
}
......@@ -23,10 +23,10 @@ package de.tud.kom.p2psim.api.util.geo.maps;
import java.util.Collection;
import java.util.List;
import org.jgrapht.Graph;
import de.tud.kom.p2psim.api.topology.obstacles.Obstacle;
import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.DefaultWeightedEdgeRetrievableGraph;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Path;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.PathEdge;
import de.tud.kom.p2psim.impl.topology.waypoints.graph.Waypoint;
import de.tud.kom.p2psim.impl.util.geo.maps.MapChangeListener;
......@@ -39,9 +39,8 @@ public interface Map {
* @return
*/
public PositionVector getDimensions();
// TODO: Extract required functionality
public DefaultWeightedEdgeRetrievableGraph<Waypoint, Path> getGraph();
public Graph<Waypoint, PathEdge> getGraph();
public void addWaypoint(Waypoint waypoint);
......
......@@ -20,7 +20,7 @@
package de.tud.kom.p2psim.api.util.geo.maps;
import de.tud.kom.p2psim.impl.topology.PositionVector;
import de.tud.kom.p2psim.impl.topology.util.PositionVector;
public interface Node {
......
......@@ -25,6 +25,8 @@ import java.util.LinkedList;
import java.util.List;
import de.tud.kom.p2psim.api.scenario.ConfigurationException;
import de.tud.kom.p2psim.impl.topology.movement.TracefileMovementModel;
import de.tud.kom.p2psim.impl.topology.movement.modularosm.ModularMovementModel;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Oracle;
......@@ -90,7 +92,7 @@ public class MetricAnalyzer implements Analyzer {
}
for (MetricOutput outputChannel : outputs) {
outputChannel.onStop();
}
}
}
/**
......
......@@ -303,11 +303,15 @@ public abstract class AbstractFilter<M extends MetricValue<?>>
* @param blacklist
*/
public void setBlacklist(String blacklist) {
this.blacklist = blacklist.split(";");
this.blacklist = blacklist.split(";|;\\n");
for (String string : this.blacklist)
string = string.replaceAll("\\s+", "");
}
public void setWhitelist(String whitelist) {
this.whitelist = whitelist.split(";");
this.whitelist = whitelist.split(";|;\\n");
for (int i = 0; i < this.whitelist.length; i++)
this.whitelist[i] = this.whitelist[i].replaceAll("\\s+", "");
}
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.impl.analyzer.metric.filter;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Monitor.Level;
import de.tudarmstadt.maki.simonstrator.api.common.metric.Metric;
import de.tudarmstadt.maki.simonstrator.api.common.metric.Metric.MetricValue;
/**
* calculates the delivery ratio, which is the percent of actual transferred
* messages. (1 - overhead). Uses the duplicate and message count metrics and
* merge them. Used metrics are in DELIVERY_RATIO_LIST and duplicate metric must
* end with "Dup".
*
* @author Simon Luser
* @version 1.0, 08.03.2017
*/
public class MergeDeliveryRatioFilter
extends AbstractFilter<MetricValue<Double>> {
@Override
public void onStop() {
// nothing to do
}
@Override
public String getName() {
return "DeliveryRatio";
}
@Override
protected void onInitialize(List<Metric<?>> incomingMetrics) {
// get the pairing metrics
Set<Metric<?>> duplicateMetrics = incomingMetrics.stream().filter(
m -> m.getName().endsWith("Dup") && !m.isOverallMetric())
.collect(Collectors.toSet());
Set<Metric<?>> nonDuplicateMetrics = incomingMetrics.stream().filter(
m -> !m.getName().endsWith("Dup") && !m.isOverallMetric())
.collect(Collectors.toSet());
// generate the matches and create derived metric
for (Metric<?> met : nonDuplicateMetrics) {
List<Metric<?>> matches = duplicateMetrics.stream()
.filter(m -> met.getName()
.startsWith(m.getName().substring(0,
m.getName().lastIndexOf("Dup"))))
.collect(Collectors.toList());
if (matches.size() > 1)
Monitor.log(MergeDeliveryRatioFilter.class, Level.ERROR,
"Config Error!");
else if (matches.size() == 1) {
matches.add(met);
createDerivedMetric(matches, false, met.getUnit(),
"Delivery Ratio", false);
}
}
}
@Override
protected String getNameForDerivedMetric(List<Metric<?>> inputs) {
String str = getName();
if (inputs.size() >= 1) {
str += "_";
String firstName = inputs.get(0).getName();
if (firstName.contains("Dup"))
str += firstName.substring(0, firstName.lastIndexOf("Dup"));
else
str += firstName;
}
return str;
}
@Override
protected MetricValue<Double> getDerivedMetricValueFor(
Metric<?> derivedMetric, List<Metric<?>> inputs, Host host) {
// separate the values
if (inputs.size() == 2) {
try {
MetricValue<?> duplicateVal = inputs.stream()
.filter(m -> m.getName().endsWith("Dup"))
.collect(Collectors.toList()).get(0)
.getPerHostMetric(host.getId());
MetricValue<?> receiveVal = inputs.stream()
.filter(m -> !m.getName().endsWith("Dup"))
.collect(Collectors.toList()).get(0)
.getPerHostMetric(host.getId());
if (duplicateVal == null || receiveVal == null) {
return null;
}
return new DeliveryRatioMetricValue(duplicateVal, receiveVal);
} catch (IndexOutOfBoundsException e) {
return null;
}
} else
return null;
}
/**
* calculates the delivery ratio.
*
* @author Simon Luser
* @version 1.0, 08.03.2017
*/
private class DeliveryRatioMetricValue implements MetricValue<Double> {
private MetricValue<?> duplicateVal, receiveVal;
private boolean valid;
public DeliveryRatioMetricValue(MetricValue<?> duplicateVal,
MetricValue<?> receiveVal) {
this.duplicateVal = duplicateVal;
this.receiveVal = receiveVal;
}
@Override
public Double getValue() {
Object oDup = duplicateVal.getValue();
Object oRec = receiveVal.getValue();
double nDup;
if (oDup instanceof Number) {
nDup = ((Number) oDup).doubleValue();
} else {
throw new AssertionError();
}
double nRec;
if (oRec instanceof Number) {
nRec = ((Number) oRec).doubleValue();
} else {
throw new AssertionError();
}
this.valid = duplicateVal.isValid() && receiveVal.isValid()
&& nRec > 0;
return 1 - nDup / nRec;
}
@Override
public boolean isValid() {
return valid;
}
}
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.impl.analyzer.metric.filter;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.common.metric.Metric;
import de.tudarmstadt.maki.simonstrator.api.common.metric.Metric.MetricValue;
public class OnShutdownFilter extends AbstractFilter<MetricValue<?>> {
protected String description = "Shutdown Value";
private String prefix;
@Override
public void onStop() {
notifyListenersOfUpdate();
}
@Override
protected void onInitialize(List<Metric<?>> incomingMetrics) {
for (Metric metric : incomingMetrics) {
createDerivedMetric(metric, metric.isOverallMetric(), metric.getUnit(),
description + " of " + metric.getName(), true);
}
}
@Override
protected MetricValue<?> getDerivedMetricValueFor(Metric<?> derivedMetric,
List<Metric<?>> inputs, Host host) {
if (inputs.size() != 1) {
throw new AssertionError();
}
Metric input = inputs.get(0);
MetricValue inputMv = null;
if (input.isOverallMetric()) {
inputMv = input.getOverallMetric();
} else {
inputMv = input.getPerHostMetric(host.getId());
}
return inputMv;
}
@Override
protected String getNameForDerivedMetric(List<Metric<?>> inputs) {
if (inputs.size() != 1) {
throw new AssertionError();
}
if (prefix == null) {
return "OnShutdown_"
+ inputs.get(0).getName();
} else {
return prefix + "_" + inputs.get(0).getName();
}
}
/**
* Prefix to use instead of the Filtername
*
* @param prefix
* @return
*/
public void setPrefix(String prefix) {
this.prefix = prefix;
}
}
......@@ -2,17 +2,17 @@
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
......@@ -38,7 +38,7 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
* basic filter for more complex statistical computations on the provided
* dataset. Common functions are included as inner classes in this abstract
* filter.
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 08.08.2012
*/
......@@ -92,23 +92,22 @@ public abstract class StatisticsFilter extends
if (values == null || values.isEmpty()) {
return null;
}
LinkedList<MetricValue> mvs = new LinkedList<MetricValue>(values);
return new StatisticsMetricValue(mvs);
return new StatisticsMetricValue(values);
}
/**
* Computes statistics such as svg, sum, std...
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 08.08.2012
*/
private class StatisticsMetricValue implements MetricValue<Double> {
private final List<MetricValue> inputs;
private final List<? extends MetricValue<?>> inputs;
private Double result = Double.NaN;
public StatisticsMetricValue(List<MetricValue> inputs) {
public StatisticsMetricValue(List<? extends MetricValue<?>> inputs) {
this.inputs = inputs;
}
......@@ -175,7 +174,7 @@ public abstract class StatisticsFilter extends
/**
* Function that has to compute sth. on the double-list. For convenience,
* some basic statistical values are already included.
*
*
* @param incoming
* @param count
* number of values
......@@ -191,7 +190,7 @@ public abstract class StatisticsFilter extends
/**
* Standard deviation
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 08.08.2012
*/
......@@ -208,7 +207,7 @@ public abstract class StatisticsFilter extends
/**
* Average
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 08.08.2012
*/
......@@ -231,7 +230,7 @@ public abstract class StatisticsFilter extends
/**
* Minimum
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 08.08.2012
*/
......@@ -250,7 +249,7 @@ public abstract class StatisticsFilter extends
/**
* Maximum
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 08.08.2012
*/
......@@ -271,7 +270,7 @@ public abstract class StatisticsFilter extends
* The Percentile, pass a value between 0 (exclusive) and 100 (inclusive).
* The resulting metric will be called "P20_incomingmetric" in the case of
* the 20th percentile.
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 08.08.2012
*/
......
......@@ -100,11 +100,15 @@ public abstract class AbstractOutput implements MetricOutput {
* @param blacklist
*/
public void setBlacklist(String blacklist) {
this.blacklist = blacklist.split(";");
this.blacklist = blacklist.split(";|;\\n");
for (int i = 0; i < this.blacklist.length; i++)
this.blacklist[i] = this.blacklist[i].replaceAll("\\s+", "");
}
public void setWhitelist(String whitelist) {
this.whitelist = whitelist.split(";");
this.whitelist = whitelist.split(";|;\\n");
for (int i = 0; i < this.whitelist.length; i++)
this.whitelist[i] = this.whitelist[i].replaceAll("\\s+", "");
}
}
......@@ -2,17 +2,17 @@
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
......@@ -31,7 +31,7 @@ import de.tudarmstadt.maki.simonstrator.api.common.metric.Metric.MetricValue;
/**
* Live Monitoring of all configured {@link Metric}s
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 07.08.2012
*/
......@@ -55,7 +55,7 @@ public class MetricOutputLive extends AbstractOutput {
/**
* Just matching the {@link ProgressValue}-interface to the
* {@link TransitMetric} interface.
*
*
* @author Bjoern Richerzhagen
* @version 1.0, 07.08.2012
*/
......
......@@ -24,12 +24,14 @@ import java.util.LinkedList;
import java.util.List;
import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.VisualizationInjector;
import de.tud.kom.p2psim.impl.topology.views.visualization.ui.DisasterMetricChartAdapter;
import de.tud.kom.p2psim.impl.topology.views.visualization.ui.MetricCDFAdapter;
import de.tud.kom.p2psim.impl.topology.views.visualization.ui.MetricChartAdapter;
import de.tud.kom.p2psim.impl.topology.views.visualization.ui.MetricPlotAdapter;
import de.tud.kom.p2psim.impl.topology.views.visualization.ui.PlottingView;
import de.tudarmstadt.maki.simonstrator.api.Event;
import de.tudarmstadt.maki.simonstrator.api.EventHandler;
import de.tudarmstadt.maki.simonstrator.api.MessageWithDisasterType.MessageDisasterType;
import de.tudarmstadt.maki.simonstrator.api.common.metric.Metric;
import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
......@@ -41,6 +43,13 @@ import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;
public class MetricOutputLivePlot extends AbstractOutput implements
EventHandler {
/**
* appended in metric description to separate from normal metrics, these
* metrics have a {@link MessageDisasterType} to plot, which are visualized
* in only one graph.
*/
public static final String DRAW_ONCE = "_DRAW_ONCE_";
private List<MetricPlotAdapter> charts = new LinkedList<MetricPlotAdapter>();
protected int upperPercentile = -1;
......@@ -70,8 +79,28 @@ public class MetricOutputLivePlot extends AbstractOutput implements
if (pView == null) {
pView = VisualizationInjector.createPlottingView("Metrics");
}
MetricChartAdapter mca = new MetricChartAdapter(metric, pView,
lowerPercentile, upperPercentile, maxItemCount);
// extended by choosing disaster adapter, if it is a disaster metric
boolean isMessageDisasterMetric = false;
for (MessageDisasterType type : MessageDisasterType.values())
if (metric.getName().contains(DRAW_ONCE)
&& metric.getName().contains(type.name())) {
isMessageDisasterMetric = true;
break;
}
if (isMessageDisasterMetric)
continue;
MetricPlotAdapter mca;
if (metric.getName().contains(DRAW_ONCE))
mca = new DisasterMetricChartAdapter(metric, pView,
maxItemCount);
else
mca = new MetricChartAdapter(metric, pView, lowerPercentile,
upperPercentile, maxItemCount);
charts.add(mca);
if (enableCDF && !metric.isOverallMetric()) {
if (pViewCdf == null) {
......
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.impl.analyzer.metric.spatial;
import java.util.ArrayList;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.common.metric.AbstractMetric;
import de.tudarmstadt.maki.simonstrator.api.common.metric.ActiveSpatialMetric;
import de.tudarmstadt.maki.simonstrator.api.common.metric.Metric;
public abstract class AbstractSpatialMetric<T extends AbstractSpatialMetricValue<?>> extends AbstractMetric<T> implements Metric<T>, ActiveSpatialMetric<T> {
protected boolean aggregate = false;
public AbstractSpatialMetric(String pDescription, MetricUnit pUnit) {
super(pDescription, pUnit);
}
public AbstractSpatialMetric(String pName, String pDescription, MetricUnit pUnit) {
super(pName, pDescription, pUnit);
}
protected void setOverallMetric(T aggregate) {
super.setOverallMetric(aggregate);
}
@Override
public boolean isAggregated() {
return aggregate;
}
private List<ActiveSpatialMetricListener> _listeners = new ArrayList<>();
@Override
public void addActiveSpatialMetricListener(ActiveSpatialMetricListener pListener) {
_listeners.add(pListener);
}
@Override
public void notifyListeners() {
for (ActiveSpatialMetricListener activeSpatialMetricListener : _listeners) {
activeSpatialMetricListener.onMetricUpdate(this);
}
}
}
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.impl.analyzer.metric.spatial;
import de.tudarmstadt.maki.simonstrator.api.common.metric.ActiveSpatialMetric;
import de.tudarmstadt.maki.simonstrator.api.common.metric.ActiveSpatialMetric.SpatialMetricValue;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Location;
public abstract class AbstractSpatialMetricValue<S extends Object> implements SpatialMetricValue<S> {
private S value;
private Location location;
private ActiveSpatialMetric<?> metric;
public AbstractSpatialMetricValue(ActiveSpatialMetric<?> pMetric) {
metric = pMetric;
}
public AbstractSpatialMetricValue(ActiveSpatialMetric<?> pMetric, S pValue) {
metric = pMetric;
value = pValue;
}
public void setValue(S pValue, Location pLocation) {
value = pValue;
location = pLocation;
metric.notifyListeners();
}
@Override
public S getValue() {
return value;
}
@Override
public Location getLocation() {
return location;
}
}
\ No newline at end of file
......@@ -114,8 +114,17 @@ public class MaxPeerCountChurnGenerator
@XMLConfigurableConstructor({ "file", "maxNumberOfNodes" })
public MaxPeerCountChurnGenerator(String file, int maxNumberOfNodes) {
this.maxNumberOfNodes = maxNumberOfNodes;
parseTrace(file);
parseTrace(file);
}
@XMLConfigurableConstructor({ "churnStart", "maxNumberOfNodes", "burstLength" })
public MaxPeerCountChurnGenerator(long churnStart, int maxNumberOfNodes, long burstLength) {
this.maxNumberOfNodes = maxNumberOfNodes;
churnInfos.add(new ChurnInfo(churnStart, burstLength, maxNumberOfNodes));
this.setChurnStart(churnStart);
}
/**
* A class that implements the {@link LifecycleComponent}-interface and can
......@@ -361,8 +370,6 @@ public class MaxPeerCountChurnGenerator
// Insanity Checks
assert startTime >= previousEndTime : "Start time for next fluctuation must be greater than previous end time.";
assert burstLength >= _minBurstLength : "The minimal length of the burst must be at least 1m.";
assert numberOfClients > 0 : "Number of nodes must be positive.";
assert numberOfClients <= maxNumberOfNodes : "Cannot configure more nodes than configured in configuration.";
......
......@@ -231,6 +231,6 @@ public class DefaultHost implements SimHost {
throw new AssertionError(
"This host was configured without any components!");
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment