Commit 70b38d4f authored by Christian Wulf's avatar Christian Wulf

moved ISendTraceBuffer to ctor

parent 813304cc
#FindBugs User Preferences #FindBugs User Preferences
#Thu Feb 19 16:40:02 CET 2015 #Wed Feb 25 09:07:58 CET 2015
detector_threshold=3 detector_threshold=3
effort=max effort=max
excludefilter0=.fbExcludeFilterFile|true excludefilter0=.fbExcludeFilterFile|true
......
...@@ -139,34 +139,34 @@ ...@@ -139,34 +139,34 @@
</plugin> </plugin>
<!-- goals to build a jar with binaries: jar:jar, jar:test-jar --> <!-- goals to build a jar with binaries: jar:jar, jar:test-jar -->
<plugin> <!-- <plugin> -->
<groupId>org.apache.maven.plugins</groupId> <!-- <groupId>org.apache.maven.plugins</groupId> -->
<artifactId>maven-jar-plugin</artifactId> <!-- <artifactId>maven-jar-plugin</artifactId> -->
<version>2.5</version> <!-- <version>2.5</version> -->
<executions> <!-- <executions> -->
<execution> <!-- <execution> -->
<goals> <!-- <goals> -->
<goal>test-jar</goal> <!-- <goal>test-jar</goal> -->
</goals> <!-- </goals> -->
</execution> <!-- </execution> -->
</executions> <!-- </executions> -->
</plugin> <!-- </plugin> -->
<!-- copies all dependencies as separate jars into the target folder --> <!-- copies all dependencies as separate jars into the target folder -->
<plugin> <!-- <plugin> -->
<groupId>org.apache.maven.plugins</groupId> <!-- <groupId>org.apache.maven.plugins</groupId> -->
<artifactId>maven-dependency-plugin</artifactId> <!-- <artifactId>maven-dependency-plugin</artifactId> -->
<version>2.10</version> <!-- <version>2.10</version> -->
<executions> <!-- <executions> -->
<execution> <!-- <execution> -->
<id>copy-dependencies</id> <!-- <id>copy-dependencies</id> -->
<phase>package</phase> <!-- <phase>package</phase> -->
<goals> <!-- <goals> -->
<goal>copy-dependencies</goal> <!-- <goal>copy-dependencies</goal> -->
</goals> <!-- </goals> -->
</execution> <!-- </execution> -->
</executions> <!-- </executions> -->
</plugin> <!-- </plugin> -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
......
...@@ -44,17 +44,17 @@ public class TraceReconstructionFilter extends AbstractConsumerStage<IFlowRecord ...@@ -44,17 +44,17 @@ public class TraceReconstructionFilter extends AbstractConsumerStage<IFlowRecord
public TraceReconstructionFilter(final ConcurrentHashMapWithDefault<Long, EventBasedTrace> traceId2trace) { public TraceReconstructionFilter(final ConcurrentHashMapWithDefault<Long, EventBasedTrace> traceId2trace) {
super(); super();
this.reconstructor = new TraceReconstructor(traceId2trace); this.reconstructor = new TraceReconstructor(traceId2trace, this);
} }
@Override @Override
protected void execute(final IFlowRecord element) { protected void execute(final IFlowRecord element) {
reconstructor.execute(element, this); reconstructor.execute(element);
} }
@Override @Override
public void onTerminating() throws Exception { public void onTerminating() throws Exception {
reconstructor.terminate(this); reconstructor.terminate();
super.onTerminating(); super.onTerminating();
} }
......
...@@ -16,9 +16,11 @@ import kieker.common.record.flow.trace.TraceMetadata; ...@@ -16,9 +16,11 @@ import kieker.common.record.flow.trace.TraceMetadata;
public class TraceReconstructor { public class TraceReconstructor {
private final ConcurrentHashMapWithDefault<Long, EventBasedTrace> traceId2trace; private final ConcurrentHashMapWithDefault<Long, EventBasedTrace> traceId2trace;
private final ISendTraceBuffer sender;
public TraceReconstructor(final ConcurrentHashMapWithDefault<Long, EventBasedTrace> traceId2trace) { public TraceReconstructor(final ConcurrentHashMapWithDefault<Long, EventBasedTrace> traceId2trace, final ISendTraceBuffer sender) {
this.traceId2trace = traceId2trace; this.traceId2trace = traceId2trace;
this.sender = sender;
} }
private Long reconstructTrace(final IFlowRecord record) { private Long reconstructTrace(final IFlowRecord record) {
...@@ -58,13 +60,13 @@ public class TraceReconstructor { ...@@ -58,13 +60,13 @@ public class TraceReconstructor {
} }
} }
public void terminate(final ISendTraceBuffer sender) { public void terminate() {
for (Long traceId : traceId2trace.keySet()) { for (Long traceId : traceId2trace.keySet()) {
this.put(traceId, false, sender); this.put(traceId, false, sender);
} }
} }
public void execute(final IFlowRecord record, final ISendTraceBuffer sender) { public void execute(final IFlowRecord record) {
final Long traceId = this.reconstructTrace(record); final Long traceId = this.reconstructTrace(record);
if (traceId != null) { if (traceId != null) {
this.put(traceId, true, sender); this.put(traceId, true, sender);
......
...@@ -15,15 +15,9 @@ ...@@ -15,15 +15,9 @@
***************************************************************************/ ***************************************************************************/
package teetime.examples.traceReconstructionWithThreads; package teetime.examples.traceReconstructionWithThreads;
import static org.hamcrest.Matchers.both;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.junit.After; import org.junit.After;
...@@ -35,7 +29,6 @@ import org.junit.runners.MethodSorters; ...@@ -35,7 +29,6 @@ import org.junit.runners.MethodSorters;
import teetime.framework.Analysis; import teetime.framework.Analysis;
import teetime.util.ListUtil; import teetime.util.ListUtil;
import teetime.util.StopWatch; import teetime.util.StopWatch;
import util.test.eval.StatisticsUtil;
/** /**
* @author Christian Wulf * @author Christian Wulf
...@@ -46,7 +39,7 @@ import util.test.eval.StatisticsUtil; ...@@ -46,7 +39,7 @@ import util.test.eval.StatisticsUtil;
public class ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest { public class ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest {
private static final int MIO = 1000000; private static final int MIO = 1000000;
private static final int EXPECTED_NUM_TRACES = 10 * MIO; private static final int EXPECTED_NUM_TRACES = 1 * MIO;
private static final int EXPECTED_NUM_RECORDS = 21 * EXPECTED_NUM_TRACES + 1; private static final int EXPECTED_NUM_RECORDS = 21 * EXPECTED_NUM_TRACES + 1;
private StopWatch stopWatch; private StopWatch stopWatch;
...@@ -102,8 +95,8 @@ public class ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest { ...@@ -102,8 +95,8 @@ public class ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest {
// System.out.println("Median trace delay: " + traceQuintiles.get(0.5) + " time units/trace"); // System.out.println("Median trace delay: " + traceQuintiles.get(0.5) + " time units/trace");
List<Long> recordThroughputs = ListUtil.removeFirstHalfElements(configuration.getRecordThroughputs()); List<Long> recordThroughputs = ListUtil.removeFirstHalfElements(configuration.getRecordThroughputs());
Map<Double, Long> recordQuintiles = StatisticsUtil.calculateQuintiles(recordThroughputs); // Map<Double, Long> recordQuintiles = StatisticsUtil.calculateQuintiles(recordThroughputs);
System.out.println("Median record throughput: " + recordQuintiles.get(0.5) + " elements/time unit"); // System.out.println("Median record throughput: " + recordQuintiles.get(0.5) + " elements/time unit");
// List<Long> traceThroughputs = ListUtil.removeFirstHalfElements(analysis.getTraceThroughputs()); // List<Long> traceThroughputs = ListUtil.removeFirstHalfElements(analysis.getTraceThroughputs());
// Map<Double, Long> traceQuintiles = StatisticsUtil.calculateQuintiles(traceThroughputs); // Map<Double, Long> traceQuintiles = StatisticsUtil.calculateQuintiles(traceThroughputs);
...@@ -123,7 +116,7 @@ public class ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest { ...@@ -123,7 +116,7 @@ public class ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest {
} }
// 08.07.2014 (incl.) // 08.07.2014 (incl.)
assertThat(recordQuintiles.get(0.5), is(both(greaterThan(3100L)).and(lessThan(3500L)))); // assertThat(recordQuintiles.get(0.5), is(both(greaterThan(3100L)).and(lessThan(3500L))));
} }
public static void main(final String[] args) { public static void main(final String[] args) {
......
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