Mercurial > stress-tester
changeset 852:bd7ddb7ff81d
SummrizeMetricsCollectionHandler -> SummaryMetricsCollectionHandler
author | Devel 2 |
---|---|
date | Tue, 23 Jan 2018 15:17:53 +0100 |
parents | ba2ddf2d553c |
children | dd889cf40118 |
files | stress-tester/src/main/java/com/passus/st/Main.java stress-tester/src/main/java/com/passus/st/Main2.java stress-tester/src/main/java/com/passus/st/PcapReporter.java stress-tester/src/main/java/com/passus/st/metric/SummaryMetricsCollectionHandler.java stress-tester/src/main/java/com/passus/st/metric/SummrizeMetricsCollectionHandler.java |
diffstat | 5 files changed, 45 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/Main.java Tue Jan 23 14:22:47 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/Main.java Tue Jan 23 15:17:53 2018 +0100 @@ -1,7 +1,6 @@ package com.passus.st; import com.passus.commons.ConversionException; -import com.passus.commons.metric.MapMetric; import com.passus.commons.metric.Metric; import com.passus.commons.service.Registry; import com.passus.st.client.MemoryEventsCache; @@ -12,8 +11,7 @@ import com.passus.st.metric.FileMetricsCollectionAppender; import com.passus.st.metric.MetricSource; import com.passus.st.metric.ScheduledMetricsCollector; -import com.passus.st.metric.SummrizeMetricsCollectionHandler; -import com.passus.st.reporter.ReporterClient; +import com.passus.st.metric.SummaryMetricsCollectionHandler; import com.passus.st.source.EventSource; import com.passus.st.utils.PeriodFormatter; import org.apache.commons.cli.*; @@ -37,7 +35,7 @@ private final CliHelper cliHelper = new CliHelper(); - private final SummrizeMetricsCollectionHandler summMetricsHandler = new SummrizeMetricsCollectionHandler(); + private final SummaryMetricsCollectionHandler summMetricsHandler = new SummaryMetricsCollectionHandler(); private long startTime; static void printHelp(Options options) {
--- a/stress-tester/src/main/java/com/passus/st/Main2.java Tue Jan 23 14:22:47 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/Main2.java Tue Jan 23 15:17:53 2018 +0100 @@ -1,7 +1,6 @@ package com.passus.st; import com.passus.commons.ConversionException; -import com.passus.commons.metric.MapMetric; import com.passus.commons.metric.Metric; import com.passus.commons.service.Registry; import com.passus.net.PortRangeSet; @@ -20,19 +19,14 @@ import com.passus.st.emitter.nio.NioEmitterWorker2; import com.passus.st.metric.FileMetricsCollectionAppender; import com.passus.st.metric.ScheduledMetricsCollector; -import com.passus.st.metric.SummrizeMetricsCollectionHandler; -import com.passus.st.reporter.ReporterClient; -import com.passus.st.reporter.trx.SocketReporterClient; +import com.passus.st.metric.SummaryMetricsCollectionHandler; import com.passus.st.source.PcapSessionEventSource; import static com.passus.st.utils.CliUtils.option; import com.passus.st.utils.PeriodFormatter; import java.io.File; import java.io.FileOutputStream; import java.io.Serializable; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -54,7 +48,7 @@ public class Main2 { private final CliHelper cliHelper = new CliHelper(); - private final SummrizeMetricsCollectionHandler summMetricsHandler = new SummrizeMetricsCollectionHandler(); + private final SummaryMetricsCollectionHandler summMetricsHandler = new SummaryMetricsCollectionHandler(); private long startTime; static void printHelp(Options options) {
--- a/stress-tester/src/main/java/com/passus/st/PcapReporter.java Tue Jan 23 14:22:47 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/PcapReporter.java Tue Jan 23 15:17:53 2018 +0100 @@ -27,14 +27,11 @@ import com.passus.st.emitter.SessionInfo; import com.passus.st.metric.FileMetricsCollectionAppender; import com.passus.st.metric.ScheduledMetricsCollector; -import com.passus.st.metric.SummrizeMetricsCollectionHandler; -import com.passus.st.reporter.trx.SocketReporterClient; +import com.passus.st.metric.SummaryMetricsCollectionHandler; import com.passus.st.source.PcapSessionEventSource; import static com.passus.st.utils.CliUtils.option; import com.passus.st.utils.PeriodFormatter; import java.io.File; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.cli.CommandLine; @@ -112,7 +109,7 @@ } ScheduledMetricsCollector collector = new ScheduledMetricsCollector(); - SummrizeMetricsCollectionHandler summMetricsHandler = new SummrizeMetricsCollectionHandler(); + SummaryMetricsCollectionHandler summMetricsHandler = new SummaryMetricsCollectionHandler(); if (cl.hasOption("wm")) { File metricsFile = new File(cl.getOptionValue("wm")); if (!metricsFile.exists() && !metricsFile.createNewFile()) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/metric/SummaryMetricsCollectionHandler.java Tue Jan 23 15:17:53 2018 +0100 @@ -0,0 +1,39 @@ +package com.passus.st.metric; + +import com.passus.commons.metric.Metric; +import com.passus.commons.metric.MetricsCollection; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * + * @author Mirosław Hawrot + */ +public class SummaryMetricsCollectionHandler implements MetricsCollectionHandler { + + public final Map<String, Metric> metrics = new HashMap<>(); + + public List<Metric> getMetrics() { + return new ArrayList<>(metrics.values()); + } + + public Metric getMetric(String name) { + return metrics.get(name); + } + + @Override + public void handle(MetricsCollection mc) { + for (Metric metric : mc.getMetrics()) { + Metric mapMetric = metrics.get(metric.getName()); + if (mapMetric == null) { + mapMetric = metric.copy(); + metrics.put(mapMetric.getName(), mapMetric); + } else { + mapMetric.update(metric); + } + } + } + +}
--- a/stress-tester/src/main/java/com/passus/st/metric/SummrizeMetricsCollectionHandler.java Tue Jan 23 14:22:47 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -package com.passus.st.metric; - -import com.passus.commons.metric.Metric; -import com.passus.commons.metric.MetricsCollection; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * - * @author Mirosław Hawrot - */ -public class SummrizeMetricsCollectionHandler implements MetricsCollectionHandler { - - public final Map<String, Metric> metrics = new HashMap<>(); - - public List<Metric> getMetrics() { - return new ArrayList<>(metrics.values()); - } - - public Metric getMetric(String name) { - return metrics.get(name); - } - - @Override - public void handle(MetricsCollection mc) { - for (Metric metric : mc.getMetrics()) { - Metric mapMetric = metrics.get(metric.getName()); - if (mapMetric == null) { - mapMetric = metric.copy(); - metrics.put(mapMetric.getName(), mapMetric); - } else { - mapMetric.update(metric); - } - } - } - -}