Commit 6445bb20 authored by Julian Zobel's avatar Julian Zobel
Browse files

Filter for metrics that are only saved on shutdown.

parent f2ef599f
......@@ -25,6 +25,7 @@ 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.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.Monitor;
import de.tudarmstadt.maki.simonstrator.api.Oracle;
......@@ -91,6 +92,16 @@ public class MetricAnalyzer implements Analyzer {
for (MetricOutput outputChannel : outputs) {
outputChannel.onStop();
}
System.out.println(" 0..2 >> " + TracefileMovementModel.ZERO_TO_2);
System.out.println(" 2..5 >> " + TracefileMovementModel._2_to_5);
System.out.println(" 5..10 >> " + TracefileMovementModel._5_to_10);
System.out.println(" 10..30 >> " + TracefileMovementModel.TEN_TO_THIRTY);
System.out.println(" 30..60 >> " + TracefileMovementModel.THIRTY_TO_SIXTY);
System.out.println(" 60..120 >> " + TracefileMovementModel.SIXTY_TO_120);
System.out.println(" 120..300 >> " + TracefileMovementModel._120_TO_300);
System.out.println(" 300..600 >> " + TracefileMovementModel._300_TO_600);
System.out.println(" 600 ++ >> " + TracefileMovementModel.ABOVE_600);
}
/**
......
/*
* 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;
}
}
......@@ -50,7 +50,17 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
public static String tracefileFolder ="smarter/tracefiles/";
public static String tracefilePrefix = "smarterTraceFile-";
public static long GPS_MISSING_TRACE_THRESHOLD = 120;
public static long GPS_MISSING_TRACE_THRESHOLD = 60;
public static int ZERO_TO_2 = 0;
public static int _2_to_5 = 0;
public static int _5_to_10 = 0;
public static int TEN_TO_THIRTY = 0;
public static int THIRTY_TO_SIXTY = 0;
public static int SIXTY_TO_120 = 0;
public static int _120_TO_300 = 0;
public static int _300_TO_600 = 0;
public static int ABOVE_600 = 0;
protected final int EVENT_MOVE = 1;
......@@ -113,7 +123,7 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
private void move() {
if(first) {
components.forEach((component, steps) -> {
components.forEach((component, steps) -> {
shutdownComponent(component);
});
}
......@@ -135,12 +145,41 @@ public class TracefileMovementModel implements MovementModel, EventHandler {
if(component.getRealPosition().distanceTo(new PositionVector(step.x, step.y)) > GPS_MISSING_TRACE_THRESHOLD * 2) {
shutdownComponent(component);
}
}
// do nothing for smoothing?
}
else {
if(DefaultTopology.isWithinWorldBoundaries(component.getRealPosition())) {
if(DefaultTopology.isWithinWorldBoundaries(component.getRealPosition())) {
long delta = step.timestamp - currentTime + GPS_MISSING_TRACE_THRESHOLD;
if(delta > 0 && delta <= 2) {
ZERO_TO_2++;
}
else if(delta > 2 && delta <= 5) {
_2_to_5++;
}
else if(delta > 5 && delta <= 10) {
_5_to_10++;
}
else if(delta > 10 && delta <= 30) {
TEN_TO_THIRTY++;
}
else if(delta > 30 && delta <= 60) {
THIRTY_TO_SIXTY++;
}
else if(delta > 60 && delta <= 120) {
SIXTY_TO_120++;
}
else if(delta > 120 && delta <= 300) {
_120_TO_300++;
}
else if(delta > 300 && delta <= 600) {
_300_TO_600++;
}
else if(delta > 600) {
ABOVE_600++;
}
shutdownComponent(component);
}
}
......
......@@ -95,6 +95,10 @@ public class AttractionPointViz extends JComponent
if (showAttractionPoints) {
drawAttractionPoints(g2);
}
if(true) {
drawClusters(g2);
}
}
/**
......
......@@ -133,15 +133,17 @@ public class JSONAttractionGenerator implements IAttractionGenerator {
if(allPOI.getJSONObject(i).getJSONObject("tags").has("pauseTimeMin") && allPOI.getJSONObject(i).getJSONObject("tags").has("pauseTimeMax")) {
ap.setPauseTime( allPOI.getJSONObject(i).getJSONObject("tags").getLong("pauseTimeMin"), allPOI.getJSONObject(i).getJSONObject("tags").getLong("pauseTimeMax"));
}
System.out.println(ap);
}
}
catch (JSONException e) {
//This bar had no name defined, so there was an error. Not so bad
System.out.println(e);
}
}
}
}
}
}
return attractionPoints;
}
......
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