diff --git a/pom.xml b/pom.xml index 7eed5fafa7b33c916205ec6f5eb1cb24260623e3..bf5dfe71b0efe39f575bf3e59b34f702236d581e 100644 --- a/pom.xml +++ b/pom.xml @@ -81,11 +81,6 @@ <artifactId>hamcrest-library</artifactId> <version>1.3</version> </dependency> - <dependency> - <groupId>net.kieker-monitoring</groupId> - <artifactId>kieker</artifactId> - <version>1.10-SNAPSHOT</version> - </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> diff --git a/src/main/java/kieker/analysis/examples/ThroughputAnalysis.java b/src/main/java/kieker/analysis/examples/ThroughputAnalysis.java deleted file mode 100644 index 589185abb5ae97ce6c37edb8c3a26d7a7d099ece..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/analysis/examples/ThroughputAnalysis.java +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.examples; - -import java.util.concurrent.Callable; - -import kieker.analysis.AnalysisController; -import kieker.analysis.IAnalysisController; -import kieker.analysis.exception.AnalysisConfigurationException; -import kieker.analysis.stage.EmptyPassOnFilter; -import kieker.analysis.stage.ObjectProducer; -import kieker.common.configuration.Configuration; - -/** - * @author Nils Christian Ehmke - * - * @since 1.10 - */ -public class ThroughputAnalysis<T> { - - private final IAnalysisController ac = new AnalysisController(); - private int numNoopFilters; - private int numInputObjects; - private Callable<T> inputObjectCreator; - - public void setNumNoopFilters(final int numNoopFilters) { - this.numNoopFilters = numNoopFilters; - } - - public void setInput(final int numInputObjects, final Callable<T> inputObjectCreator) { - this.numInputObjects = numInputObjects; - this.inputObjectCreator = inputObjectCreator; - } - - public void start() throws IllegalStateException, AnalysisConfigurationException { - this.ac.run(); - } - - public void init() throws IllegalStateException, AnalysisConfigurationException { - final Configuration producerConfig = new Configuration(); - producerConfig.setProperty(ObjectProducer.CONFIG_PROPERTY_NAME_OBJECTS_TO_CREATE, Long.toString(this.numInputObjects)); - final ObjectProducer<T> producer = new ObjectProducer<T>(producerConfig, this.ac, this.inputObjectCreator); - - EmptyPassOnFilter predecessor = new EmptyPassOnFilter(new Configuration(), this.ac); - this.ac.connect(producer, ObjectProducer.OUTPUT_PORT_NAME, predecessor, EmptyPassOnFilter.INPUT_PORT_NAME); - for (int idx = 0; idx < (this.numNoopFilters - 1); idx++) { - final EmptyPassOnFilter newPredecessor = new EmptyPassOnFilter(new Configuration(), this.ac); - this.ac.connect(predecessor, EmptyPassOnFilter.OUTPUT_PORT_NAME, newPredecessor, EmptyPassOnFilter.INPUT_PORT_NAME); - predecessor = newPredecessor; - } - } - -} diff --git a/src/main/java/kieker/analysis/examples/ThroughputTimestampAnalysis.java b/src/main/java/kieker/analysis/examples/ThroughputTimestampAnalysis.java deleted file mode 100644 index f06b4e175ba4e0670f2501004dc2dc68df0e07a3..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/analysis/examples/ThroughputTimestampAnalysis.java +++ /dev/null @@ -1,84 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.examples; - -import java.util.Collection; -import java.util.concurrent.Callable; - -import teetime.util.TimestampObject; - -import kieker.analysis.AnalysisController; -import kieker.analysis.IAnalysisController; -import kieker.analysis.exception.AnalysisConfigurationException; -import kieker.analysis.stage.CollectorSink; -import kieker.analysis.stage.EmptyPassOnFilter; -import kieker.analysis.stage.ObjectProducer; -import kieker.analysis.stage.StartTimestampFilter; -import kieker.analysis.stage.StopTimestampFilter; -import kieker.common.configuration.Configuration; - -/** - * @author Nils Christian Ehmke - * - * @since 1.10 - */ -public class ThroughputTimestampAnalysis { - - private final IAnalysisController ac = new AnalysisController(); - private int numNoopFilters; - private int numInputObjects; - private Callable<TimestampObject> inputObjectCreator; - private Collection<TimestampObject> timestampObjects; - - public void setNumNoopFilters(final int numNoopFilters) { - this.numNoopFilters = numNoopFilters; - } - - public void setInput(final int numInputObjects, final Callable<TimestampObject> inputObjectCreator) { - this.numInputObjects = numInputObjects; - this.inputObjectCreator = inputObjectCreator; - } - - public void setTimestampObjects(final Collection<TimestampObject> timestampObjects) { - this.timestampObjects = timestampObjects; - } - - public void start() throws IllegalStateException, AnalysisConfigurationException { - this.ac.run(); - } - - public void init() throws IllegalStateException, AnalysisConfigurationException { - final Configuration producerConfig = new Configuration(); - producerConfig.setProperty(ObjectProducer.CONFIG_PROPERTY_NAME_OBJECTS_TO_CREATE, Long.toString(this.numInputObjects)); - final ObjectProducer<TimestampObject> producer = new ObjectProducer<TimestampObject>(producerConfig, this.ac, this.inputObjectCreator); - - final StartTimestampFilter startTimestampFilter = new StartTimestampFilter(new Configuration(), this.ac); - EmptyPassOnFilter predecessor = new EmptyPassOnFilter(new Configuration(), this.ac); - this.ac.connect(producer, ObjectProducer.OUTPUT_PORT_NAME, startTimestampFilter, StartTimestampFilter.INPUT_PORT_NAME); - this.ac.connect(startTimestampFilter, StartTimestampFilter.OUTPUT_PORT_NAME, predecessor, EmptyPassOnFilter.INPUT_PORT_NAME); - for (int idx = 0; idx < (this.numNoopFilters - 1); idx++) { - final EmptyPassOnFilter newPredecessor = new EmptyPassOnFilter(new Configuration(), this.ac); - this.ac.connect(predecessor, EmptyPassOnFilter.OUTPUT_PORT_NAME, newPredecessor, EmptyPassOnFilter.INPUT_PORT_NAME); - predecessor = newPredecessor; - } - final StopTimestampFilter stopTimestampFilter = new StopTimestampFilter(new Configuration(), this.ac); - final CollectorSink<TimestampObject> collectorSink = new CollectorSink<TimestampObject>(new Configuration(), this.ac, this.timestampObjects); - - this.ac.connect(predecessor, EmptyPassOnFilter.OUTPUT_PORT_NAME, stopTimestampFilter, StopTimestampFilter.INPUT_PORT_NAME); - this.ac.connect(stopTimestampFilter, StopTimestampFilter.OUTPUT_PORT_NAME, collectorSink, CollectorSink.INPUT_PORT_NAME); - } - -} diff --git a/src/main/java/kieker/analysis/stage/CacheFilter.java b/src/main/java/kieker/analysis/stage/CacheFilter.java deleted file mode 100644 index 9aaac112c74a5dd94fd7e0ddbfd57ffd7c74ff3b..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/analysis/stage/CacheFilter.java +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.stage; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import teetime.util.StopWatch; - -import kieker.analysis.IProjectContext; -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.common.configuration.Configuration; - -/** - * @author Nils Christian Ehmke - * - * @since 1.10 - */ -@Plugin(outputPorts = @OutputPort(name = CacheFilter.OUTPUT_PORT_NAME)) -public class CacheFilter extends AbstractFilterPlugin { - - public static final String INPUT_PORT_NAME = "input"; - public static final String OUTPUT_PORT_NAME = "output"; - - private final List<Object> cache = new ArrayList<Object>(); - - public CacheFilter(final Configuration configuration, - final IProjectContext projectContext) { - super(configuration, projectContext); - } - - @Override - public void terminate(final boolean error) { - StopWatch stopWatch = new StopWatch(); - stopWatch.start(); - for (final Object data : this.cache) { - super.deliver(EmptyPassOnFilter.OUTPUT_PORT_NAME, data); - } - stopWatch.end(); - System.out.println("dur: " + TimeUnit.NANOSECONDS.toMillis(stopWatch.getDurationInNs()) + " ms"); - super.terminate(error); - } - - @Override - public Configuration getCurrentConfiguration() { - return new Configuration(); - } - - @InputPort(name = CacheFilter.INPUT_PORT_NAME) - public void input(final Object data) { - this.cache.add(data); - } - -} diff --git a/src/main/java/kieker/analysis/stage/CollectorSink.java b/src/main/java/kieker/analysis/stage/CollectorSink.java deleted file mode 100644 index 279c471610d8de9cab7e9fb6f8c5ee64e7958b16..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/analysis/stage/CollectorSink.java +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.stage; - -import java.util.Collection; - -import kieker.analysis.IProjectContext; -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.common.configuration.Configuration; - -public class CollectorSink<T> extends AbstractFilterPlugin { - - public static final String INPUT_PORT_NAME = "input"; - - private static final int THRESHOLD = 10000; - - private Collection<T> objects; - - public CollectorSink(final Configuration configuration, final IProjectContext projectContext, final Collection<T> collection) { - super(configuration, projectContext); - this.objects = collection; - } - - @InputPort(name = CollectorSink.INPUT_PORT_NAME) - public void execute(final T object) { - this.objects.add(object); - if ((this.objects.size() % THRESHOLD) == 0) { - System.out.println("size: " + this.objects.size()); - } - } - - public Collection<T> getObjects() { - return this.objects; - } - - public void setObjects(final Collection<T> objects) { - this.objects = objects; - } - - @Override - public Configuration getCurrentConfiguration() { - return new Configuration(); - } - -} diff --git a/src/main/java/kieker/analysis/stage/EmptyPassOnFilter.java b/src/main/java/kieker/analysis/stage/EmptyPassOnFilter.java deleted file mode 100644 index f535034901ff9fed49c13b2e7e04ad122c2fdfbd..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/analysis/stage/EmptyPassOnFilter.java +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.stage; - -import kieker.analysis.IProjectContext; -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.common.configuration.Configuration; - - -/** - * @author Nils Christian Ehmke - * - * @since 1.10 - */ -@Plugin(outputPorts = @OutputPort(name = EmptyPassOnFilter.OUTPUT_PORT_NAME)) -public class EmptyPassOnFilter extends AbstractFilterPlugin { - - public static final String INPUT_PORT_NAME = "input"; - public static final String OUTPUT_PORT_NAME = "output"; - - public EmptyPassOnFilter(final Configuration configuration, final IProjectContext projectContext) { - super(configuration, projectContext); - } - - @Override - public Configuration getCurrentConfiguration() { - return new Configuration(); - } - - @InputPort(name = EmptyPassOnFilter.INPUT_PORT_NAME) - public void input(final Object data) { - super.deliver(EmptyPassOnFilter.OUTPUT_PORT_NAME, data); - } - -} diff --git a/src/main/java/kieker/analysis/stage/ObjectProducer.java b/src/main/java/kieker/analysis/stage/ObjectProducer.java deleted file mode 100644 index 515ae0fc08070dbe8f63a86f8fb1908e10f3a2e3..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/analysis/stage/ObjectProducer.java +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.stage; - -import java.util.concurrent.Callable; - -import kieker.analysis.IProjectContext; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.annotation.Property; -import kieker.analysis.plugin.reader.AbstractReaderPlugin; -import kieker.common.configuration.Configuration; - - -@Plugin( - outputPorts = @OutputPort(name = ObjectProducer.OUTPUT_PORT_NAME), - configuration = @Property(name = ObjectProducer.CONFIG_PROPERTY_NAME_OBJECTS_TO_CREATE, defaultValue = "100")) -public class ObjectProducer<T> extends AbstractReaderPlugin { - - public static final String CONFIG_PROPERTY_NAME_OBJECTS_TO_CREATE = "numObjectsToCreate"; - public static final String OUTPUT_PORT_NAME = "output"; - - private Callable<T> objectCreator; - private long numObjectsToCreate; - - public ObjectProducer(final Configuration configuration, final IProjectContext projectContext, final Callable<T> objectCreator) { - super(configuration, projectContext); - - this.numObjectsToCreate = configuration.getLongProperty(CONFIG_PROPERTY_NAME_OBJECTS_TO_CREATE); - this.objectCreator = objectCreator; - } - - public Callable<T> getObjectCreator() { - return this.objectCreator; - } - - public void setObjectCreator(final Callable<T> objectCreator) { - this.objectCreator = objectCreator; - } - - public long getNumObjectsToCreate() { - return this.numObjectsToCreate; - } - - public void setNumObjectsToCreate(final long numObjectsToCreate) { - this.numObjectsToCreate = numObjectsToCreate; - } - - @Override - public boolean read() { - for (int idx = 0; idx < this.numObjectsToCreate; idx++) { - try { - final T newObject = this.objectCreator.call(); - super.deliver(OUTPUT_PORT_NAME, newObject); - } catch (final Exception e) { - throw new IllegalStateException(); - } - } - - return true; - } - - @Override - public void terminate(final boolean error) { - // Nothing to do - } - - @Override - public Configuration getCurrentConfiguration() { - final Configuration configuration = new Configuration(); - configuration.setProperty(CONFIG_PROPERTY_NAME_OBJECTS_TO_CREATE, Long.toString(this.numObjectsToCreate)); - return configuration; - } - -} diff --git a/src/main/java/kieker/analysis/stage/StartTimestampFilter.java b/src/main/java/kieker/analysis/stage/StartTimestampFilter.java deleted file mode 100644 index c82b0ff6d4c93d30b58498c468884257e245729d..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/analysis/stage/StartTimestampFilter.java +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.stage; - -import teetime.util.TimestampObject; - -import kieker.analysis.IProjectContext; -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.common.configuration.Configuration; - -@Plugin(outputPorts = @OutputPort(name = StartTimestampFilter.OUTPUT_PORT_NAME)) -public class StartTimestampFilter extends AbstractFilterPlugin { - - public static final String INPUT_PORT_NAME = "input"; - public static final String OUTPUT_PORT_NAME = "output"; - - public StartTimestampFilter(final Configuration configuration, final IProjectContext projectContext) { - super(configuration, projectContext); - } - - @InputPort(name = StartTimestampFilter.INPUT_PORT_NAME) - public void execute(final TimestampObject inputObject) { - inputObject.setStartTimestamp(System.nanoTime()); - super.deliver(StartTimestampFilter.OUTPUT_PORT_NAME, inputObject); - } - - @Override - public Configuration getCurrentConfiguration() { - return new Configuration(); - } - -} diff --git a/src/main/java/kieker/analysis/stage/StopTimestampFilter.java b/src/main/java/kieker/analysis/stage/StopTimestampFilter.java deleted file mode 100644 index 77eeb95c4a94e904da9c6ed45bff43c8e60f3e34..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/analysis/stage/StopTimestampFilter.java +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.stage; - -import teetime.util.TimestampObject; - -import kieker.analysis.IProjectContext; -import kieker.analysis.plugin.annotation.InputPort; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.common.configuration.Configuration; - -@Plugin(outputPorts = @OutputPort(name = StopTimestampFilter.OUTPUT_PORT_NAME)) -public class StopTimestampFilter extends AbstractFilterPlugin { - - public static final String INPUT_PORT_NAME = "input"; - public static final String OUTPUT_PORT_NAME = "output"; - - public StopTimestampFilter(final Configuration configuration, final IProjectContext projectContext) { - super(configuration, projectContext); - } - - @InputPort(name = StopTimestampFilter.INPUT_PORT_NAME) - public void execute(final TimestampObject inputObject) { - inputObject.setStopTimestamp(System.nanoTime()); - super.deliver(StartTimestampFilter.OUTPUT_PORT_NAME, inputObject); - } - - @Override - public Configuration getCurrentConfiguration() { - return new Configuration(); - } - -} diff --git a/src/main/java/kieker/analysis/stage/TimeReader.java b/src/main/java/kieker/analysis/stage/TimeReader.java deleted file mode 100644 index 30ec2b5577063225e951875c014f33c469793f16..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/analysis/stage/TimeReader.java +++ /dev/null @@ -1,185 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package kieker.analysis.stage; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import kieker.analysis.IProjectContext; -import kieker.analysis.plugin.annotation.OutputPort; -import kieker.analysis.plugin.annotation.Plugin; -import kieker.analysis.plugin.annotation.Property; -import kieker.analysis.plugin.reader.AbstractReaderPlugin; -import kieker.common.configuration.Configuration; -import kieker.common.record.misc.TimestampRecord; - -@Plugin( - description = "Delivers the current (system) time in regular intervals", - outputPorts = { - @OutputPort(name = TimeReader.OUTPUT_PORT_NAME_TIMESTAMPS, eventTypes = Long.class), - @OutputPort(name = TimeReader.OUTPUT_PORT_NAME_TIMESTAMP_RECORDS, eventTypes = TimestampRecord.class) - }, - configuration = { - @Property(name = TimeReader.CONFIG_PROPERTY_NAME_UPDATE_INTERVAL_NS, defaultValue = TimeReader.CONFIG_PROPERTY_VALUE_UPDATE_INTERVAL_NS, - description = "Determines the update interval in nano seconds."), - @Property(name = TimeReader.CONFIG_PROPERTY_NAME_DELAY_NS, defaultValue = TimeReader.CONFIG_PROPERTY_VALUE_DELAY_NS, - description = "Determines the initial delay in nano seconds."), - @Property(name = TimeReader.CONFIG_PROPERTY_NAME_NUMBER_IMPULSES, defaultValue = TimeReader.CONFIG_PROPERTY_VALUE_NUMBER_IMPULSES, - description = "Determines the number of impulses to emit (0 = infinite).") - }) -public final class TimeReader extends AbstractReaderPlugin { - - /** The name of the output port for the timestamps. */ - public static final String OUTPUT_PORT_NAME_TIMESTAMPS = "timestamps"; - /** The name of the output port for the timestamp records. */ - public static final String OUTPUT_PORT_NAME_TIMESTAMP_RECORDS = "timestampRecords"; - - /** The name of the property determining the update interval in nanoseconds. */ - public static final String CONFIG_PROPERTY_NAME_UPDATE_INTERVAL_NS = "updateIntervalNS"; - /** The default value for the update interval (1 second). */ - public static final String CONFIG_PROPERTY_VALUE_UPDATE_INTERVAL_NS = "1000000000"; - - /** The name of the property determining the initial delay in nanoseconds. */ - public static final String CONFIG_PROPERTY_NAME_DELAY_NS = "delayNS"; - /** The default value for the initial delay (0 seconds). */ - public static final String CONFIG_PROPERTY_VALUE_DELAY_NS = "0"; - - /** The name of the property determining the number of impulses to emit. */ - public static final String CONFIG_PROPERTY_NAME_NUMBER_IMPULSES = "numberImpulses"; - /** The default value for number of impulses (infinite). */ - public static final String CONFIG_PROPERTY_VALUE_NUMBER_IMPULSES = "0"; - - /** A value for the number of impulses. It makes sure that the reader emits an infinite amount of signals. */ - public static final long INFINITE_EMITS = 0L; - - final CountDownLatch impulseEmitLatch = new CountDownLatch(1); // NOCS NOPMD (package visible) - - private volatile boolean terminated; - - private final ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1); - private volatile ScheduledFuture<?> result; - - private final long initialDelay; - private final long period; - private final long numberImpulses; - - /** - * Creates a new timer using the given configuration. - * - * @param configuration - * The configuration containing the properties to initialize this timer. - * @param projectContext - * The project context. - */ - public TimeReader(final Configuration configuration, final IProjectContext projectContext) { - super(configuration, projectContext); - this.initialDelay = configuration.getLongProperty(CONFIG_PROPERTY_NAME_DELAY_NS); - this.period = configuration.getLongProperty(CONFIG_PROPERTY_NAME_UPDATE_INTERVAL_NS); - this.numberImpulses = configuration.getLongProperty(CONFIG_PROPERTY_NAME_NUMBER_IMPULSES); - } - - /** - * {@inheritDoc} - */ - @Override - public void terminate(final boolean error) { - if (!this.terminated) { - this.log.info("Shutdown of TimeReader requested."); - this.executorService.shutdown(); - try { - this.terminated = this.executorService.awaitTermination(5, TimeUnit.SECONDS); - } catch (final InterruptedException ex) { - // ignore - } - if (!this.terminated && (this.result != null)) { - // problems shutting down - this.result.cancel(true); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean read() { - this.result = this.executorService.scheduleAtFixedRate(new TimestampEventTask(this.numberImpulses), this.initialDelay, this.period, TimeUnit.NANOSECONDS); - - return true; - } - - @Override - public Configuration getCurrentConfiguration() { - final Configuration configuration = new Configuration(); - configuration.setProperty(CONFIG_PROPERTY_NAME_DELAY_NS, Long.toString(this.initialDelay)); - configuration.setProperty(CONFIG_PROPERTY_NAME_UPDATE_INTERVAL_NS, Long.toString(this.period)); - configuration.setProperty(CONFIG_PROPERTY_NAME_NUMBER_IMPULSES, Long.toString(this.numberImpulses)); - return configuration; - } - - /** - * Sends the current system time as a new timestamp event. - */ - protected void sendTimestampEvent() { - final long timestamp = super.recordsTimeUnitFromProjectContext.convert(System.nanoTime(), TimeUnit.NANOSECONDS); - super.deliver(OUTPUT_PORT_NAME_TIMESTAMPS, timestamp); - super.deliver(OUTPUT_PORT_NAME_TIMESTAMP_RECORDS, new TimestampRecord(timestamp)); - } - - /** - * A simple helper class used to send the current system time. - * - * @author Nils Christian Ehmke - * - * @since 1.8 - */ - protected class TimestampEventTask implements Runnable { - private final boolean infinite; - private volatile long numberImpulses; - - /** - * Creates a new task. - * - * @param numberImpulses - * 0 = infinite - */ - public TimestampEventTask(final long numberImpulses) { - this.numberImpulses = numberImpulses; - if (numberImpulses == 0) { - this.infinite = true; - } else { - this.infinite = false; - } - } - - /** - * Executes the task. - */ - @Override - public void run() { - if (this.infinite || (this.numberImpulses > 0)) { - TimeReader.this.sendTimestampEvent(); - if (!this.infinite && (0 == --this.numberImpulses)) { // NOPMD - TimeReader.this.impulseEmitLatch.countDown(); - } - } - } - } -} diff --git a/src/main/java/kieker/common/exception/IllegalRecordFormatException.java b/src/main/java/kieker/common/exception/IllegalRecordFormatException.java deleted file mode 100644 index 034404fd43df0fba57903eaca38791662b903f02..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/common/exception/IllegalRecordFormatException.java +++ /dev/null @@ -1,32 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package kieker.common.exception; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class IllegalRecordFormatException extends Exception { - - private static final long serialVersionUID = -6747714448544097075L; - - public IllegalRecordFormatException() { - // No code necessary - } - -} diff --git a/src/main/java/kieker/common/exception/MonitoringRecordException.java b/src/main/java/kieker/common/exception/MonitoringRecordException.java deleted file mode 100644 index 50cbaccb08e937aa47f26154a9bef8a382fa9aca..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/common/exception/MonitoringRecordException.java +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package kieker.common.exception; - -/** - * This exception can be used to show that something in context with a monitoring record failed. - * - * @author Jan Waller - * - * @since 1.0 - */ -public class MonitoringRecordException extends Exception { - - private static final long serialVersionUID = -619093518689867366L; - - /** - * Creates a new instance of this class using the given parameters. - * - * @param messString - * The message of this exception. - */ - public MonitoringRecordException(final String messString) { - super(messString); - } - - /** - * Creates a new instance of this class using the given parameters. - * - * @param messString - * The message of this exception. - * @param cause - * The cause of this exception. - */ - public MonitoringRecordException(final String messString, final Throwable cause) { - super(messString, cause); - } -} diff --git a/src/main/java/kieker/common/exception/UnknownRecordTypeException.java b/src/main/java/kieker/common/exception/UnknownRecordTypeException.java deleted file mode 100644 index f365f75be7b2f88e0f379e0d0c27ec9cc94b4578..0000000000000000000000000000000000000000 --- a/src/main/java/kieker/common/exception/UnknownRecordTypeException.java +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package kieker.common.exception; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class UnknownRecordTypeException extends Exception { - - private static final long serialVersionUID = 3967732396720668295L; - private final String classname; - - public UnknownRecordTypeException(final String message, final String classname, final Throwable cause) { - super(message, cause); - this.classname = classname; - } - - public String getClassName() { - return this.classname; - } -} diff --git a/src/main/java/teetime/stage/explorviz/KiekerRecordTcpReader.java b/src/main/java/teetime/stage/explorviz/KiekerRecordTcpReader.java deleted file mode 100644 index cd0aa5162e8f70ae2987b029fd3aac244fe35dd6..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/explorviz/KiekerRecordTcpReader.java +++ /dev/null @@ -1,229 +0,0 @@ -package teetime.stage.explorviz; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.nio.BufferUnderflowException; -import java.nio.ByteBuffer; -import java.nio.channels.ServerSocketChannel; -import java.nio.channels.SocketChannel; -import java.util.ArrayList; -import java.util.List; - -import teetime.framework.ProducerStage; - -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.flow.trace.operation.AfterOperationEvent; -import kieker.common.record.flow.trace.operation.BeforeOperationEvent; -import kieker.common.util.registry.ILookup; -import kieker.common.util.registry.Lookup; - -public class KiekerRecordTcpReader extends ProducerStage<IMonitoringRecord> { - - private static final int MESSAGE_BUFFER_SIZE = 65535; - - private static final byte HostApplicationMetaDataRecord_CLAZZ_ID = 0; - private static final byte BeforeOperationEventRecord_CLAZZ_ID = 1; - private static final byte AfterOperationEventRecord_CLAZZ_ID = 3; - private static final byte StringRegistryRecord_CLAZZ_ID = 4; - - private static final int HostApplicationMetaDataRecord_BYTE_LENGTH = 16; - private static final int BeforeOperationEventRecord_COMPRESSED_BYTE_LENGTH = 36; - private static final int AfterOperationEventRecord_COMPRESSED_BYTE_LENGTH = 20; - - private final ILookup<String> stringRegistry = new Lookup<String>(); - - private final List<byte[]> waitingForStringMessages = new ArrayList<byte[]>(1024); - - private int port1 = 10133; - - public final int getPort1() { - return this.port1; - } - - public final void setPort1(final int port1) { - this.port1 = port1; - } - - @Override - protected void execute() { - ServerSocketChannel serversocket = null; - try { - serversocket = ServerSocketChannel.open(); - serversocket.socket().bind(new InetSocketAddress(this.port1)); - if (super.logger.isDebugEnabled()) { - super.logger.debug("Listening on port " + this.port1); - } - // BEGIN also loop this one? - final SocketChannel socketChannel = serversocket.accept(); - final ByteBuffer buffer = ByteBuffer.allocateDirect(MESSAGE_BUFFER_SIZE); - while (socketChannel.read(buffer) != -1) { - buffer.flip(); - // System.out.println("Reading, remaining:" + buffer.remaining()); - try { - while (buffer.hasRemaining()) { - buffer.mark(); - this.messagesfromByteArray(buffer); - } - buffer.clear(); - } catch (final BufferUnderflowException ex) { - buffer.reset(); - // System.out.println("Underflow, remaining:" + buffer.remaining()); - buffer.compact(); - } - } - // System.out.println("Channel closing..."); - socketChannel.close(); - // END also loop this one? - } catch (final IOException ex) { - super.logger.error("Error while reading", ex); - } finally { - if (null != serversocket) { - try { - serversocket.close(); - } catch (final IOException e) { - if (super.logger.isDebugEnabled()) { - super.logger.debug("Failed to close TCP connection!", e); - } - } - } - - this.terminate(); - } - } - - private final void messagesfromByteArray(final ByteBuffer buffer) { - final byte clazzId = buffer.get(); - switch (clazzId) { - case HostApplicationMetaDataRecord_CLAZZ_ID: { - if (buffer.remaining() >= HostApplicationMetaDataRecord_BYTE_LENGTH) { - this.readInHostApplicationMetaData(buffer); - break; - } - buffer.position(buffer.position() - 1); - buffer.compact(); - return; - } - case BeforeOperationEventRecord_CLAZZ_ID: { - if (buffer.remaining() >= BeforeOperationEventRecord_COMPRESSED_BYTE_LENGTH) { - this.readInBeforeOperationEvent(buffer); - break; - } - buffer.position(buffer.position() - 1); - buffer.compact(); - return; - } - case AfterOperationEventRecord_CLAZZ_ID: { - if (buffer.remaining() >= AfterOperationEventRecord_COMPRESSED_BYTE_LENGTH) { - this.readInAfterOperationEvent(buffer); - break; - } - buffer.position(buffer.position() - 1); - buffer.compact(); - return; - } - case StringRegistryRecord_CLAZZ_ID: { - int mapId = 0; - int stringLength = 0; - if (buffer.remaining() >= 8) { - mapId = buffer.getInt(); - stringLength = buffer.getInt(); - } else { - buffer.position(buffer.position() - 1); - buffer.compact(); - return; - } - - if (buffer.remaining() >= stringLength) { - final byte[] stringByteArray = new byte[stringLength]; - - buffer.get(stringByteArray); - - this.stringRegistry.set(new String(stringByteArray), mapId); - - this.checkWaitingMessages(); - } else { - buffer.position(buffer.position() - 9); - buffer.compact(); - return; - } - break; - } - default: { - System.out.println("unknown class id " + clazzId + " at offset " - + (buffer.position() - 1)); - return; - } - } - } - - private final void readInHostApplicationMetaData(final ByteBuffer buffer) { - final int systemnameId = buffer.getInt(); - final int ipaddressId = buffer.getInt(); - final int hostnameId = buffer.getInt(); - final int applicationId = buffer.getInt(); - // just consume; not necessary for kieker - } - - private final void readInBeforeOperationEvent(final ByteBuffer buffer) { - final long timestamp = buffer.getLong(); - final long traceId = buffer.getLong(); - final int orderIndex = buffer.getInt(); - final int objectId = buffer.getInt(); - final int operationId = buffer.getInt(); - final int clazzId = buffer.getInt(); - final int interfaceId = buffer.getInt(); - - final String operation = this.stringRegistry.get(operationId); - final String clazz = this.stringRegistry.get(clazzId); - if (operation == null || clazz == null) { - this.putInWaitingMessages(buffer, BeforeOperationEventRecord_COMPRESSED_BYTE_LENGTH + 1); - return; - } - - final IMonitoringRecord record = new BeforeOperationEvent(timestamp, traceId, orderIndex, operation, clazz); - this.send(this.outputPort, record); - } - - private final void readInAfterOperationEvent(final ByteBuffer buffer) { - final long timestamp = buffer.getLong(); - final long traceId = buffer.getLong(); - final int orderIndex = buffer.getInt(); - - final IMonitoringRecord record = new AfterOperationEvent(timestamp, traceId, orderIndex, null, null); - this.send(this.outputPort, record); - } - - private final void putInWaitingMessages(final ByteBuffer buffer, final int length) { - final byte[] message = new byte[length]; - buffer.position(buffer.position() - length); - buffer.get(message); - this.waitingForStringMessages.add(message); - } - - private final void checkWaitingMessages() { - final List<byte[]> localWaitingList = new ArrayList<byte[]>(); - for (final byte[] waitingMessage : this.waitingForStringMessages) { - localWaitingList.add(waitingMessage); - } - this.waitingForStringMessages.clear(); - - for (final byte[] waitingMessage : localWaitingList) { - final ByteBuffer buffer = ByteBuffer.wrap(waitingMessage); - final byte waitingMessageClazzId = buffer.get(); - switch (waitingMessageClazzId) { - case HostApplicationMetaDataRecord_CLAZZ_ID: - this.readInHostApplicationMetaData(buffer); - break; - case BeforeOperationEventRecord_CLAZZ_ID: - this.readInBeforeOperationEvent(buffer); - break; - case AfterOperationEventRecord_CLAZZ_ID: - this.readInAfterOperationEvent(buffer); - break; - default: - break; - } - } - } - -} diff --git a/src/main/java/teetime/stage/io/DbReader.java b/src/main/java/teetime/stage/io/DbReader.java deleted file mode 100644 index 82ced4e9bb1b446df8f2eb03c12a142f56bcfd26..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/io/DbReader.java +++ /dev/null @@ -1,187 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package teetime.stage.io; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import teetime.framework.ProducerStage; - -import kieker.common.exception.MonitoringRecordException; -import kieker.common.record.AbstractMonitoringRecord; -import kieker.common.record.IMonitoringRecord; - -/** - * A very simple database reader that probably only works for small data sets. - * - * @author Jan Waller, Nils Christian Ehmke - * - * @since 1.10 - */ -// @Description("A reader which reads records from a database") -public class DbReader extends ProducerStage<IMonitoringRecord> { - - /** - * The classname of the driver used for the connection. - */ - private String driverClassname = "org.apache.derby.jdbc.EmbeddedDrive"; - - /** - * The connection string used to establish the connection. - */ - private String connectionString = "jdbc:derby:tmp/KIEKER;user=DBUSER;password=DBPASS"; - - /** - * The prefix of the used table within the database. - */ - private String tablePrefix = "kieker"; - - private volatile boolean running = true; - - @Override - public void onStarting() { - try { - Class.forName(this.driverClassname).newInstance(); - } catch (final Exception ex) { // NOPMD NOCS (IllegalCatchCheck) - throw new RuntimeException("DB driver registration failed. Perhaps the driver jar is missing?", ex); - } - } - - // @Override // TODO implement onStop - // public void onPipelineStops() { - // super.logger.info("Shutdown of DBReader requested."); - // this.running = false; - // super.onPipelineStops(); - // } - - @Override - protected void execute() { - Connection connection = null; - try { - connection = DriverManager.getConnection(this.connectionString); - Statement getIndexTable = null; - try { - getIndexTable = connection.createStatement(); - ResultSet indexTable = null; - try { // NOCS (nested try) - indexTable = getIndexTable.executeQuery("SELECT * from " + this.tablePrefix); - while (this.running && indexTable.next()) { - final String tablename = indexTable.getString(1); - final String classname = indexTable.getString(2); - try { // NOCS (nested try) - this.table2record(connection, tablename, AbstractMonitoringRecord.classForName(classname)); - } catch (final MonitoringRecordException ex) { - // log error but continue with next table - super.logger.error("Failed to load records of type " + classname + " from table " + tablename, ex); - continue; - } - } - } finally { - if (indexTable != null) { - indexTable.close(); - } - } - } finally { - if (getIndexTable != null) { - getIndexTable.close(); - } - } - } catch (final SQLException ex) { - super.logger.error("SQLException with SQLState: '" + ex.getSQLState() + "' and VendorError: '" + ex.getErrorCode() + "'", ex); - } finally { - if (connection != null) { - try { - connection.close(); - } catch (final SQLException ex) { - super.logger.error("SQLException with SQLState: '" + ex.getSQLState() + "' and VendorError: '" + ex.getErrorCode() + "'", ex); - } - } - } - } - - public final String getDriverClassname() { - return this.driverClassname; - } - - public final void setDriverClassname(final String driverClassname) { - this.driverClassname = driverClassname; - } - - public final String getConnectionString() { - return this.connectionString; - } - - public final void setConnectionString(final String connectionString) { - this.connectionString = connectionString; - } - - public final String getTablePrefix() { - return this.tablePrefix; - } - - public final void setTablePrefix(final String tablePrefix) { - this.tablePrefix = tablePrefix; - } - - /** - * This method uses the given table to read records and sends them to the output port. - * - * @param connection - * The connection to the database which will be used. - * @param tablename - * The name of the table containing records. - * @param clazz - * The class of the monitoring records. This will be used to convert the array into the record. - * @throws SQLException - * If something went wrong during the database access. - * @throws MonitoringRecordException - * If the data within the table could not be converted into a valid record. - */ - private void table2record(final Connection connection, final String tablename, final Class<? extends IMonitoringRecord> clazz) - throws SQLException, MonitoringRecordException { - Statement selectRecord = null; - try { - selectRecord = connection.createStatement(); - ResultSet records = null; - try { - records = selectRecord.executeQuery("SELECT * from " + tablename); - final int size = records.getMetaData().getColumnCount() - 2; // remove index column - while (this.running && records.next()) { - final Object[] recordValues = new Object[size]; - for (int i = 0; i < size; i++) { - recordValues[i] = records.getObject(i + 3); - } - final IMonitoringRecord record = AbstractMonitoringRecord.createFromArray(clazz, recordValues); - record.setLoggingTimestamp(records.getLong(2)); - this.send(this.outputPort, record); - } - } finally { - if (records != null) { - records.close(); - } - } - } finally { - if (selectRecord != null) { - selectRecord.close(); - } - } - } - -} diff --git a/src/main/java/teetime/stage/io/IRecordFactoryMethod.java b/src/main/java/teetime/stage/io/IRecordFactoryMethod.java deleted file mode 100644 index 10849cd49654ddb762f835a01f4214419c659aa6..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/io/IRecordFactoryMethod.java +++ /dev/null @@ -1,12 +0,0 @@ -package teetime.stage.io; - -import java.nio.ByteBuffer; - -import kieker.common.record.IMonitoringRecord; -import kieker.common.util.registry.ILookup; - -public interface IRecordFactoryMethod { - - IMonitoringRecord create(ByteBuffer buffer, ILookup<String> stringRegistry); - -} diff --git a/src/main/java/teetime/stage/io/RecordFactory.java b/src/main/java/teetime/stage/io/RecordFactory.java deleted file mode 100644 index 0d012dbcf83cd872520eebc04259f082bbafdb19..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/io/RecordFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -package teetime.stage.io; - -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Map; - -import kieker.common.exception.MonitoringRecordException; -import kieker.common.record.IMonitoringRecord; -import kieker.common.util.registry.ILookup; - -public final class RecordFactory { - - private final Map<String, IRecordFactoryMethod> recordFactoryMethods = new HashMap<String, IRecordFactoryMethod>(); - - public IMonitoringRecord create(final int clazzId, final ByteBuffer buffer, final ILookup<String> stringRegistry) throws MonitoringRecordException { - String recordClassName = stringRegistry.get(clazzId); - IRecordFactoryMethod recordFactoryMethod = this.recordFactoryMethods.get(recordClassName); - if (recordFactoryMethod == null) { - throw new IllegalStateException("recordClassName: " + recordClassName); - } - return recordFactoryMethod.create(buffer, stringRegistry); - } - - public void register(final String recordClassName, final IRecordFactoryMethod recordFactoryMethod) { - this.recordFactoryMethods.put(recordClassName, recordFactoryMethod); - } -} diff --git a/src/main/java/teetime/stage/io/TCPReader.java b/src/main/java/teetime/stage/io/TCPReader.java deleted file mode 100644 index ee2d8d5b8f96b9fa009dbce20f623c1852e946a0..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/io/TCPReader.java +++ /dev/null @@ -1,258 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.io; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.nio.BufferUnderflowException; -import java.nio.ByteBuffer; -import java.nio.channels.ClosedByInterruptException; -import java.nio.channels.ServerSocketChannel; -import java.nio.channels.SocketChannel; - -import teetime.framework.ProducerStage; - -import kieker.common.exception.MonitoringRecordException; -import kieker.common.logging.Log; -import kieker.common.logging.LogFactory; -import kieker.common.record.AbstractMonitoringRecord; -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.flow.trace.TraceMetadata; -import kieker.common.record.flow.trace.operation.AfterOperationEvent; -import kieker.common.record.flow.trace.operation.BeforeOperationEvent; -import kieker.common.record.flow.trace.operation.CallOperationEvent; -import kieker.common.record.misc.KiekerMetadataRecord; -import kieker.common.record.misc.RegistryRecord; -import kieker.common.util.registry.ILookup; -import kieker.common.util.registry.Lookup; - -/** - * This is a reader which reads the records from a TCP port. - * - * @author Jan Waller, Nils Christian Ehmke - * - * @since 1.10 - */ -public class TCPReader extends ProducerStage<IMonitoringRecord> { - - private static final int MESSAGE_BUFFER_SIZE = 65535; - - // BETTER use a non thread-safe implementation to increase performance. A thread-safe version is not necessary. - private final ILookup<String> stringRegistry = new Lookup<String>(); - private int port1 = 10133; - private int port2 = 10134; - - private TCPStringReader tcpStringReader; - - private RecordFactory recordFactory; - - public final int getPort1() { - return this.port1; - } - - public final void setPort1(final int port1) { - this.port1 = port1; - } - - public final int getPort2() { - return this.port2; - } - - public final void setPort2(final int port2) { - this.port2 = port2; - } - - @Override - public void onStarting() { - this.recordFactory = new RecordFactory(); - this.register(); - - this.tcpStringReader = new TCPStringReader(this.port2, this.stringRegistry); - this.tcpStringReader.start(); - super.onStarting(); - } - - private void register() { - this.recordFactory.register(TraceMetadata.class.getCanonicalName(), new IRecordFactoryMethod() { - @Override - public IMonitoringRecord create(final ByteBuffer buffer, final ILookup<String> stringRegistry) { - return new TraceMetadata(buffer, stringRegistry); - } - }); - - this.recordFactory.register(KiekerMetadataRecord.class.getCanonicalName(), new IRecordFactoryMethod() { - @Override - public IMonitoringRecord create(final ByteBuffer buffer, final ILookup<String> stringRegistry) { - return new KiekerMetadataRecord(buffer, stringRegistry); - } - }); - - this.recordFactory.register(BeforeOperationEvent.class.getCanonicalName(), new IRecordFactoryMethod() { - @Override - public IMonitoringRecord create(final ByteBuffer buffer, final ILookup<String> stringRegistry) { - return new BeforeOperationEvent(buffer, stringRegistry); - } - }); - - this.recordFactory.register(AfterOperationEvent.class.getCanonicalName(), new IRecordFactoryMethod() { - @Override - public IMonitoringRecord create(final ByteBuffer buffer, final ILookup<String> stringRegistry) { - return new AfterOperationEvent(buffer, stringRegistry); - } - }); - - this.recordFactory.register(CallOperationEvent.class.getCanonicalName(), new IRecordFactoryMethod() { - @Override - public IMonitoringRecord create(final ByteBuffer buffer, final ILookup<String> stringRegistry) { - return new CallOperationEvent(buffer, stringRegistry); - } - }); - } - - @Override - protected void execute() { - ServerSocketChannel serversocket = null; - try { - serversocket = ServerSocketChannel.open(); - serversocket.socket().bind(new InetSocketAddress(this.port1)); - if (super.logger.isDebugEnabled()) { - super.logger.debug("Listening on port " + this.port1); - } - // BEGIN also loop this one? - final SocketChannel socketChannel = serversocket.accept(); - final ByteBuffer buffer = ByteBuffer.allocateDirect(MESSAGE_BUFFER_SIZE); - while (socketChannel.read(buffer) != -1) { - buffer.flip(); - // System.out.println("Reading, remaining:" + buffer.remaining()); - try { - while (buffer.hasRemaining()) { - buffer.mark(); - this.createAndSendRecord(buffer); - } - buffer.clear(); - } catch (final BufferUnderflowException ex) { - buffer.reset(); - // System.out.println("Underflow, remaining:" + buffer.remaining()); - buffer.compact(); - } - } - // System.out.println("Channel closing..."); - socketChannel.close(); - // END also loop this one? - } catch (final IOException ex) { - super.logger.error("Error while reading", ex); - } finally { - if (null != serversocket) { - try { - serversocket.close(); - } catch (final IOException e) { - if (super.logger.isDebugEnabled()) { - super.logger.debug("Failed to close TCP connection!", e); - } - } - } - - this.terminate(); - this.tcpStringReader.terminate(); - } - } - - private final void createAndSendRecord(final ByteBuffer buffer) { - final int clazzid = buffer.getInt(); - final long loggingTimestamp = buffer.getLong(); - try { - // record = this.recordFactory.create(clazzid, buffer, this.stringRegistry); - final IMonitoringRecord record = AbstractMonitoringRecord.createFromByteBuffer(clazzid, buffer, this.stringRegistry); - record.setLoggingTimestamp(loggingTimestamp); - this.send(this.outputPort, record); - } catch (final MonitoringRecordException ex) { - super.logger.error("Failed to create record.", ex); - } - } - - /** - * - * @author Jan Waller - * - * @since 1.8 - */ - private static class TCPStringReader extends Thread { - - private static final int MESSAGE_BUFFER_SIZE = 65535; - - private static final Log LOG = LogFactory.getLog(TCPStringReader.class); - - private final int port; - private final ILookup<String> stringRegistry; - private volatile boolean terminated = false; // NOPMD - private volatile Thread readerThread; - - public TCPStringReader(final int port, final ILookup<String> stringRegistry) { - this.port = port; - this.stringRegistry = stringRegistry; - } - - public void terminate() { - this.terminated = true; - this.readerThread.interrupt(); - } - - @Override - public void run() { - this.readerThread = Thread.currentThread(); - ServerSocketChannel serversocket = null; - try { - serversocket = ServerSocketChannel.open(); - serversocket.socket().bind(new InetSocketAddress(this.port)); - if (LOG.isDebugEnabled()) { - LOG.debug("Listening on port " + this.port); - } - // BEGIN also loop this one? - final SocketChannel socketChannel = serversocket.accept(); - final ByteBuffer buffer = ByteBuffer.allocateDirect(MESSAGE_BUFFER_SIZE); - while ((socketChannel.read(buffer) != -1) && (!this.terminated)) { - buffer.flip(); - try { - while (buffer.hasRemaining()) { - buffer.mark(); - RegistryRecord.registerRecordInRegistry(buffer, this.stringRegistry); - } - buffer.clear(); - } catch (final BufferUnderflowException ex) { - buffer.reset(); - buffer.compact(); - } - } - socketChannel.close(); - // END also loop this one? - } catch (final ClosedByInterruptException ex) { - LOG.warn("Reader interrupted", ex); - } catch (final IOException ex) { - LOG.error("Error while reading", ex); - } finally { - if (null != serversocket) { - try { - serversocket.close(); - } catch (final IOException e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Failed to close TCP connection!", e); - } - } - } - } - } - } -} diff --git a/src/main/java/teetime/stage/kieker/Dir2RecordsFilter.java b/src/main/java/teetime/stage/kieker/Dir2RecordsFilter.java deleted file mode 100644 index 15ecff3f80aeedf5dadc27e455f7137edc4f6fa4..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/Dir2RecordsFilter.java +++ /dev/null @@ -1,115 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker; - -import java.io.File; - -import teetime.framework.InputPort; -import teetime.framework.OldPipeline; -import teetime.framework.OutputPort; -import teetime.framework.pipe.IPipeFactory; -import teetime.framework.pipe.PipeFactoryRegistry; -import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering; -import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; -import teetime.stage.FileExtensionSwitch; -import teetime.stage.basic.merger.Merger; -import teetime.stage.io.Directory2FilesFilter; -import teetime.stage.kieker.className.ClassNameRegistryCreationFilter; -import teetime.stage.kieker.className.ClassNameRegistryRepository; -import teetime.stage.kieker.fileToRecord.BinaryFile2RecordFilter; -import teetime.stage.kieker.fileToRecord.DatFile2RecordFilter; -import teetime.stage.kieker.fileToRecord.ZipFile2RecordFilter; - -import kieker.common.record.IMonitoringRecord; -import kieker.common.util.filesystem.BinaryCompressionMethod; -import kieker.common.util.filesystem.FSUtil; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class Dir2RecordsFilter extends OldPipeline<ClassNameRegistryCreationFilter, Merger<IMonitoringRecord>> { - - private final PipeFactoryRegistry pipeFactoryRegistry = PipeFactoryRegistry.INSTANCE; - private ClassNameRegistryRepository classNameRegistryRepository; - - /** - * @since 1.10 - */ - public Dir2RecordsFilter(final ClassNameRegistryRepository classNameRegistryRepository) { - this.classNameRegistryRepository = classNameRegistryRepository; - - // FIXME does not yet work with more than one thread due to classNameRegistryRepository: classNameRegistryRepository is set after the ctor - // create stages - final ClassNameRegistryCreationFilter classNameRegistryCreationFilter = new ClassNameRegistryCreationFilter(this.classNameRegistryRepository); - final Directory2FilesFilter directory2FilesFilter = new Directory2FilesFilter(); - - final FileExtensionSwitch fileExtensionSwitch = new FileExtensionSwitch(); - - final DatFile2RecordFilter datFile2RecordFilter = new DatFile2RecordFilter(this.classNameRegistryRepository); - final BinaryFile2RecordFilter binaryFile2RecordFilter = new BinaryFile2RecordFilter(this.classNameRegistryRepository); - final ZipFile2RecordFilter zipFile2RecordFilter = new ZipFile2RecordFilter(); - - final Merger<IMonitoringRecord> recordMerger = new Merger<IMonitoringRecord>(); - - // store ports due to readability reasons - final OutputPort<File> normalFileOutputPort = fileExtensionSwitch.addFileExtension(FSUtil.NORMAL_FILE_EXTENSION); - final OutputPort<File> binFileOutputPort = fileExtensionSwitch.addFileExtension(BinaryCompressionMethod.NONE.getFileExtension()); - final OutputPort<File> zipFileOutputPort = fileExtensionSwitch.addFileExtension(FSUtil.ZIP_FILE_EXTENSION); - - // connect ports by pipes - IPipeFactory pipeFactory = pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false); - pipeFactory.create(classNameRegistryCreationFilter.getOutputPort(), directory2FilesFilter.getInputPort()); - pipeFactory.create(directory2FilesFilter.getOutputPort(), fileExtensionSwitch.getInputPort()); - - pipeFactory.create(normalFileOutputPort, datFile2RecordFilter.getInputPort()); - pipeFactory.create(binFileOutputPort, binaryFile2RecordFilter.getInputPort()); - pipeFactory.create(zipFileOutputPort, zipFile2RecordFilter.getInputPort()); - - pipeFactory.create(datFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort()); - pipeFactory.create(binaryFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort()); - pipeFactory.create(zipFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort()); - - // prepare pipeline - this.setFirstStage(classNameRegistryCreationFilter); - this.setLastStage(recordMerger); - } - - /** - * @since 1.10 - */ - public Dir2RecordsFilter() { - this(null); - } - - public ClassNameRegistryRepository getClassNameRegistryRepository() { - return this.classNameRegistryRepository; - } - - public void setClassNameRegistryRepository(final ClassNameRegistryRepository classNameRegistryRepository) { - this.classNameRegistryRepository = classNameRegistryRepository; - } - - public InputPort<File> getInputPort() { - return this.getFirstStage().getInputPort(); - } - - public OutputPort<IMonitoringRecord> getOutputPort() { - return this.getLastStage().getOutputPort(); - } - -} diff --git a/src/main/java/teetime/stage/kieker/DirWithBin2RecordFilter.java b/src/main/java/teetime/stage/kieker/DirWithBin2RecordFilter.java deleted file mode 100644 index efe06d6db427d917de5451f05a7fedef6a59bf7f..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/DirWithBin2RecordFilter.java +++ /dev/null @@ -1,49 +0,0 @@ -package teetime.stage.kieker; - -import java.io.File; - -import teetime.framework.InputPort; -import teetime.framework.OutputPort; -import teetime.framework.OldPipeline; -import teetime.stage.io.Directory2FilesFilter; -import teetime.stage.kieker.className.ClassNameRegistryCreationFilter; -import teetime.stage.kieker.className.ClassNameRegistryRepository; -import teetime.stage.kieker.fileToRecord.BinaryFile2RecordFilter; - -import kieker.common.record.IMonitoringRecord; - -public class DirWithBin2RecordFilter extends OldPipeline<ClassNameRegistryCreationFilter, BinaryFile2RecordFilter> { - - private ClassNameRegistryRepository classNameRegistryRepository; - - public DirWithBin2RecordFilter(final ClassNameRegistryRepository classNameRegistryRepository) { - this.classNameRegistryRepository = classNameRegistryRepository; - - final ClassNameRegistryCreationFilter classNameRegistryCreationFilter = new ClassNameRegistryCreationFilter(classNameRegistryRepository); - final Directory2FilesFilter directory2FilesFilter = new Directory2FilesFilter(); - final BinaryFile2RecordFilter binaryFile2RecordFilter = new BinaryFile2RecordFilter(classNameRegistryRepository); - - this.setFirstStage(classNameRegistryCreationFilter); - this.setLastStage(binaryFile2RecordFilter); - } - - public DirWithBin2RecordFilter() { - this(null); - } - - public ClassNameRegistryRepository getClassNameRegistryRepository() { - return this.classNameRegistryRepository; - } - - public void setClassNameRegistryRepository(final ClassNameRegistryRepository classNameRegistryRepository) { - this.classNameRegistryRepository = classNameRegistryRepository; - } - - public InputPort<File> getInputPort() { - return this.getFirstStage().getInputPort(); - } - - public OutputPort<IMonitoringRecord> getOutputPort() { - return this.getLastStage().getOutputPort(); - } -} diff --git a/src/main/java/teetime/stage/kieker/DirWithDat2RecordFilter.java b/src/main/java/teetime/stage/kieker/DirWithDat2RecordFilter.java deleted file mode 100644 index 93fe14f22242b576a818b5cd809fc8d3fd7c0dbe..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/DirWithDat2RecordFilter.java +++ /dev/null @@ -1,49 +0,0 @@ -package teetime.stage.kieker; - -import java.io.File; - -import teetime.framework.InputPort; -import teetime.framework.OutputPort; -import teetime.framework.OldPipeline; -import teetime.stage.io.Directory2FilesFilter; -import teetime.stage.kieker.className.ClassNameRegistryCreationFilter; -import teetime.stage.kieker.className.ClassNameRegistryRepository; -import teetime.stage.kieker.fileToRecord.DatFile2RecordFilter; - -import kieker.common.record.IMonitoringRecord; - -public class DirWithDat2RecordFilter extends OldPipeline<ClassNameRegistryCreationFilter, DatFile2RecordFilter> { - - private ClassNameRegistryRepository classNameRegistryRepository; - - public DirWithDat2RecordFilter(final ClassNameRegistryRepository classNameRegistryRepository) { - this.classNameRegistryRepository = classNameRegistryRepository; - - final ClassNameRegistryCreationFilter classNameRegistryCreationFilter = new ClassNameRegistryCreationFilter(classNameRegistryRepository); - final Directory2FilesFilter directory2FilesFilter = new Directory2FilesFilter(); - final DatFile2RecordFilter datFile2RecordFilter = new DatFile2RecordFilter(classNameRegistryRepository); - - this.setFirstStage(classNameRegistryCreationFilter); - this.setLastStage(datFile2RecordFilter); - } - - public DirWithDat2RecordFilter() { - this(null); - } - - public ClassNameRegistryRepository getClassNameRegistryRepository() { - return this.classNameRegistryRepository; - } - - public void setClassNameRegistryRepository(final ClassNameRegistryRepository classNameRegistryRepository) { - this.classNameRegistryRepository = classNameRegistryRepository; - } - - public InputPort<File> getInputPort() { - return this.getFirstStage().getInputPort(); - } - - public OutputPort<IMonitoringRecord> getOutputPort() { - return this.getLastStage().getOutputPort(); - } -} diff --git a/src/main/java/teetime/stage/kieker/TCPReaderSink.java b/src/main/java/teetime/stage/kieker/TCPReaderSink.java deleted file mode 100644 index e3e0523aa85017b72da40e79c04708ef07c947d2..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/TCPReaderSink.java +++ /dev/null @@ -1,225 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.nio.BufferUnderflowException; -import java.nio.ByteBuffer; -import java.nio.channels.ClosedByInterruptException; -import java.nio.channels.ServerSocketChannel; -import java.nio.channels.SocketChannel; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import teetime.framework.ProducerStage; - -import kieker.common.exception.MonitoringRecordException; -import kieker.common.logging.Log; -import kieker.common.logging.LogFactory; -import kieker.common.record.AbstractMonitoringRecord; -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.misc.RegistryRecord; -import kieker.common.util.registry.ILookup; -import kieker.common.util.registry.Lookup; - -/** - * This is a reader which reads the records from a TCP port. - * - * @author Jan Waller, Nils Christian Ehmke - * - * @since 1.10 - */ -public class TCPReaderSink extends ProducerStage<IMonitoringRecord> { - - private static final int MESSAGE_BUFFER_SIZE = 65535; - - private final ILookup<String> stringRegistry = new Lookup<String>(); - private int port1 = 10133; - private int port2 = 10134; - - private TCPStringReader tcpStringReader; - - private final AtomicInteger counter = new AtomicInteger(0); - private final ScheduledThreadPoolExecutor executorService; - - public TCPReaderSink() { - this.executorService = new ScheduledThreadPoolExecutor(1); - } - - public final int getPort1() { - return this.port1; - } - - public final void setPort1(final int port1) { - this.port1 = port1; - } - - public final int getPort2() { - return this.port2; - } - - public final void setPort2(final int port2) { - this.port2 = port2; - } - - @Override - public void onStarting() { - this.executorService.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - System.out.println("Records/s: " + TCPReaderSink.this.counter.getAndSet(0)); - } - }, 0, 1, TimeUnit.SECONDS); - - this.tcpStringReader = new TCPStringReader(this.port2, this.stringRegistry); - this.tcpStringReader.start(); - super.onStarting(); - } - - @Override - protected void execute() { - ServerSocketChannel serversocket = null; - try { - serversocket = ServerSocketChannel.open(); - serversocket.socket().bind(new InetSocketAddress(this.port1)); - if (super.logger.isDebugEnabled()) { - super.logger.debug("Listening on port " + this.port1); - } - // BEGIN also loop this one? - final SocketChannel socketChannel = serversocket.accept(); - final ByteBuffer buffer = ByteBuffer.allocateDirect(MESSAGE_BUFFER_SIZE); - while (socketChannel.read(buffer) != -1) { - buffer.flip(); - // System.out.println("Reading, remaining:" + buffer.remaining()); - try { - while (buffer.hasRemaining()) { - buffer.mark(); - final int clazzid = buffer.getInt(); - final long loggingTimestamp = buffer.getLong(); - final IMonitoringRecord record; - try { // NOCS (Nested try-catch) - record = AbstractMonitoringRecord.createFromByteBuffer(clazzid, buffer, this.stringRegistry); - record.setLoggingTimestamp(loggingTimestamp); - // this.send(record); - this.counter.incrementAndGet(); - } catch (final MonitoringRecordException ex) { - super.logger.error("Failed to create record.", ex); - } - } - buffer.clear(); - } catch (final BufferUnderflowException ex) { - buffer.reset(); - // System.out.println("Underflow, remaining:" + buffer.remaining()); - buffer.compact(); - } - } - // System.out.println("Channel closing..."); - socketChannel.close(); - // END also loop this one? - } catch (final IOException ex) { - super.logger.error("Error while reading", ex); - } finally { - if (null != serversocket) { - try { - serversocket.close(); - } catch (final IOException e) { - if (super.logger.isDebugEnabled()) { - super.logger.debug("Failed to close TCP connection!", e); - } - } - } - - this.terminate(); - } - } - - @Override - public void onTerminating() { - super.onTerminating(); - this.executorService.shutdown(); - this.tcpStringReader.interrupt(); - super.onTerminating(); - } - - /** - * - * @author Jan Waller - * - * @since 1.8 - */ - private static class TCPStringReader extends Thread { - - private static final int MESSAGE_BUFFER_SIZE = 65535; - - private static final Log LOG = LogFactory.getLog(TCPStringReader.class); - - private final int port; - private final ILookup<String> stringRegistry; - - public TCPStringReader(final int port, final ILookup<String> stringRegistry) { - this.port = port; - this.stringRegistry = stringRegistry; - } - - @Override - public void run() { - ServerSocketChannel serversocket = null; - try { - serversocket = ServerSocketChannel.open(); - serversocket.socket().bind(new InetSocketAddress(this.port)); - if (LOG.isDebugEnabled()) { - LOG.debug("Listening on port " + this.port); - } - // BEGIN also loop this one? - final SocketChannel socketChannel = serversocket.accept(); - final ByteBuffer buffer = ByteBuffer.allocateDirect(MESSAGE_BUFFER_SIZE); - while ((socketChannel.read(buffer) != -1)) { - buffer.flip(); - try { - while (buffer.hasRemaining()) { - buffer.mark(); - RegistryRecord.registerRecordInRegistry(buffer, this.stringRegistry); - } - buffer.clear(); - } catch (final BufferUnderflowException ex) { - buffer.reset(); - buffer.compact(); - } - } - socketChannel.close(); - // END also loop this one? - } catch (final ClosedByInterruptException ex) { - LOG.warn("Reader interrupted", ex); - } catch (final IOException ex) { - LOG.error("Error while reading", ex); - } finally { - if (null != serversocket) { - try { - serversocket.close(); - } catch (final IOException e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Failed to close TCP connection!", e); - } - } - } - } - - LOG.debug("StringRegistryReader thread has finished."); - } - } -} diff --git a/src/main/java/teetime/stage/kieker/className/ClassNameRegistry.java b/src/main/java/teetime/stage/kieker/className/ClassNameRegistry.java deleted file mode 100644 index 15e300ede691b9ff5d9a1c33d8b6ba15f7cd1daa..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/className/ClassNameRegistry.java +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker.className; - -import java.util.HashMap; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class ClassNameRegistry extends HashMap<Integer, String> { - - private static final long serialVersionUID = -7254550212115937463L; - -} diff --git a/src/main/java/teetime/stage/kieker/className/ClassNameRegistryCreationFilter.java b/src/main/java/teetime/stage/kieker/className/ClassNameRegistryCreationFilter.java deleted file mode 100644 index 4171c34ac0a81ee87fab469bdc41e75ab05adc72..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/className/ClassNameRegistryCreationFilter.java +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker.className; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -import teetime.framework.ConsumerStage; -import teetime.framework.OutputPort; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class ClassNameRegistryCreationFilter extends ConsumerStage<File> { - - private final OutputPort<File> outputPort = this.createOutputPort(); - - private ClassNameRegistryRepository classNameRegistryRepository; - - private final MappingFileParser mappingFileParser; - - /** - * @since 1.10 - */ - public ClassNameRegistryCreationFilter(final ClassNameRegistryRepository classNameRegistryRepository) { - this(); - this.classNameRegistryRepository = classNameRegistryRepository; - } - - /** - * @since 1.10 - */ - public ClassNameRegistryCreationFilter() { - super(); - this.mappingFileParser = new MappingFileParser(this.logger); - } - - @Override - protected void execute(final File inputDir) { - final File mappingFile = this.mappingFileParser.findMappingFile(inputDir); - if (mappingFile == null) { - return; - } - - try { - final ClassNameRegistry classNameRegistry = this.mappingFileParser.parseFromStream(new FileInputStream(mappingFile)); - this.classNameRegistryRepository.put(inputDir, classNameRegistry); - this.send(this.outputPort, inputDir); - - // final String filePrefix = this.mappingFileParser.getFilePrefixFromMappingFile(mappingFile); - // context.put(this.filePrefixOutputPort, filePrefix); // TODO pass prefix - } catch (final FileNotFoundException e) { - this.logger.error("Mapping file not found.", e); // and skip this directory - } - } - - public ClassNameRegistryRepository getClassNameRegistryRepository() { - return this.classNameRegistryRepository; - } - - public void setClassNameRegistryRepository(final ClassNameRegistryRepository classNameRegistryRepository) { - this.classNameRegistryRepository = classNameRegistryRepository; - } - - public OutputPort<File> getOutputPort() { - return this.outputPort; - } - -} diff --git a/src/main/java/teetime/stage/kieker/className/ClassNameRegistryRepository.java b/src/main/java/teetime/stage/kieker/className/ClassNameRegistryRepository.java deleted file mode 100644 index bbbd79117109f14dc6e59b2850a5f7a26cb9a3a1..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/className/ClassNameRegistryRepository.java +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker.className; - -import java.io.File; -import java.util.concurrent.ConcurrentHashMap; - -/** - * This class represents a wrapper for a Map<String, ClassNameRegistry> ensuring that keys are - * <ul> - * <li>of the type <code>java.io.File</code> and - * <li>passed as absolute file paths. - * </ul> - * - * @author Christian Wulf - * - * @since 1.10 - */ -public class ClassNameRegistryRepository { - - private final ConcurrentHashMap<String, ClassNameRegistry> classNameRegistryRepository = new ConcurrentHashMap<String, ClassNameRegistry>(); - - /** - * @since 1.10 - */ - public ClassNameRegistry get(final File directory) { - return this.classNameRegistryRepository.get(directory.getAbsolutePath()); - } - - /** - * @since 1.10 - */ - public void put(final File directory, final ClassNameRegistry classNameRegistry) { - this.classNameRegistryRepository.put(directory.getAbsolutePath(), classNameRegistry); - } - - /** - * @since 1.10 - */ - public int size() { - return this.classNameRegistryRepository.size(); - } - - @Override - public String toString() { - return this.classNameRegistryRepository.toString(); - } -} diff --git a/src/main/java/teetime/stage/kieker/className/MappingFileParser.java b/src/main/java/teetime/stage/kieker/className/MappingFileParser.java deleted file mode 100644 index a428056aa49840f02f889a5bd9d8c74a5c64317e..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/className/MappingFileParser.java +++ /dev/null @@ -1,128 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker.className; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.Logger; - -import kieker.common.util.filesystem.FSUtil; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class MappingFileParser { - - protected Logger logger; - - private static final Map<String, String> filePrefixRegistry = new HashMap<String, String>(); - - static { - filePrefixRegistry.put(FSUtil.MAP_FILENAME, FSUtil.FILE_PREFIX); - filePrefixRegistry.put(FSUtil.LEGACY_MAP_FILENAME, FSUtil.LEGACY_FILE_PREFIX); - } - - public MappingFileParser(final Logger logger) { - this.logger = logger; - } - - public ClassNameRegistry parseFromStream(final InputStream inputStream) { - final ClassNameRegistry classNameRegistry = new ClassNameRegistry(); - - BufferedReader in = null; - try { - in = new BufferedReader(new InputStreamReader(inputStream, FSUtil.ENCODING)); - String line; - while ((line = in.readLine()) != null) { // NOPMD (assign) - this.parseTextLine(line, classNameRegistry); - } - } catch (final IOException ex) { - this.logger.error("Error reading mapping file", ex); - } finally { - if (in != null) { - try { - in.close(); - } catch (final IOException ex) { - this.logger.error("Exception while closing input stream for mapping file", ex); - } - } - } - - return classNameRegistry; - } - - private void parseTextLine(final String line, final Map<Integer, String> stringRegistry) { - if (line.length() == 0) { - return; // ignore empty lines - } - final int split = line.indexOf('='); - if (split == -1) { - this.logger.error("Failed to find character '=' in line: {" + line + "}. It must consist of a ID=VALUE pair."); - return; // continue on errors - } - final String key = line.substring(0, split); - final String value = FSUtil.decodeNewline(line.substring(split + 1)); - // the leading $ is optional - final Integer id; - try { - id = Integer.valueOf((key.charAt(0) == '$') ? key.substring(1) : key); // NOCS - } catch (final NumberFormatException ex) { - this.logger.error("Error reading mapping file, id must be integer", ex); - return; // continue on errors - } - final String prevVal = stringRegistry.put(id, value); - if (prevVal != null) { - this.logger.error("Found addional entry for id='" + id + "', old value was '" + prevVal + "' new value is '" + value + "'"); - } - } - - /** - * @since 1.10 - */ - public File findMappingFile(final File dirPath) { - File mappingFile = new File(dirPath, FSUtil.MAP_FILENAME); - if (!mappingFile.exists()) { - // No mapping file found. Check whether we find a legacy tpmon.map file! - mappingFile = new File(dirPath, FSUtil.LEGACY_MAP_FILENAME); - if (mappingFile.exists()) { - this.logger.info("Directory '" + dirPath + "' contains no file '" + FSUtil.MAP_FILENAME + "'. Found '" + FSUtil.LEGACY_MAP_FILENAME - + "' ... switching to legacy mode"); - } else { - // no {kieker|tpmon}.map exists. This is valid for very old monitoring logs. Hence, only dump a log.warn - this.logger.warn("No mapping file in directory '" + dirPath.getAbsolutePath() + "'"); - return null; - } - } - - return mappingFile; - } - - /** - * @return <code>null</code> if a file prefix for the given <code>mappingFile</code> is not registered. - * @since 1.10 - */ - public String getFilePrefixFromMappingFile(final File mappingFile) { - return MappingFileParser.filePrefixRegistry.get(mappingFile.getName()); - } -} diff --git a/src/main/java/teetime/stage/kieker/fileToRecord/BinaryFile2RecordFilter.java b/src/main/java/teetime/stage/kieker/fileToRecord/BinaryFile2RecordFilter.java deleted file mode 100644 index c25ebe898c1f1fabe752f4a0c1e07283356a32b8..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/fileToRecord/BinaryFile2RecordFilter.java +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker.fileToRecord; - -import java.io.DataInputStream; -import java.io.File; -import java.io.IOException; - -import teetime.framework.ConsumerStage; -import teetime.framework.OutputPort; -import teetime.stage.kieker.className.ClassNameRegistryRepository; - -import kieker.common.exception.MonitoringRecordException; -import kieker.common.record.IMonitoringRecord; -import kieker.common.util.filesystem.BinaryCompressionMethod; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class BinaryFile2RecordFilter extends ConsumerStage<File> { - - private final OutputPort<IMonitoringRecord> outputPort = this.createOutputPort(); - - private static final int MB = 1024 * 1024; - - private RecordFromBinaryFileCreator recordFromBinaryFileCreator; - - private ClassNameRegistryRepository classNameRegistryRepository; - - /** - * @since 1.10 - */ - public BinaryFile2RecordFilter(final ClassNameRegistryRepository classNameRegistryRepository) { - this(); - this.classNameRegistryRepository = classNameRegistryRepository; - } - - /** - * @since 1.10 - */ - public BinaryFile2RecordFilter() { - super(); - } - - @Override - public void onStarting() { - this.recordFromBinaryFileCreator = new RecordFromBinaryFileCreator(this.logger, this.classNameRegistryRepository); - super.onStarting(); - } - - public ClassNameRegistryRepository getClassNameRegistryRepository() { - return this.classNameRegistryRepository; - } - - public void setClassNameRegistryRepository(final ClassNameRegistryRepository classNameRegistryRepository) { - this.classNameRegistryRepository = classNameRegistryRepository; - } - - @Override - protected void execute(final File binaryFile) { - try { - final BinaryCompressionMethod method = BinaryCompressionMethod.getByFileExtension(binaryFile.getName()); - final DataInputStream in = method.getDataInputStream(binaryFile, 1 * MB); - try { - IMonitoringRecord record = this.recordFromBinaryFileCreator.createRecordFromBinaryFile(binaryFile, in); - while (record != null) { - this.send(this.outputPort, record); - record = this.recordFromBinaryFileCreator.createRecordFromBinaryFile(binaryFile, in); - } - } catch (final MonitoringRecordException e) { - this.logger.error("Error reading file: " + binaryFile, e); - } finally { - if (in != null) { - try { - in.close(); - } catch (final IOException ex) { - this.logger.error("Exception while closing input stream for processing input file", ex); - } - } - } - } catch (final IOException e) { - this.logger.error("Error reading file: " + binaryFile, e); - } catch (final IllegalArgumentException e) { - this.logger.warn("Unknown file extension for file: " + binaryFile); - } - } - - public OutputPort<IMonitoringRecord> getOutputPort() { - return outputPort; - } - -} diff --git a/src/main/java/teetime/stage/kieker/fileToRecord/DatFile2RecordFilter.java b/src/main/java/teetime/stage/kieker/fileToRecord/DatFile2RecordFilter.java deleted file mode 100644 index 30dfa1b59b3c4076081acc7a68249e5dfa3d78db..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/fileToRecord/DatFile2RecordFilter.java +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker.fileToRecord; - -import java.io.File; - -import teetime.framework.InputPort; -import teetime.framework.OutputPort; -import teetime.framework.OldPipeline; -import teetime.framework.pipe.SingleElementPipe; -import teetime.stage.io.File2TextLinesFilter; -import teetime.stage.kieker.className.ClassNameRegistryRepository; -import teetime.stage.kieker.fileToRecord.textLine.TextLine2RecordFilter; - -import kieker.common.record.IMonitoringRecord; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class DatFile2RecordFilter extends OldPipeline<File2TextLinesFilter, TextLine2RecordFilter> { - - public DatFile2RecordFilter(final ClassNameRegistryRepository classNameRegistryRepository) { - File2TextLinesFilter file2TextLinesFilter = new File2TextLinesFilter(); - TextLine2RecordFilter textLine2RecordFilter = new TextLine2RecordFilter(classNameRegistryRepository); - - this.setFirstStage(file2TextLinesFilter); - this.setLastStage(textLine2RecordFilter); - - // BETTER let the framework choose the optimal pipe implementation - SingleElementPipe.connect(file2TextLinesFilter.getOutputPort(), textLine2RecordFilter.getInputPort()); - } - - public InputPort<File> getInputPort() { - return this.getFirstStage().getInputPort(); - } - - public OutputPort<IMonitoringRecord> getOutputPort() { - return this.getLastStage().getOutputPort(); - } -} diff --git a/src/main/java/teetime/stage/kieker/fileToRecord/RecordFromBinaryFileCreator.java b/src/main/java/teetime/stage/kieker/fileToRecord/RecordFromBinaryFileCreator.java deleted file mode 100644 index 17700c2a93973eb11c4a519e76711fa62ded3667..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/fileToRecord/RecordFromBinaryFileCreator.java +++ /dev/null @@ -1,118 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker.fileToRecord; - -import java.io.DataInputStream; -import java.io.EOFException; -import java.io.File; -import java.io.IOException; - -import org.slf4j.Logger; - -import teetime.stage.kieker.className.ClassNameRegistry; -import teetime.stage.kieker.className.ClassNameRegistryRepository; - -import kieker.common.exception.MonitoringRecordException; -import kieker.common.record.AbstractMonitoringRecord; -import kieker.common.record.IMonitoringRecord; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class RecordFromBinaryFileCreator { - - private final Logger logger; - private final ClassNameRegistryRepository classNameRegistryRepository; - - public RecordFromBinaryFileCreator(final Logger logger, final ClassNameRegistryRepository classNameRegistryRepository) { - this.logger = logger; - this.classNameRegistryRepository = classNameRegistryRepository; - } - - public IMonitoringRecord createRecordFromBinaryFile(final File binaryFile, final DataInputStream inputStream) throws IOException, MonitoringRecordException { - final ClassNameRegistry classNameRegistry = this.classNameRegistryRepository.get(binaryFile.getParentFile()); - - final Integer id; - try { - id = inputStream.readInt(); - } catch (final EOFException eof) { - return null; // we are finished - } - final String classname = classNameRegistry.get(id); - if (classname == null) { - this.logger.error("Missing classname mapping for record type id " + "'" + id + "'"); - return null; // we can't easily recover on errors - } - - final Class<? extends IMonitoringRecord> clazz = AbstractMonitoringRecord.classForName(classname); - final Class<?>[] typeArray = AbstractMonitoringRecord.typesForClass(clazz); - - // read record - final long loggingTimestamp = inputStream.readLong(); // NOPMD (must be read here!) - final Object[] objectArray = new Object[typeArray.length]; - int idx = -1; - for (final Class<?> type : typeArray) { - idx++; - boolean successful = this.writeToObjectArray(inputStream, classNameRegistry, clazz, objectArray, idx, type); - if (!successful) { - return null; - } - } - final IMonitoringRecord record = AbstractMonitoringRecord.createFromArray(clazz, objectArray); - record.setLoggingTimestamp(loggingTimestamp); - - return record; - } - - private boolean writeToObjectArray(final DataInputStream inputStream, final ClassNameRegistry classNameRegistry, final Class<? extends IMonitoringRecord> clazz, - final Object[] objectArray, final int idx, final Class<?> type) throws IOException { - if (type == String.class) { - final Integer strId = inputStream.readInt(); - final String str = classNameRegistry.get(strId); - if (str == null) { - this.logger.error("No String mapping found for id " + strId.toString()); - objectArray[idx] = ""; - } else { - objectArray[idx] = str; - } - } else if ((type == int.class) || (type == Integer.class)) { - objectArray[idx] = inputStream.readInt(); - } else if ((type == long.class) || (type == Long.class)) { - objectArray[idx] = inputStream.readLong(); - } else if ((type == float.class) || (type == Float.class)) { - objectArray[idx] = inputStream.readFloat(); - } else if ((type == double.class) || (type == Double.class)) { - objectArray[idx] = inputStream.readDouble(); - } else if ((type == byte.class) || (type == Byte.class)) { - objectArray[idx] = inputStream.readByte(); - } else if ((type == short.class) || (type == Short.class)) { // NOPMD (short) - objectArray[idx] = inputStream.readShort(); - } else if ((type == boolean.class) || (type == Boolean.class)) { - objectArray[idx] = inputStream.readBoolean(); - } else { - if (inputStream.readByte() != 0) { - this.logger.error("Unexpected value for unsupported type: " + clazz.getName()); - return false; // breaking error (break would not terminate the correct loop) - } - this.logger.warn("Unsupported type: " + clazz.getName()); - objectArray[idx] = null; - } - - return true; - } -} diff --git a/src/main/java/teetime/stage/kieker/fileToRecord/RecordFromTextLineCreator.java b/src/main/java/teetime/stage/kieker/fileToRecord/RecordFromTextLineCreator.java deleted file mode 100644 index 118fec7521f3645ebf0650dd6fce7d2d09de2e10..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/fileToRecord/RecordFromTextLineCreator.java +++ /dev/null @@ -1,116 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker.fileToRecord; - -import java.io.File; - -import teetime.stage.kieker.className.ClassNameRegistry; -import teetime.stage.kieker.className.ClassNameRegistryRepository; -import teetime.stage.util.MappingException; - -import kieker.common.exception.IllegalRecordFormatException; -import kieker.common.exception.MonitoringRecordException; -import kieker.common.exception.UnknownRecordTypeException; -import kieker.common.record.AbstractMonitoringRecord; -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.controlflow.OperationExecutionRecord; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class RecordFromTextLineCreator { - - private static final String CSV_SEPARATOR_CHARACTER = ";"; - - private static final IllegalRecordFormatException ILLEGAL_RECORD_FORMAT_EXCEPTION = new IllegalRecordFormatException(); - - private final ClassNameRegistryRepository classNameRegistryRepository; - - public RecordFromTextLineCreator(final ClassNameRegistryRepository classNameRegistryRepository) { - this.classNameRegistryRepository = classNameRegistryRepository; - } - - /** - * @since 1.10 - */ - public IMonitoringRecord createRecordFromLine(final File textFile, final String line) throws MonitoringRecordException, IllegalRecordFormatException, - MappingException, - UnknownRecordTypeException { - final String[] recordFields = line.split(CSV_SEPARATOR_CHARACTER); - - if (recordFields.length < 2) { - throw ILLEGAL_RECORD_FORMAT_EXCEPTION; - } - - final boolean isModernRecord = recordFields[0].charAt(0) == '$'; - if (isModernRecord) { - return this.createModernRecordFromRecordFields(textFile, recordFields); - } else { - return this.createLegacyRecordFromRecordFiels(recordFields); - } - } - - private IMonitoringRecord createModernRecordFromRecordFields(final File textFile, final String[] recordFields) throws MonitoringRecordException, - MappingException, - UnknownRecordTypeException { - final ClassNameRegistry classNameRegistry = this.classNameRegistryRepository.get(textFile.getParentFile()); - final Integer id = Integer.valueOf(recordFields[0].substring(1)); - final String classname = classNameRegistry.get(id); - if (classname == null) { - throw new MappingException("Missing classname mapping for record type id " + "'" + id + "'"); - } - final Class<? extends IMonitoringRecord> clazz = this.getClassByName(classname); - final long loggingTimestamp = Long.parseLong(recordFields[1]); - final int skipValues; - // check for Kieker < 1.6 OperationExecutionRecords - if ((recordFields.length == 11) && clazz.equals(OperationExecutionRecord.class)) { - skipValues = 3; - } else { - skipValues = 2; - } - // Java 1.5 compatibility - final String[] recordFieldsReduced = new String[recordFields.length - skipValues]; - System.arraycopy(recordFields, skipValues, recordFieldsReduced, 0, recordFields.length - skipValues); - // in Java 1.6 this could be simplified to - // recordFieldsReduced = Arrays.copyOfRange(recordFields, skipValues, recordFields.length); - - final IMonitoringRecord record = AbstractMonitoringRecord.createFromStringArray(clazz, recordFieldsReduced); - record.setLoggingTimestamp(loggingTimestamp); - return record; - } - - /** - * @since 1.10 - */ - private Class<? extends IMonitoringRecord> getClassByName(final String classname) throws MonitoringRecordException, UnknownRecordTypeException { - try { - return AbstractMonitoringRecord.classForName(classname); - } catch (final MonitoringRecordException ex) { - throw new UnknownRecordTypeException("Failed to load record type " + classname, classname, ex); - } - } - - /** - * @since 1.10 - */ - private IMonitoringRecord createLegacyRecordFromRecordFiels(final String[] recordFields) throws MonitoringRecordException { - final String[] recordFieldsReduced = new String[recordFields.length - 1]; - System.arraycopy(recordFields, 1, recordFieldsReduced, 0, recordFields.length - 1); - return AbstractMonitoringRecord.createFromStringArray(OperationExecutionRecord.class, recordFieldsReduced); - } -} diff --git a/src/main/java/teetime/stage/kieker/fileToRecord/ZipFile2RecordFilter.java b/src/main/java/teetime/stage/kieker/fileToRecord/ZipFile2RecordFilter.java deleted file mode 100644 index e9686124d16453603ca5e6984c25098ae810774a..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/fileToRecord/ZipFile2RecordFilter.java +++ /dev/null @@ -1,129 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker.fileToRecord; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import teetime.framework.ConsumerStage; -import teetime.framework.OutputPort; -import teetime.stage.kieker.className.ClassNameRegistry; -import teetime.stage.kieker.className.MappingFileParser; - -import kieker.common.record.IMonitoringRecord; -import kieker.common.util.filesystem.FSUtil; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class ZipFile2RecordFilter extends ConsumerStage<File> { - - private final OutputPort<IMonitoringRecord> outputPort = this.createOutputPort(); - - private final MappingFileParser mappingFileParser; - - /** - * @since 1.10 - */ - public ZipFile2RecordFilter() { - this.mappingFileParser = new MappingFileParser(this.logger); - } - - @Override - protected void execute(final File zipFile) { - final InputStream mappingFileInputStream = this.findMappingFileInputStream(zipFile); - if (mappingFileInputStream == null) { - return; - } - final ClassNameRegistry classNameRegistry = this.mappingFileParser.parseFromStream(mappingFileInputStream); - - try { - this.createAndSendRecordsFromZipFile(zipFile, classNameRegistry); - } catch (final FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - private void createAndSendRecordsFromZipFile(final File zipFile, final ClassNameRegistry classNameRegistry) - throws FileNotFoundException { - final ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(zipFile)); - final BufferedReader reader; - try { - reader = new BufferedReader(new InputStreamReader(zipInputStream, FSUtil.ENCODING)); - } catch (final UnsupportedEncodingException e) { - this.logger.error("This exception should never occur.", e); - return; - } - final DataInputStream input = new DataInputStream(new BufferedInputStream(zipInputStream, 1024 * 1024)); - - ZipEntry zipEntry; - try { - while (null != (zipEntry = zipInputStream.getNextEntry())) { // NOCS NOPMD - final String filename = zipEntry.getName(); - // TODO implement the zip filter - } - } catch (final IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - private InputStream findMappingFileInputStream(final File zipFile) { - ZipInputStream zipInputStream = null; - try { - zipInputStream = new ZipInputStream(new FileInputStream(zipFile)); - ZipEntry zipEntry; - while ((null != (zipEntry = zipInputStream.getNextEntry())) && !zipEntry.getName().equals(FSUtil.MAP_FILENAME)) { // NOCS NOPMD - // do nothing, just skip to the map file if present - } - if (null == zipEntry) { - this.logger.error("The zip file does not contain a Kieker log: " + zipFile.toString()); - return null; - } - return zipInputStream; - } catch (final IOException ex) { - this.logger.error("Error accessing ZipInputStream", ex); - } finally { - if (null != zipInputStream) { - try { - zipInputStream.close(); - } catch (final IOException ex) { - this.logger.error("Failed to close ZipInputStream", ex); - } - } - } - - return null; - } - - public OutputPort<IMonitoringRecord> getOutputPort() { - return outputPort; - } - -} diff --git a/src/main/java/teetime/stage/kieker/fileToRecord/textLine/TextLine2MappingRegistryFilter.java b/src/main/java/teetime/stage/kieker/fileToRecord/textLine/TextLine2MappingRegistryFilter.java deleted file mode 100644 index e15f352f7d121bb8f174efa80413c9c4c9776fe1..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/fileToRecord/textLine/TextLine2MappingRegistryFilter.java +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package teetime.stage.kieker.fileToRecord.textLine; - -import java.util.Map; - -import teetime.framework.ConsumerStage; - -import kieker.common.util.filesystem.FSUtil; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class TextLine2MappingRegistryFilter extends ConsumerStage<String> { - - private final Map<Integer, String> stringRegistry; - - public TextLine2MappingRegistryFilter(final Map<Integer, String> stringRegistry) { - this.stringRegistry = stringRegistry; - } - - @Override - protected void execute(final String textLine) { - final int split = textLine.indexOf('='); - if (split == -1) { - this.logger.error("Failed to find character '=' in line: {" + textLine + "}. It must consist of a ID=VALUE pair."); - return; - } - final String key = textLine.substring(0, split); - // BETTER execute split instead of checking it before with multiple string operations - final String value = FSUtil.decodeNewline(textLine.substring(split + 1)); - // the leading $ is optional - final Integer id; - try { - id = Integer.valueOf((key.charAt(0) == '$') ? key.substring(1) : key); // NOCS - } catch (final NumberFormatException ex) { - this.logger.error("Error reading mapping file, id must be integer", ex); - return; // continue on errors - } - final String prevVal = this.stringRegistry.put(id, value); - if (prevVal != null) { - this.logger.error("Found additional entry for id='" + id + "', old value was '" + prevVal + "' new value is '" + value + "'"); - return; - } - } - -} diff --git a/src/main/java/teetime/stage/kieker/fileToRecord/textLine/TextLine2RecordFilter.java b/src/main/java/teetime/stage/kieker/fileToRecord/textLine/TextLine2RecordFilter.java deleted file mode 100644 index b730d2d5bc8cd289fa53ebc0df290721e2fbe591..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/fileToRecord/textLine/TextLine2RecordFilter.java +++ /dev/null @@ -1,108 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package teetime.stage.kieker.fileToRecord.textLine; - -import java.util.HashSet; -import java.util.Set; - -import teetime.framework.ConsumerStage; -import teetime.framework.OutputPort; -import teetime.stage.kieker.className.ClassNameRegistryRepository; -import teetime.stage.kieker.fileToRecord.RecordFromTextLineCreator; -import teetime.stage.util.MappingException; -import teetime.stage.util.TextLine; - -import kieker.common.exception.IllegalRecordFormatException; -import kieker.common.exception.MonitoringRecordException; -import kieker.common.exception.UnknownRecordTypeException; -import kieker.common.record.IMonitoringRecord; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class TextLine2RecordFilter extends ConsumerStage<TextLine> { - - private final OutputPort<IMonitoringRecord> outputPort = this.createOutputPort(); - - private final Set<String> unknownTypesObserved = new HashSet<String>(); - - private boolean ignoreUnknownRecordTypes; - - private boolean abortDueToUnknownRecordType; - - private RecordFromTextLineCreator recordFromTextLineCreator; - - /** - * @since 1.10 - */ - public TextLine2RecordFilter(final ClassNameRegistryRepository classNameRegistryRepository) { - this.recordFromTextLineCreator = new RecordFromTextLineCreator(classNameRegistryRepository); - } - - /** - * @since 1.10 - */ - public TextLine2RecordFilter() { - super(); - } - - public boolean isIgnoreUnknownRecordTypes() { - return this.ignoreUnknownRecordTypes; - } - - public void setIgnoreUnknownRecordTypes(final boolean ignoreUnknownRecordTypes) { - this.ignoreUnknownRecordTypes = ignoreUnknownRecordTypes; - } - - public RecordFromTextLineCreator getRecordFromTextLineCreator() { - return this.recordFromTextLineCreator; - } - - public void setRecordFromTextLineCreator(final RecordFromTextLineCreator recordFromTextLineCreator) { - this.recordFromTextLineCreator = recordFromTextLineCreator; - } - - @Override - protected void execute(final TextLine textLine) { - try { - final IMonitoringRecord record = this.recordFromTextLineCreator.createRecordFromLine(textLine.getTextFile(), textLine.getTextLine()); - this.send(this.outputPort, record); - } catch (final MonitoringRecordException e) { - this.logger.error("Could not create record from text line: '" + textLine + "'", e); - } catch (final IllegalRecordFormatException e) { - this.logger.error("Illegal record format: " + textLine, e); - } catch (final MappingException e) { - this.logger.error("", e); - } catch (final UnknownRecordTypeException e) { - final String classname = e.getClassName(); - if (!this.ignoreUnknownRecordTypes) { - this.abortDueToUnknownRecordType = true; - this.logger.error("Failed to load record type " + classname, e); - } else if (!this.unknownTypesObserved.contains(classname)) { - this.unknownTypesObserved.add(classname); - this.logger.error("Failed to load record type " + classname, e); // log once for this type - } - } - } - - public OutputPort<IMonitoringRecord> getOutputPort() { - return this.outputPort; - } - -} diff --git a/src/main/java/teetime/stage/kieker/traceReconstruction/TraceReconstructionFilter.java b/src/main/java/teetime/stage/kieker/traceReconstruction/TraceReconstructionFilter.java deleted file mode 100644 index b9e1d973fedf6dbcaa68b46a6d734e55133632de..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/traceReconstruction/TraceReconstructionFilter.java +++ /dev/null @@ -1,160 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.kieker.traceReconstruction; - -import java.util.concurrent.TimeUnit; - -import teetime.framework.ConsumerStage; -import teetime.framework.OutputPort; -import teetime.util.concurrent.hashmap.ConcurrentHashMapWithDefault; -import teetime.util.concurrent.hashmap.TraceBuffer; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; -import kieker.common.record.flow.IFlowRecord; -import kieker.common.record.flow.trace.AbstractTraceEvent; -import kieker.common.record.flow.trace.TraceMetadata; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class TraceReconstructionFilter extends ConsumerStage<IFlowRecord> { - - private final OutputPort<TraceEventRecords> traceValidOutputPort = this.createOutputPort(); - private final OutputPort<TraceEventRecords> traceInvalidOutputPort = this.createOutputPort(); // TODO send output to this port - - private TimeUnit timeunit; - private long maxTraceDuration = Long.MAX_VALUE; - private long maxTraceTimeout = Long.MAX_VALUE; - private long maxEncounteredLoggingTimestamp = -1; - - private final ConcurrentHashMapWithDefault<Long, TraceBuffer> traceId2trace; - - public TraceReconstructionFilter(final ConcurrentHashMapWithDefault<Long, TraceBuffer> traceId2trace) { - super(); - this.traceId2trace = traceId2trace; - } - - @Override - protected void execute(final IFlowRecord element) { - final Long traceId = this.reconstructTrace(element); - if (traceId != null) { - this.put(traceId, true); - } - } - - private void put(final Long traceId, final boolean onlyIfFinished) { - final TraceBuffer traceBuffer = this.traceId2trace.get(traceId); - if (traceBuffer != null) { // null-check to check whether the trace has already been sent and removed - boolean shouldSend; - if (onlyIfFinished) { - shouldSend = traceBuffer.isFinished(); - } else { - shouldSend = true; - } - - if (shouldSend) { - boolean removed = (null != this.traceId2trace.remove(traceId)); - if (removed) { - this.sendTraceBuffer(traceBuffer); - } - } - } - } - - private Long reconstructTrace(final IFlowRecord record) { - Long traceId = null; - if (record instanceof TraceMetadata) { - traceId = ((TraceMetadata) record).getTraceId(); - TraceBuffer traceBuffer = this.traceId2trace.getOrCreate(traceId); - - traceBuffer.setTrace((TraceMetadata) record); - } else if (record instanceof AbstractTraceEvent) { - traceId = ((AbstractTraceEvent) record).getTraceId(); - TraceBuffer traceBuffer = this.traceId2trace.getOrCreate(traceId); - - traceBuffer.insertEvent((AbstractTraceEvent) record); - } - - return traceId; - } - - @Override - public void onTerminating() { - super.onTerminating(); - for (Long traceId : this.traceId2trace.keySet()) { - this.put(traceId, false); - } - - super.onTerminating(); - } - - private void sendTraceBuffer(final TraceBuffer traceBuffer) { - OutputPort<TraceEventRecords> outputPort = (traceBuffer.isInvalid()) ? this.traceInvalidOutputPort - : this.traceValidOutputPort; - this.send(outputPort, traceBuffer.toTraceEvents()); - } - - public TimeUnit getTimeunit() { - return this.timeunit; - } - - public void setTimeunit(final TimeUnit timeunit) { - this.timeunit = timeunit; - } - - public long getMaxTraceDuration() { - return this.maxTraceDuration; - } - - public void setMaxTraceDuration(final long maxTraceDuration) { - this.maxTraceDuration = maxTraceDuration; - } - - public long getMaxTraceTimeout() { - return this.maxTraceTimeout; - } - - public void setMaxTraceTimeout(final long maxTraceTimeout) { - this.maxTraceTimeout = maxTraceTimeout; - } - - public long getMaxEncounteredLoggingTimestamp() { - return this.maxEncounteredLoggingTimestamp; - } - - public void setMaxEncounteredLoggingTimestamp(final long maxEncounteredLoggingTimestamp) { - this.maxEncounteredLoggingTimestamp = maxEncounteredLoggingTimestamp; - } - - public OutputPort<TraceEventRecords> getTraceValidOutputPort() { - return this.traceValidOutputPort; - } - - public OutputPort<TraceEventRecords> getTraceInvalidOutputPort() { - return this.traceInvalidOutputPort; - } - - // public Map<Long, TraceBuffer> getTraceId2trace() { - // return TraceReconstructionFilter.traceId2trace; - // } - // - // public void setTraceId2trace(final Map<Long, TraceBuffer> traceId2trace) { - // TraceReconstructionFilter.traceId2trace = traceId2trace; - // } - -} diff --git a/src/main/java/teetime/stage/kieker/traceReduction/TraceAggregationBuffer.java b/src/main/java/teetime/stage/kieker/traceReduction/TraceAggregationBuffer.java deleted file mode 100644 index 56b1c257953d1f1ab940b060e73c0719a0ace656..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/traceReduction/TraceAggregationBuffer.java +++ /dev/null @@ -1,36 +0,0 @@ -package teetime.stage.kieker.traceReduction; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; - -/** - * Buffer for similar traces that are to be aggregated into a single trace. - * - * @author Jan Waller, Florian Biss - */ -public final class TraceAggregationBuffer { - private final long bufferCreatedTimestamp; - private final TraceEventRecords aggregatedTrace; - - private int countOfAggregatedTraces; - - public TraceAggregationBuffer(final long bufferCreatedTimestamp, final TraceEventRecords trace) { - this.bufferCreatedTimestamp = bufferCreatedTimestamp; - this.aggregatedTrace = trace; - } - - public void count() { - this.countOfAggregatedTraces++; - } - - public long getBufferCreatedTimestamp() { - return this.bufferCreatedTimestamp; - } - - public TraceEventRecords getTraceEventRecords() { - return this.aggregatedTrace; - } - - public int getCount() { - return this.countOfAggregatedTraces; - } -} diff --git a/src/main/java/teetime/stage/kieker/traceReduction/TraceComperator.java b/src/main/java/teetime/stage/kieker/traceReduction/TraceComperator.java deleted file mode 100644 index b1fadaeb1faee62b27261ed50da76cc5da4137a0..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/traceReduction/TraceComperator.java +++ /dev/null @@ -1,69 +0,0 @@ -package teetime.stage.kieker.traceReduction; - -import java.io.Serializable; -import java.util.Comparator; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; -import kieker.common.record.flow.trace.AbstractTraceEvent; -import kieker.common.record.flow.trace.operation.AbstractOperationEvent; -import kieker.common.record.flow.trace.operation.AfterOperationFailedEvent; - -/** - * @author Jan Waller, Florian Fittkau, Florian Biss - */ -public final class TraceComperator implements Comparator<TraceEventRecords>, Serializable { - private static final long serialVersionUID = 8920766818232517L; - - /** - * Creates a new instance of this class. - */ - public TraceComperator() { - // default empty constructor - } - - /** - * {@inheritDoc} - */ - @Override - public int compare(final TraceEventRecords t1, final TraceEventRecords t2) { - final AbstractTraceEvent[] recordsT1 = t1.getTraceEvents(); - final AbstractTraceEvent[] recordsT2 = t2.getTraceEvents(); - - if (recordsT1.length != recordsT2.length) { - return recordsT1.length - recordsT2.length; - } - - final int cmpHostnames = t1.getTraceMetadata().getHostname() - .compareTo(t2.getTraceMetadata().getHostname()); - if (cmpHostnames != 0) { - return cmpHostnames; - } - - for (int i = 0; i < recordsT1.length; i++) { - final AbstractTraceEvent recordT1 = recordsT1[i]; - final AbstractTraceEvent recordT2 = recordsT2[i]; - - final int cmpClass = recordT1.getClass().getName() - .compareTo(recordT2.getClass().getName()); - if (cmpClass != 0) { - return cmpClass; - } - if (recordT1 instanceof AbstractOperationEvent) { - final int cmpSignature = ((AbstractOperationEvent) recordT1).getOperationSignature() - .compareTo(((AbstractOperationEvent) recordT2).getOperationSignature()); - if (cmpSignature != 0) { - return cmpSignature; - } - } - if (recordT1 instanceof AfterOperationFailedEvent) { - final int cmpError = ((AfterOperationFailedEvent) recordT1).getCause().compareTo( - ((AfterOperationFailedEvent) recordT2).getCause()); - if (cmpError != 0) { - return cmpClass; - } - } - } - // All records match. - return 0; - } -} diff --git a/src/main/java/teetime/stage/kieker/traceReduction/TraceReductionFilter.java b/src/main/java/teetime/stage/kieker/traceReduction/TraceReductionFilter.java deleted file mode 100644 index f9a282328367ae32c3396299a0571b6f1c231e86..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/kieker/traceReduction/TraceReductionFilter.java +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package teetime.stage.kieker.traceReduction; - -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import teetime.framework.ConsumerStage; -import teetime.framework.InputPort; -import teetime.framework.OutputPort; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; - -/** - * This filter collects incoming traces for a specified amount of time. - * Any traces representing the same series of events will be used to calculate statistical informations like the average runtime of this kind of trace. - * Only one specimen of these traces containing this information will be forwarded from this filter. - * - * Statistical outliers regarding the runtime of the trace will be treated special and therefore send out as they are and will not be mixed with others. - * - * @author Jan Waller, Florian Biss - * - * @since - */ -public class TraceReductionFilter extends ConsumerStage<TraceEventRecords> { - - private final InputPort<Long> triggerInputPort = this.createInputPort(); - private final OutputPort<TraceEventRecords> outputPort = this.createOutputPort(); - - private final Map<TraceEventRecords, TraceAggregationBuffer> trace2buffer; - - private long maxCollectionDurationInNs; - - public TraceReductionFilter(final Map<TraceEventRecords, TraceAggregationBuffer> trace2buffer) { - this.trace2buffer = trace2buffer; - } - - @Override - protected void execute(final TraceEventRecords traceEventRecords) { - Long timestampInNs = this.triggerInputPort.receive(); - if (timestampInNs != null) { - this.processTimeoutQueue(timestampInNs); - } - - final long timestamp = System.nanoTime(); - this.countSameTraces(traceEventRecords, timestamp); - } - - private void countSameTraces(final TraceEventRecords traceEventRecords, final long timestamp) { - synchronized (this.trace2buffer) { - TraceAggregationBuffer traceBuffer = this.trace2buffer.get(traceEventRecords); - if (traceBuffer == null) { - traceBuffer = new TraceAggregationBuffer(timestamp, traceEventRecords); - this.trace2buffer.put(traceEventRecords, traceBuffer); - } - traceBuffer.count(); - } - } - - @Override - public void onTerminating() { - super.onTerminating(); - synchronized (this.trace2buffer) { // BETTER hide and improve synchronization in the buffer - for (final Entry<TraceEventRecords, TraceAggregationBuffer> entry : this.trace2buffer.entrySet()) { - final TraceAggregationBuffer buffer = entry.getValue(); - final TraceEventRecords record = buffer.getTraceEventRecords(); - record.setCount(buffer.getCount()); - this.send(this.outputPort, record); - } - this.trace2buffer.clear(); - } - - super.onTerminating(); - } - - private void processTimeoutQueue(final long timestampInNs) { - final long bufferTimeoutInNs = timestampInNs - this.maxCollectionDurationInNs; - synchronized (this.trace2buffer) { - for (final Iterator<Entry<TraceEventRecords, TraceAggregationBuffer>> iterator = this.trace2buffer.entrySet().iterator(); iterator.hasNext();) { - final TraceAggregationBuffer traceBuffer = iterator.next().getValue(); - // this.logger.debug("traceBuffer.getBufferCreatedTimestamp(): " + traceBuffer.getBufferCreatedTimestamp() + " vs. " + bufferTimeoutInNs - // + " (bufferTimeoutInNs)"); - if (traceBuffer.getBufferCreatedTimestamp() <= bufferTimeoutInNs) { - final TraceEventRecords record = traceBuffer.getTraceEventRecords(); - record.setCount(traceBuffer.getCount()); - this.send(this.outputPort, record); - } - iterator.remove(); - } - } - } - - public long getMaxCollectionDuration() { - return this.maxCollectionDurationInNs; - } - - public void setMaxCollectionDuration(final long maxCollectionDuration) { - this.maxCollectionDurationInNs = maxCollectionDuration; - } - - public InputPort<Long> getTriggerInputPort() { - return this.triggerInputPort; - } - - public OutputPort<TraceEventRecords> getOutputPort() { - return this.outputPort; - } -} diff --git a/src/main/java/teetime/stage/stringBuffer/handler/IMonitoringRecordHandler.java b/src/main/java/teetime/stage/stringBuffer/handler/IMonitoringRecordHandler.java deleted file mode 100644 index ee345747f9ab70a1ec5e9f8ce26524fec8dd2e4d..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/stage/stringBuffer/handler/IMonitoringRecordHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.stage.stringBuffer.handler; - -import kieker.common.exception.MonitoringRecordException; -import kieker.common.record.AbstractMonitoringRecord; -import kieker.common.record.IMonitoringRecord; - - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class IMonitoringRecordHandler extends AbstractDataTypeHandler<IMonitoringRecord> { - - @Override - public boolean canHandle(final Object object) { - return object instanceof IMonitoringRecord; - } - - @Override - public IMonitoringRecord handle(final IMonitoringRecord monitoringRecord) { - final Object[] objects = monitoringRecord.toArray(); - - boolean stringBuffered = false; - for (int i = 0; i < objects.length; i++) { - if (objects[i] instanceof String) { - objects[i] = this.stringRepository.get((String) objects[i]); - stringBuffered = true; - } - } - - if (stringBuffered) { - try { - final IMonitoringRecord newRecord = AbstractMonitoringRecord.createFromArray(monitoringRecord.getClass(), objects); - newRecord.setLoggingTimestamp(monitoringRecord.getLoggingTimestamp()); - return newRecord; - } catch (final MonitoringRecordException ex) { - this.logger.warn("Failed to recreate buffered monitoring record: " + monitoringRecord.toString(), ex); - } - } - - return monitoringRecord; - } - -} diff --git a/src/main/java/teetime/util/concurrent/hashmap/TraceBuffer.java b/src/main/java/teetime/util/concurrent/hashmap/TraceBuffer.java deleted file mode 100644 index 52184dddc8770639b76bb22c8612ab13a74112fb..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/util/concurrent/hashmap/TraceBuffer.java +++ /dev/null @@ -1,152 +0,0 @@ -package teetime.util.concurrent.hashmap; - -import java.io.Serializable; -import java.util.Comparator; -import java.util.SortedSet; -import java.util.TreeSet; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; -import kieker.common.logging.Log; -import kieker.common.logging.LogFactory; -import kieker.common.record.flow.trace.AbstractTraceEvent; -import kieker.common.record.flow.trace.TraceMetadata; -import kieker.common.record.flow.trace.operation.AfterOperationEvent; -import kieker.common.record.flow.trace.operation.AfterOperationFailedEvent; -import kieker.common.record.flow.trace.operation.BeforeOperationEvent; - -/** - * The TraceBuffer is synchronized to prevent problems with concurrent access. - * - * @author Jan Waller - */ -public final class TraceBuffer implements ValueFactory<TraceBuffer> { - private static final Log LOG = LogFactory.getLog(TraceBuffer.class); - private static final Comparator<AbstractTraceEvent> COMPARATOR = new TraceEventComperator(); - - private TraceMetadata trace; - private final SortedSet<AbstractTraceEvent> events = new TreeSet<AbstractTraceEvent>(COMPARATOR); - - private boolean closeable; - private boolean damaged; - private int openEvents; - private int maxOrderIndex = -1; - - private long minLoggingTimestamp = Long.MAX_VALUE; - private long maxLoggingTimestamp = -1; - - private long traceId = -1; - - /** - * Creates a new instance of this class. - */ - public TraceBuffer() { - // default empty constructor - } - - public void insertEvent(final AbstractTraceEvent event) { - final long myTraceId = event.getTraceId(); - synchronized (this) { - if (this.traceId == -1) { - this.traceId = myTraceId; - } else if (this.traceId != myTraceId) { - LOG.error("Invalid traceId! Expected: " + this.traceId + " but found: " + myTraceId + " in event " + event.toString()); - this.damaged = true; - } - final long loggingTimestamp = event.getTimestamp(); - if (loggingTimestamp > this.maxLoggingTimestamp) { - this.maxLoggingTimestamp = loggingTimestamp; - } - if (loggingTimestamp < this.minLoggingTimestamp) { - this.minLoggingTimestamp = loggingTimestamp; - } - final int orderIndex = event.getOrderIndex(); - if (orderIndex > this.maxOrderIndex) { - this.maxOrderIndex = orderIndex; - } - if (event instanceof BeforeOperationEvent) { - if (orderIndex == 0) { - this.closeable = true; - } - this.openEvents++; - } else if (event instanceof AfterOperationEvent) { - this.openEvents--; - } else if (event instanceof AfterOperationFailedEvent) { - this.openEvents--; - } - if (!this.events.add(event)) { - LOG.error("Duplicate entry for orderIndex " + orderIndex + " with traceId " + myTraceId); - this.damaged = true; - } - } - } - - public void setTrace(final TraceMetadata trace) { - final long myTraceId = trace.getTraceId(); - synchronized (this) { - if (this.traceId == -1) { - this.traceId = myTraceId; - } else if (this.traceId != myTraceId) { - LOG.error("Invalid traceId! Expected: " + this.traceId + " but found: " + myTraceId + " in trace " + trace.toString()); - this.damaged = true; - } - if (this.trace == null) { - this.trace = trace; - } else { - LOG.error("Duplicate Trace entry for traceId " + myTraceId); - this.damaged = true; - } - } - } - - public boolean isFinished() { - synchronized (this) { - return this.closeable && !this.isInvalid(); - } - } - - public boolean isInvalid() { - synchronized (this) { - return (this.trace == null) || this.damaged || (this.openEvents != 0) || (((this.maxOrderIndex + 1) != this.events.size()) || this.events.isEmpty()); - } - } - - public TraceEventRecords toTraceEvents() { - synchronized (this) { - return new TraceEventRecords(this.trace, this.events.toArray(new AbstractTraceEvent[this.events.size()])); - } - } - - public long getMaxLoggingTimestamp() { - synchronized (this) { - return this.maxLoggingTimestamp; - } - } - - public long getMinLoggingTimestamp() { - synchronized (this) { - return this.minLoggingTimestamp; - } - } - - /** - * @author Jan Waller - */ - private static final class TraceEventComperator implements Comparator<AbstractTraceEvent>, Serializable { - private static final long serialVersionUID = 8920737343446332517L; - - /** - * Creates a new instance of this class. - */ - public TraceEventComperator() { - // default empty constructor - } - - public int compare(final AbstractTraceEvent o1, final AbstractTraceEvent o2) { - return o1.getOrderIndex() - o2.getOrderIndex(); - } - } - - public TraceBuffer create() { - return new TraceBuffer(); - } -} diff --git a/src/main/java/util/KiekerLoadDriver.java b/src/main/java/util/KiekerLoadDriver.java deleted file mode 100644 index 65795567b3a578a10f2d459991a89dedd8836672..0000000000000000000000000000000000000000 --- a/src/main/java/util/KiekerLoadDriver.java +++ /dev/null @@ -1,202 +0,0 @@ -package util; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; -import java.net.InetSocketAddress; -import java.nio.ByteBuffer; -import java.nio.channels.SocketChannel; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -import teetime.framework.HeadPipeline; -import teetime.framework.HeadStage; -import teetime.framework.RunnableStage; -import teetime.framework.pipe.SingleElementPipe; -import teetime.stage.CollectorSink; -import teetime.stage.InitialElementProducer; -import teetime.stage.kieker.Dir2RecordsFilter; -import teetime.stage.kieker.className.ClassNameRegistryRepository; - -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.flow.trace.TraceMetadata; -import kieker.common.record.flow.trace.operation.AbstractOperationEvent; -import kieker.common.util.registry.IMonitoringRecordReceiver; -import kieker.common.util.registry.Registry; - -public class KiekerLoadDriver { - - private final List<IMonitoringRecord> elementCollection = new LinkedList<IMonitoringRecord>(); - private final RunnableStage runnableStage; - private long[] timings; - - public KiekerLoadDriver(final File directory) { - HeadStage producerPipeline = this.buildProducerPipeline(directory); - this.runnableStage = new RunnableStage(producerPipeline); - } - - private HeadPipeline<InitialElementProducer<File>, CollectorSink<IMonitoringRecord>> buildProducerPipeline(final File directory) { - ClassNameRegistryRepository classNameRegistryRepository = new ClassNameRegistryRepository(); - // create stages - InitialElementProducer<File> initialElementProducer = new InitialElementProducer<File>(directory); - Dir2RecordsFilter dir2RecordsFilter = new Dir2RecordsFilter(classNameRegistryRepository); - CollectorSink<IMonitoringRecord> collector = new CollectorSink<IMonitoringRecord>(this.elementCollection); - - final HeadPipeline<InitialElementProducer<File>, CollectorSink<IMonitoringRecord>> pipeline = new HeadPipeline<InitialElementProducer<File>, CollectorSink<IMonitoringRecord>>(); - pipeline.setFirstStage(initialElementProducer); - pipeline.setLastStage(collector); - - SingleElementPipe.connect(initialElementProducer.getOutputPort(), dir2RecordsFilter.getInputPort()); - SingleElementPipe.connect(dir2RecordsFilter.getOutputPort(), collector.getInputPort()); - - return pipeline; - } - - public Collection<IMonitoringRecord> load() { - this.runnableStage.run(); - return this.elementCollection; - } - - private static class RecordReceiver implements IMonitoringRecordReceiver { - - private final Registry<String> stringRegistry; - private final ByteBuffer buffer = ByteBuffer.allocateDirect(Short.MAX_VALUE * 10); - private SocketChannel socketChannel; - - public RecordReceiver(final Registry<String> stringRegistry) throws IOException { - this.stringRegistry = stringRegistry; - } - - @Override - public boolean newMonitoringRecord(final IMonitoringRecord record) { - System.out.println("Registering " + record); - record.writeBytes(this.buffer, this.stringRegistry); - this.buffer.flip(); - try { - int writtenBytes = this.socketChannel.write(this.buffer); - System.out.println("writtenBytes: " + writtenBytes); - this.buffer.clear(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return true; - } - - public void connect() throws IOException { - String hostname = "localhost"; - int port = 10134; - System.out.println("Connecting to " + hostname + ":" + port); - - this.socketChannel = SocketChannel.open(); - this.socketChannel.connect(new InetSocketAddress(hostname, port)); - } - - // public void sendRegistryRecords() throws IOException { - // String hostname = "localhost"; - // int port = 10134; - // System.out.println("Connecting to " + hostname + ":" + port); - // - // SocketChannel socketChannel = SocketChannel.open(); - // try { - // socketChannel.connect(new InetSocketAddress(hostname, port)); - // this.buffer.flip(); - // socketChannel.write(this.buffer); - // } finally { - // socketChannel.close(); - // } - // } - - public void close() throws IOException { - this.socketChannel.close(); - } - - } - - public static void main(final String[] args) throws IOException { - final File directory = new File(args[0]); - final File outputFile = new File(args[1]); - final int runs = Integer.parseInt(args[2]); - - KiekerLoadDriver kiekerLoadDriver = new KiekerLoadDriver(directory); - kiekerLoadDriver.start(runs); - kiekerLoadDriver.writeTimingsToFile(outputFile); - } - - public void start(final int runs) throws IOException { - this.timings = new long[runs]; - Collection<IMonitoringRecord> records = this.load(); - - final Registry<String> stringRegistry = new Registry<String>(); - ByteBuffer recordBuffer = ByteBuffer.allocateDirect(Short.MAX_VALUE); - ByteBuffer duplicateBuffer = recordBuffer.duplicate(); - - RecordReceiver recordReceiver = new RecordReceiver(stringRegistry); - stringRegistry.setRecordReceiver(recordReceiver); - try { - recordReceiver.connect(); - - String hostname = "localhost"; - int port = 10133; - System.out.println("Connecting to " + hostname + ":" + port); - long traceId = 0; - - SocketChannel socketChannel = SocketChannel.open(); - try { - socketChannel.connect(new InetSocketAddress(hostname, port)); - for (int i = 0; i < runs; i++) { - for (IMonitoringRecord record : records) { - int clazzId = stringRegistry.get(record.getClass().getName()); - recordBuffer.putInt(clazzId); - recordBuffer.putLong(record.getLoggingTimestamp()); - duplicateBuffer.position(recordBuffer.position()); - // AbstractOperationEvent writes (Long, Long traceId, ...) - record.writeBytes(recordBuffer, stringRegistry); - - if (record instanceof AbstractOperationEvent) { - duplicateBuffer.getLong(); - duplicateBuffer.putLong(traceId); - } else if (record instanceof TraceMetadata) { - duplicateBuffer.putLong(traceId); - } - } - recordBuffer.flip(); - // System.out.println("position: " + recordBuffer.position()); - // System.out.println("limit: " + recordBuffer.limit()); - long start_ns = System.nanoTime(); - int writtenBytes = socketChannel.write(recordBuffer); - long stop_ns = System.nanoTime(); - this.timings[i] = stop_ns - start_ns; - if ((i % 100000) == 0) { - System.out.println(i); // NOPMD (System.out) - } - // System.out.println("writtenBytes (record): " + writtenBytes); - recordBuffer.clear(); - duplicateBuffer.clear(); - traceId++; - } - } finally { - socketChannel.close(); - } - - } finally { - recordReceiver.close(); - } - } - - public void writeTimingsToFile(final File outputFile) throws UnsupportedEncodingException, FileNotFoundException { - PrintStream ps = new PrintStream(new BufferedOutputStream(new FileOutputStream(outputFile), 8192 * 8), false, "UTF-8"); - try { - for (long timing : this.timings) { - ps.println("0;" + timing); - } - } finally { - ps.close(); - } - } -} diff --git a/src/performancetest/java/kieker/analysis/examples/throughput/ThroughputAnalysisTest.java b/src/performancetest/java/kieker/analysis/examples/throughput/ThroughputAnalysisTest.java deleted file mode 100644 index fa53ff4af90a650742f439b7bd3197e3ec521710..0000000000000000000000000000000000000000 --- a/src/performancetest/java/kieker/analysis/examples/throughput/ThroughputAnalysisTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.examples.throughput; - -import java.util.concurrent.Callable; - -import kieker.analysis.examples.ThroughputAnalysis; -import kieker.analysis.exception.AnalysisConfigurationException; -import kieker.common.logging.LogFactory; - -import org.junit.Before; -import org.junit.Test; - -import teetime.util.StopWatch; - -/** - * @author Nils Christian Ehmke - * - * @since 1.10 - */ -public class ThroughputAnalysisTest { - - private static final int numRuns = 1000; - - @Before - public void before() { - System.setProperty(LogFactory.CUSTOM_LOGGER_JVM, "NONE"); - } - - @Test - public void testWithMultipleRuns() throws IllegalStateException, AnalysisConfigurationException { - final StopWatch stopWatch = new StopWatch(); - final long[] durations = new long[numRuns]; - - for (int i = 0; i < numRuns; i++) { - final ThroughputAnalysis<Object> analysis = new ThroughputAnalysis<Object>(); - analysis.setNumNoopFilters(100); - analysis.setInput(100, new Callable<Object>() { - @Override - public Object call() throws Exception { - return new Object(); - } - }); - analysis.init(); - - stopWatch.start(); - try { - analysis.start(); - } finally { - stopWatch.end(); - } - durations[i] = stopWatch.getDurationInNs(); - } - - // for (final long dur : durations) { - // System.out.println("Duration: " + (dur / 1000) + " �s"); - // } - - long sum = 0; - for (int i = durations.length / 2; i < durations.length; i++) { - sum += durations[i]; - } - - final long avgDur = sum / (numRuns / 2); - System.out.println("avg duration: " + (avgDur / 1000) + " �s"); - } - -} diff --git a/src/performancetest/java/kieker/analysis/examples/throughput/ThroughputTimestampAnalysisTest.java b/src/performancetest/java/kieker/analysis/examples/throughput/ThroughputTimestampAnalysisTest.java deleted file mode 100644 index 2e92b7c42e38404d8691772e3cb9209723f4d55d..0000000000000000000000000000000000000000 --- a/src/performancetest/java/kieker/analysis/examples/throughput/ThroughputTimestampAnalysisTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.examples.throughput; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; - -import org.junit.Test; - -import teetime.util.StopWatch; -import teetime.util.TimestampObject; -import util.test.PerformanceTest; -import util.test.StatisticsUtil; - -import kieker.analysis.examples.ThroughputTimestampAnalysis; -import kieker.analysis.exception.AnalysisConfigurationException; - -/** - * @author Nils Christian Ehmke - * - * @since 1.10 - */ -public class ThroughputTimestampAnalysisTest extends PerformanceTest { - - @Test - public void testWithManyObjects() throws IllegalStateException, AnalysisConfigurationException { - System.out.println("Testing kieker with NUM_OBJECTS_TO_CREATE=" + NUM_OBJECTS_TO_CREATE + ", NUM_NOOP_FILTERS=" - + NUM_NOOP_FILTERS + "..."); - final StopWatch stopWatch = new StopWatch(); - final List<TimestampObject> timestampObjects = new ArrayList<TimestampObject>(NUM_OBJECTS_TO_CREATE); - - final ThroughputTimestampAnalysis analysis = new ThroughputTimestampAnalysis(); - analysis.setNumNoopFilters(NUM_NOOP_FILTERS); - analysis.setTimestampObjects(timestampObjects); - analysis.setInput(NUM_OBJECTS_TO_CREATE, new Callable<TimestampObject>() { - @Override - public TimestampObject call() throws Exception { - return new TimestampObject(); - } - }); - analysis.init(); - - stopWatch.start(); - try { - analysis.start(); - } finally { - stopWatch.end(); - } - - StatisticsUtil.computeStatistics(stopWatch.getDurationInNs(), timestampObjects); - } - -} diff --git a/src/performancetest/java/kieker/analysis/stage/EmptyPassOnFilterTest.java b/src/performancetest/java/kieker/analysis/stage/EmptyPassOnFilterTest.java deleted file mode 100644 index 4a7e735e02a4b4be4bd2526c6338c9c336c578a9..0000000000000000000000000000000000000000 --- a/src/performancetest/java/kieker/analysis/stage/EmptyPassOnFilterTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package kieker.analysis.stage; - -import kieker.analysis.AnalysisController; -import kieker.analysis.IAnalysisController; -import kieker.analysis.exception.AnalysisConfigurationException; -import kieker.analysis.plugin.reader.filesystem.FSReader; -import kieker.analysis.stage.CacheFilter; -import kieker.analysis.stage.EmptyPassOnFilter; -import kieker.common.configuration.Configuration; - -import org.junit.Test; - -/** - * @author Nils Christian Ehmke - * - * @since 1.10 - */ -public class EmptyPassOnFilterTest { - - private static final int NUMBER_OF_EMPTY_PASS_ON_FILTERS = 1000; - - @Test - public void test() throws IllegalStateException, AnalysisConfigurationException { - final IAnalysisController ac = new AnalysisController(); - - final Configuration fsReaderConfiguration = new Configuration(); - fsReaderConfiguration.setProperty(FSReader.CONFIG_PROPERTY_NAME_INPUTDIRS, - "examples/userguide/ch5--trace-monitoring-aspectj/testdata/kieker-20100830-082225522-UTC"); - final FSReader reader = new FSReader(fsReaderConfiguration, ac); - - final CacheFilter cacheFilter = new CacheFilter(new Configuration(), ac); - - EmptyPassOnFilter predecessor = new EmptyPassOnFilter(new Configuration(), ac); - ac.connect(reader, FSReader.OUTPUT_PORT_NAME_RECORDS, cacheFilter, CacheFilter.INPUT_PORT_NAME); - ac.connect(cacheFilter, CacheFilter.OUTPUT_PORT_NAME, predecessor, EmptyPassOnFilter.INPUT_PORT_NAME); - for (int idx = 0; idx < (NUMBER_OF_EMPTY_PASS_ON_FILTERS - 1); idx++) { - final EmptyPassOnFilter newPredecessor = new EmptyPassOnFilter(new Configuration(), ac); - ac.connect(predecessor, EmptyPassOnFilter.OUTPUT_PORT_NAME, newPredecessor, EmptyPassOnFilter.INPUT_PORT_NAME); - predecessor = newPredecessor; - } - - ac.run(); - } - -} diff --git a/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceLogging.java b/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceLogging.java deleted file mode 100644 index 20e61eb6b5dca3d74bf8f95aaf3c3fdc0d147830..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceLogging.java +++ /dev/null @@ -1,44 +0,0 @@ -package teetime.examples.kiekerdays; - -import teetime.framework.HeadStage; -import teetime.framework.RunnableStage; -import teetime.stage.io.TCPReader; - -public class TcpTraceLogging { - - private Thread tcpThread; - - public void init() { - HeadStage tcpPipeline = this.buildTcpPipeline(); - this.tcpThread = new Thread(new RunnableStage(tcpPipeline)); - } - - public void start() { - - this.tcpThread.start(); - - try { - this.tcpThread.join(); - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - } - - private HeadStage buildTcpPipeline() { - // TCPReaderSink tcpReader = new TCPReaderSink(); - TCPReader tcpReader = new TCPReader(); - - return tcpReader; - } - - public static void main(final String[] args) { - final TcpTraceLogging analysis = new TcpTraceLogging(); - - analysis.init(); - try { - analysis.start(); - } finally { - } - } - -} diff --git a/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceLoggingExplorviz.java b/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceLoggingExplorviz.java deleted file mode 100644 index 9f3eab50be0bcf52b01a19330500a10ee3a37a79..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceLoggingExplorviz.java +++ /dev/null @@ -1,55 +0,0 @@ -package teetime.examples.kiekerdays; - -import teetime.framework.HeadPipeline; -import teetime.framework.HeadStage; -import teetime.framework.RunnableStage; -import teetime.framework.pipe.SingleElementPipe; -import teetime.stage.basic.Sink; -import teetime.stage.explorviz.KiekerRecordTcpReader; - -import kieker.common.record.IMonitoringRecord; - -public class TcpTraceLoggingExplorviz { - - private Thread tcpThread; - - public void init() { - HeadStage tcpPipeline = this.buildTcpPipeline(); - this.tcpThread = new Thread(new RunnableStage(tcpPipeline)); - } - - public void start() { - - this.tcpThread.start(); - - try { - this.tcpThread.join(); - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - } - - private HeadStage buildTcpPipeline() { - KiekerRecordTcpReader tcpReader = new KiekerRecordTcpReader(); - Sink<IMonitoringRecord> endStage = new Sink<IMonitoringRecord>(); - - SingleElementPipe.connect(tcpReader.getOutputPort(), endStage.getInputPort()); - - // create and configure pipeline - HeadPipeline<KiekerRecordTcpReader, Sink<IMonitoringRecord>> pipeline = new HeadPipeline<KiekerRecordTcpReader, Sink<IMonitoringRecord>>(); - pipeline.setFirstStage(tcpReader); - pipeline.setLastStage(endStage); - return tcpReader; - } - - public static void main(final String[] args) { - final TcpTraceLoggingExplorviz analysis = new TcpTraceLoggingExplorviz(); - - analysis.init(); - try { - analysis.start(); - } finally { - } - } - -} diff --git a/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceReconstruction.java b/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceReconstruction.java deleted file mode 100644 index ccafe970b144bbbfc68ed7adc1c50568c22f94a7..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceReconstruction.java +++ /dev/null @@ -1,142 +0,0 @@ -package teetime.examples.kiekerdays; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import teetime.framework.HeadPipeline; -import teetime.framework.HeadStage; -import teetime.framework.RunnableStage; -import teetime.framework.pipe.SingleElementPipe; -import teetime.framework.pipe.SpScPipe; -import teetime.stage.InstanceOfFilter; -import teetime.stage.Relay; -import teetime.stage.basic.Sink; -import teetime.stage.basic.distributor.Distributor; -import teetime.stage.io.TCPReader; -import teetime.stage.kieker.traceReconstruction.TraceReconstructionFilter; -import teetime.util.concurrent.hashmap.ConcurrentHashMapWithDefault; -import teetime.util.concurrent.hashmap.TraceBuffer; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.flow.IFlowRecord; - -public class TcpTraceReconstruction { - - private static final int NUM_VIRTUAL_CORES = Runtime.getRuntime().availableProcessors(); - private static final int MIO = 1000000; - private static final int TCP_RELAY_MAX_SIZE = 2 * MIO; - - private final List<TraceEventRecords> elementCollection = new LinkedList<TraceEventRecords>(); - private final ConcurrentHashMapWithDefault<Long, TraceBuffer> traceId2trace = new ConcurrentHashMapWithDefault<Long, TraceBuffer>(new TraceBuffer()); - private final List<SpScPipe> tcpRelayPipes = new ArrayList<SpScPipe>(); - - private Thread tcpThread; - private Thread[] workerThreads; - - private int numWorkerThreads; - - public void init() { - HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> tcpPipeline = this.buildTcpPipeline(); - this.tcpThread = new Thread(new RunnableStage(tcpPipeline)); - - this.numWorkerThreads = Math.min(NUM_VIRTUAL_CORES, this.numWorkerThreads); - this.workerThreads = new Thread[this.numWorkerThreads]; - - for (int i = 0; i < this.workerThreads.length; i++) { - HeadStage pipeline = this.buildPipeline(tcpPipeline.getLastStage()); - this.workerThreads[i] = new Thread(new RunnableStage(pipeline)); - } - } - - private HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> buildTcpPipeline() { - TCPReader tcpReader = new TCPReader(); - Distributor<IMonitoringRecord> distributor = new Distributor<IMonitoringRecord>(); - - SingleElementPipe.connect(tcpReader.getOutputPort(), distributor.getInputPort()); - - // create and configure pipeline - HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> pipeline = new HeadPipeline<TCPReader, Distributor<IMonitoringRecord>>(); - pipeline.setFirstStage(tcpReader); - pipeline.setLastStage(distributor); - return pipeline; - } - - private HeadStage buildPipeline(final Distributor<IMonitoringRecord> tcpReaderPipeline) { - // create stages - Relay<IMonitoringRecord> relay = new Relay<IMonitoringRecord>(); - final InstanceOfFilter<IMonitoringRecord, IFlowRecord> instanceOfFilter = new InstanceOfFilter<IMonitoringRecord, IFlowRecord>( - IFlowRecord.class); - final TraceReconstructionFilter traceReconstructionFilter = new TraceReconstructionFilter(this.traceId2trace); - Sink<TraceEventRecords> endStage = new Sink<TraceEventRecords>(); - - // connect stages - SpScPipe tcpRelayPipe = SpScPipe.connect(tcpReaderPipeline.getNewOutputPort(), relay.getInputPort(), TCP_RELAY_MAX_SIZE); - this.tcpRelayPipes.add(tcpRelayPipe); - - SingleElementPipe.connect(relay.getOutputPort(), instanceOfFilter.getInputPort()); - SingleElementPipe.connect(instanceOfFilter.getOutputPort(), traceReconstructionFilter.getInputPort()); - SingleElementPipe.connect(traceReconstructionFilter.getTraceValidOutputPort(), endStage.getInputPort()); - - // create and configure pipeline - HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>> pipeline = new HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>>(); - pipeline.setFirstStage(relay); - pipeline.setLastStage(endStage); - return pipeline; - } - - public void start() { - - this.tcpThread.start(); - - for (Thread workerThread : this.workerThreads) { - workerThread.start(); - } - - try { - this.tcpThread.join(); - - for (Thread workerThread : this.workerThreads) { - workerThread.join(); - } - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - } - - public void onTerminate() { - int maxNumWaits = 0; - for (SpScPipe pipe : this.tcpRelayPipes) { - maxNumWaits = Math.max(maxNumWaits, pipe.getNumWaits()); - } - System.out.println("max #waits of TcpRelayPipes: " + maxNumWaits); - } - - public List<TraceEventRecords> getElementCollection() { - return this.elementCollection; - } - - public int getNumWorkerThreads() { - return this.numWorkerThreads; - } - - public void setNumWorkerThreads(final int numWorkerThreads) { - this.numWorkerThreads = numWorkerThreads; - } - - public static void main(final String[] args) { - int numWorkerThreads = Integer.valueOf(args[0]); - - final TcpTraceReconstruction analysis = new TcpTraceReconstruction(); - analysis.setNumWorkerThreads(numWorkerThreads); - - analysis.init(); - try { - analysis.start(); - } finally { - analysis.onTerminate(); - } - } - -} diff --git a/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceReduction.java b/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceReduction.java deleted file mode 100644 index a5f865400f00b4773a1b9c3b1e3ede2b68e292ef..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/kiekerdays/TcpTraceReduction.java +++ /dev/null @@ -1,174 +0,0 @@ -package teetime.examples.kiekerdays; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import teetime.framework.HeadPipeline; -import teetime.framework.HeadStage; -import teetime.framework.RunnableStage; -import teetime.framework.pipe.SingleElementPipe; -import teetime.framework.pipe.SpScPipe; -import teetime.stage.Clock; -import teetime.stage.InstanceOfFilter; -import teetime.stage.Relay; -import teetime.stage.basic.Sink; -import teetime.stage.basic.distributor.Distributor; -import teetime.stage.io.TCPReader; -import teetime.stage.kieker.traceReconstruction.TraceReconstructionFilter; -import teetime.stage.kieker.traceReduction.TraceAggregationBuffer; -import teetime.stage.kieker.traceReduction.TraceComperator; -import teetime.stage.kieker.traceReduction.TraceReductionFilter; -import teetime.util.concurrent.hashmap.ConcurrentHashMapWithDefault; -import teetime.util.concurrent.hashmap.TraceBuffer; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.flow.IFlowRecord; - -public class TcpTraceReduction { - - private static final int NUM_VIRTUAL_CORES = Runtime.getRuntime().availableProcessors(); - private static final int MIO = 1000000; - private static final int TCP_RELAY_MAX_SIZE = 2 * MIO; - - private final List<TraceEventRecords> elementCollection = new LinkedList<TraceEventRecords>(); - private final ConcurrentHashMapWithDefault<Long, TraceBuffer> traceId2trace = new ConcurrentHashMapWithDefault<Long, TraceBuffer>(new TraceBuffer()); - private final Map<TraceEventRecords, TraceAggregationBuffer> trace2buffer = new TreeMap<TraceEventRecords, TraceAggregationBuffer>(new TraceComperator()); - private final List<SpScPipe> tcpRelayPipes = new ArrayList<SpScPipe>(); - - private Thread tcpThread; - private Thread clockThread; - private Thread[] workerThreads; - - private int numWorkerThreads; - - public void init() { - HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> tcpPipeline = this.buildTcpPipeline(); - this.tcpThread = new Thread(new RunnableStage(tcpPipeline)); - - HeadPipeline<Clock, Distributor<Long>> clockStage = this.buildClockPipeline(5000); - this.clockThread = new Thread(new RunnableStage(clockStage)); - - this.numWorkerThreads = Math.min(NUM_VIRTUAL_CORES, this.numWorkerThreads); - this.workerThreads = new Thread[this.numWorkerThreads]; - - for (int i = 0; i < this.workerThreads.length; i++) { - HeadStage pipeline = this.buildPipeline(tcpPipeline.getLastStage(), clockStage.getLastStage()); - this.workerThreads[i] = new Thread(new RunnableStage(pipeline)); - } - } - - private HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> buildTcpPipeline() { - TCPReader tcpReader = new TCPReader(); - Distributor<IMonitoringRecord> distributor = new Distributor<IMonitoringRecord>(); - - SingleElementPipe.connect(tcpReader.getOutputPort(), distributor.getInputPort()); - - // create and configure pipeline - HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> pipeline = new HeadPipeline<TCPReader, Distributor<IMonitoringRecord>>(); - pipeline.setFirstStage(tcpReader); - pipeline.setLastStage(distributor); - return pipeline; - } - - private HeadPipeline<Clock, Distributor<Long>> buildClockPipeline(final long intervalDelayInMs) { - Clock clock = new Clock(); - clock.setInitialDelayInMs(intervalDelayInMs); - clock.setIntervalDelayInMs(intervalDelayInMs); - Distributor<Long> distributor = new Distributor<Long>(); - - SingleElementPipe.connect(clock.getOutputPort(), distributor.getInputPort()); - - // create and configure pipeline - HeadPipeline<Clock, Distributor<Long>> pipeline = new HeadPipeline<Clock, Distributor<Long>>(); - pipeline.setFirstStage(clock); - pipeline.setLastStage(distributor); - return pipeline; - } - - private HeadStage buildPipeline(final Distributor<IMonitoringRecord> tcpReaderPipeline, final Distributor<Long> clockStage) { - // create stages - Relay<IMonitoringRecord> relay = new Relay<IMonitoringRecord>(); - final InstanceOfFilter<IMonitoringRecord, IFlowRecord> instanceOfFilter = new InstanceOfFilter<IMonitoringRecord, IFlowRecord>( - IFlowRecord.class); - final TraceReconstructionFilter traceReconstructionFilter = new TraceReconstructionFilter(this.traceId2trace); - TraceReductionFilter traceReductionFilter = new TraceReductionFilter(this.trace2buffer); - Sink<TraceEventRecords> endStage = new Sink<TraceEventRecords>(); - - // connect stages - SpScPipe tcpRelayPipe = SpScPipe.connect(tcpReaderPipeline.getNewOutputPort(), relay.getInputPort(), TCP_RELAY_MAX_SIZE); - this.tcpRelayPipes.add(tcpRelayPipe); - - SingleElementPipe.connect(relay.getOutputPort(), instanceOfFilter.getInputPort()); - SingleElementPipe.connect(instanceOfFilter.getOutputPort(), traceReconstructionFilter.getInputPort()); - SingleElementPipe.connect(traceReconstructionFilter.getTraceValidOutputPort(), traceReductionFilter.getInputPort()); - SingleElementPipe.connect(traceReductionFilter.getOutputPort(), endStage.getInputPort()); - - SpScPipe.connect(clockStage.getNewOutputPort(), traceReductionFilter.getTriggerInputPort(), 10); - - // create and configure pipeline - HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>> pipeline = new HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>>(); - pipeline.setFirstStage(relay); - pipeline.setLastStage(endStage); - return pipeline; - } - - public void start() { - - this.tcpThread.start(); - this.clockThread.start(); - - for (Thread workerThread : this.workerThreads) { - workerThread.start(); - } - - try { - this.tcpThread.join(); - - for (Thread workerThread : this.workerThreads) { - workerThread.join(); - } - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - this.clockThread.interrupt(); - } - - public void onTerminate() { - int maxNumWaits = 0; - for (SpScPipe pipe : this.tcpRelayPipes) { - maxNumWaits = Math.max(maxNumWaits, pipe.getNumWaits()); - } - System.out.println("max #waits of TcpRelayPipes: " + maxNumWaits); - } - - public List<TraceEventRecords> getElementCollection() { - return this.elementCollection; - } - - public int getNumWorkerThreads() { - return this.numWorkerThreads; - } - - public void setNumWorkerThreads(final int numWorkerThreads) { - this.numWorkerThreads = numWorkerThreads; - } - - public static void main(final String[] args) { - int numWorkerThreads = Integer.valueOf(args[0]); - - final TcpTraceReduction analysis = new TcpTraceReduction(); - analysis.setNumWorkerThreads(numWorkerThreads); - - analysis.init(); - try { - analysis.start(); - } finally { - analysis.onTerminate(); - } - } - -} diff --git a/src/performancetest/java/teetime/examples/recordReader/RecordReaderAnalysisTest.java b/src/performancetest/java/teetime/examples/recordReader/RecordReaderAnalysisTest.java deleted file mode 100644 index 6a49e22928924bf8ebc2fc08be376258d2ecd919..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/recordReader/RecordReaderAnalysisTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.examples.recordReader; - -import static org.junit.Assert.assertEquals; - -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import teetime.framework.Analysis; -import teetime.util.StopWatch; - -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.controlflow.OperationExecutionRecord; -import kieker.common.record.misc.KiekerMetadataRecord; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class RecordReaderAnalysisTest { - - private StopWatch stopWatch; - - @Before - public void before() { - this.stopWatch = new StopWatch(); - } - - @After - public void after() { - long overallDurationInNs = this.stopWatch.getDurationInNs(); - System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(overallDurationInNs) + " ms"); - } - - @Test - public void performAnalysis() { - final RecordReaderConfiguration configuration = new RecordReaderConfiguration(); - - Analysis analysis = new Analysis(configuration); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - assertEquals(6541, configuration.getElementCollection().size()); - - KiekerMetadataRecord metadataRecord = (KiekerMetadataRecord) configuration.getElementCollection().get(0); - assertEquals("1.9-SNAPSHOT", metadataRecord.getVersion()); - assertEquals("NANOSECONDS", metadataRecord.getTimeUnit()); - - IMonitoringRecord monitoringRecord = configuration.getElementCollection().get(1); - OperationExecutionRecord oer = (OperationExecutionRecord) monitoringRecord; - assertEquals("bookstoreTracing.Catalog.getBook(boolean)", oer.getOperationSignature()); - assertEquals(1283156498771185344l, oer.getTin()); - assertEquals(1283156498773323582l, oer.getTout()); - - monitoringRecord = configuration.getElementCollection().get(configuration.getElementCollection().size() - 1); - oer = (OperationExecutionRecord) monitoringRecord; - assertEquals("bookstoreTracing.Bookstore.searchBook()", oer.getOperationSignature()); - assertEquals(1283156499331233504l, oer.getTin()); - assertEquals(1283156499363031606l, oer.getTout()); - } - -} diff --git a/src/performancetest/java/teetime/examples/recordReader/RecordReaderConfiguration.java b/src/performancetest/java/teetime/examples/recordReader/RecordReaderConfiguration.java deleted file mode 100644 index fa289c0af832521ab19df88024c0b7853ef91b09..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/recordReader/RecordReaderConfiguration.java +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.examples.recordReader; - -import java.io.File; -import java.util.LinkedList; -import java.util.List; - -import teetime.framework.AnalysisConfiguration; -import teetime.framework.HeadStage; -import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering; -import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; -import teetime.stage.CollectorSink; -import teetime.stage.InitialElementProducer; -import teetime.stage.kieker.Dir2RecordsFilter; -import teetime.stage.kieker.className.ClassNameRegistryRepository; - -import kieker.common.record.IMonitoringRecord; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class RecordReaderConfiguration extends AnalysisConfiguration { - - private final List<IMonitoringRecord> elementCollection = new LinkedList<IMonitoringRecord>(); - - public RecordReaderConfiguration() { - this.buildConfiguration(); - } - - private void buildConfiguration() { - HeadStage producerPipeline = this.buildProducerPipeline(); - this.getFiniteProducerStages().add(producerPipeline); - } - - private HeadStage buildProducerPipeline() { - ClassNameRegistryRepository classNameRegistryRepository = new ClassNameRegistryRepository(); - File logDir = new File("src/test/data/bookstore-logs"); - // create stages - InitialElementProducer<File> initialElementProducer = new InitialElementProducer<File>(logDir); - Dir2RecordsFilter dir2RecordsFilter = new Dir2RecordsFilter(classNameRegistryRepository); - CollectorSink<IMonitoringRecord> collector = new CollectorSink<IMonitoringRecord>(this.elementCollection); - - // connect stages - PIPE_FACTORY_REGISTRY.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) - .create(initialElementProducer.getOutputPort(), dir2RecordsFilter.getInputPort()); - - PIPE_FACTORY_REGISTRY.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) - .create(dir2RecordsFilter.getOutputPort(), collector.getInputPort()); - - return initialElementProducer; - } - - public List<IMonitoringRecord> getElementCollection() { - return this.elementCollection; - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReading/ChwHomeTcpTraceReadingTest.java b/src/performancetest/java/teetime/examples/traceReading/ChwHomeTcpTraceReadingTest.java deleted file mode 100644 index 6b23a328646b716b1e0f1a743ea94d05df655959..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReading/ChwHomeTcpTraceReadingTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.examples.traceReading; - -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.assertThat; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import teetime.util.ListUtil; -import teetime.util.StopWatch; -import util.test.StatisticsUtil; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ChwHomeTcpTraceReadingTest { - - private static final int MIO = 1000000; - private static final int EXPECTED_NUM_TRACES = 10 * MIO; - private static final int EXPECTED_NUM_RECORDS = 21 * EXPECTED_NUM_TRACES + 1; - - private StopWatch stopWatch; - - @Before - public void before() { - this.stopWatch = new StopWatch(); - } - - @After - public void after() { - long overallDurationInNs = this.stopWatch.getDurationInNs(); - System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(overallDurationInNs) + " ms"); - } - - @Test - public void performAnalysis() { - final TcpTraceLoggingExtAnalysis analysis = new TcpTraceLoggingExtAnalysis(); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - List<Long> recordThroughputs = ListUtil.removeFirstHalfElements(analysis.getRecordThroughputs()); - Map<Double, Long> recordQuintiles = StatisticsUtil.calculateQuintiles(recordThroughputs); - System.out.println("Median record throughput: " + recordQuintiles.get(0.5) + " records/time unit"); - - assertEquals("#records", EXPECTED_NUM_RECORDS, analysis.getNumRecords()); - - // 08.07.2014 (incl.) - assertThat(recordQuintiles.get(0.5), is(both(greaterThan(3000L)).and(lessThan(3500L)))); - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReading/TcpTraceLoggingExtAnalysis.java b/src/performancetest/java/teetime/examples/traceReading/TcpTraceLoggingExtAnalysis.java deleted file mode 100644 index fcf14f30f008543a81800f190fcebce259ad03fc..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReading/TcpTraceLoggingExtAnalysis.java +++ /dev/null @@ -1,92 +0,0 @@ -package teetime.examples.traceReading; - -import java.util.List; - -import teetime.framework.HeadPipeline; -import teetime.framework.RunnableStage; -import teetime.framework.pipe.SingleElementPipe; -import teetime.framework.pipe.SpScPipe; -import teetime.stage.Clock; -import teetime.stage.Counter; -import teetime.stage.ElementThroughputMeasuringStage; -import teetime.stage.basic.Sink; -import teetime.stage.basic.distributor.Distributor; -import teetime.stage.io.TCPReader; - -import kieker.common.record.IMonitoringRecord; - -public class TcpTraceLoggingExtAnalysis { - - private Thread clockThread; - private Thread tcpThread; - - private Counter<IMonitoringRecord> recordCounter; - private ElementThroughputMeasuringStage<IMonitoringRecord> recordThroughputStage; - - private HeadPipeline<Clock, Distributor<Long>> buildClockPipeline(final long intervalDelayInMs) { - Clock clockStage = new Clock(); - clockStage.setInitialDelayInMs(intervalDelayInMs); - clockStage.setIntervalDelayInMs(intervalDelayInMs); - Distributor<Long> distributor = new Distributor<Long>(); - - SingleElementPipe.connect(clockStage.getOutputPort(), distributor.getInputPort()); - - // create and configure pipeline - HeadPipeline<Clock, Distributor<Long>> pipeline = new HeadPipeline<Clock, Distributor<Long>>(); - pipeline.setFirstStage(clockStage); - pipeline.setLastStage(distributor); - return pipeline; - } - - private HeadPipeline<?, ?> buildTcpPipeline(final Distributor<Long> previousClockStage) { - TCPReader tcpReader = new TCPReader(); - this.recordCounter = new Counter<IMonitoringRecord>(); - this.recordThroughputStage = new ElementThroughputMeasuringStage<IMonitoringRecord>(); - Sink<IMonitoringRecord> endStage = new Sink<IMonitoringRecord>(); - - SingleElementPipe.connect(tcpReader.getOutputPort(), this.recordCounter.getInputPort()); - SingleElementPipe.connect(this.recordCounter.getOutputPort(), this.recordThroughputStage.getInputPort()); - SingleElementPipe.connect(this.recordThroughputStage.getOutputPort(), endStage.getInputPort()); - // SingleElementPipe.connect(this.recordCounter.getOutputPort(), endStage.getInputPort()); - - SpScPipe.connect(previousClockStage.getNewOutputPort(), this.recordThroughputStage.getTriggerInputPort(), 10); - - // create and configure pipeline - HeadPipeline<TCPReader, Sink<IMonitoringRecord>> pipeline = new HeadPipeline<TCPReader, Sink<IMonitoringRecord>>(); - pipeline.setFirstStage(tcpReader); - pipeline.setLastStage(endStage); - return pipeline; - } - - public void init() { - - HeadPipeline<Clock, Distributor<Long>> clockPipeline = this.buildClockPipeline(1000); - this.clockThread = new Thread(new RunnableStage(clockPipeline)); - - HeadPipeline<?, ?> tcpPipeline = this.buildTcpPipeline(clockPipeline.getLastStage()); - this.tcpThread = new Thread(new RunnableStage(tcpPipeline)); - } - - public void start() { - - this.tcpThread.start(); - this.clockThread.start(); - - try { - this.tcpThread.join(); - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - - this.clockThread.interrupt(); - } - - public int getNumRecords() { - return this.recordCounter.getNumElementsPassed(); - } - - public List<Long> getRecordThroughputs() { - return this.recordThroughputStage.getThroughputs(); - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReconstruction/ChwHomeTcpTraceReconstructionAnalysisTest.java b/src/performancetest/java/teetime/examples/traceReconstruction/ChwHomeTcpTraceReconstructionAnalysisTest.java deleted file mode 100644 index 1158dade907c11c392f4e6e30ff4cd16a3db55e7..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstruction/ChwHomeTcpTraceReconstructionAnalysisTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.examples.traceReconstruction; - -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.assertThat; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import teetime.util.ListUtil; -import teetime.util.StopWatch; -import util.test.StatisticsUtil; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class ChwHomeTcpTraceReconstructionAnalysisTest { - - private static final int MIO = 1000000; - private static final int EXPECTED_NUM_TRACES = 10 * MIO; - private static final int EXPECTED_NUM_RECORDS = 21 * EXPECTED_NUM_TRACES + 1; - - private StopWatch stopWatch; - - @Before - public void before() { - this.stopWatch = new StopWatch(); - } - - @After - public void after() { - long overallDurationInNs = this.stopWatch.getDurationInNs(); - System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(overallDurationInNs) + " ms"); - } - - @Test - public void performAnalysis() { - final TcpTraceReconstructionAnalysis analysis = new TcpTraceReconstructionAnalysis(); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - List<Long> recordThroughputs = ListUtil.removeFirstHalfElements(analysis.getRecordThroughputs()); - Map<Double, Long> recordQuintiles = StatisticsUtil.calculateQuintiles(recordThroughputs); - System.out.println("Median record throughput: " + recordQuintiles.get(0.5) + " elements/time unit"); - - // List<Long> traceThroughputs = ListUtil.removeFirstHalfElements(analysis.getTraceThroughputs()); - // Map<Double, Long> traceQuintiles = StatisticsUtil.calculateQuintiles(traceThroughputs); - // System.out.println("Median trace throughput: " + traceQuintiles.get(0.5) + " traces/time unit"); - - assertEquals("#records", EXPECTED_NUM_RECORDS, analysis.getNumRecords()); - assertEquals("#traces", EXPECTED_NUM_TRACES, analysis.getNumTraces()); - - // TraceEventRecords trace6884 = analysis.getElementCollection().get(0); - // assertEquals(6884, trace6884.getTraceMetadata().getTraceId()); - // - // TraceEventRecords trace6886 = analysis.getElementCollection().get(1); - // assertEquals(6886, trace6886.getTraceMetadata().getTraceId()); - - // until 04.07.2014 (incl.) - // Median throughput: 74 elements/time unit - // Duration: 17445 ms - // Median throughput: 78 elements/time unit - // Duration: 16608 ms - - // 08.07.2014 (incl.) - assertThat(recordQuintiles.get(0.5), is(both(greaterThan(3000L)).and(lessThan(3200L)))); - } -} diff --git a/src/performancetest/java/teetime/examples/traceReconstruction/ChwHomeTraceReconstructionAnalysisTest.java b/src/performancetest/java/teetime/examples/traceReconstruction/ChwHomeTraceReconstructionAnalysisTest.java deleted file mode 100644 index bf85954aff055d7cfc44b52da3acc95431c3d146..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstruction/ChwHomeTraceReconstructionAnalysisTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.examples.traceReconstruction; - -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.assertThat; - -import java.io.File; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import teetime.util.StopWatch; -import util.test.StatisticsUtil; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class ChwHomeTraceReconstructionAnalysisTest { - - private StopWatch stopWatch; - - @Before - public void before() { - this.stopWatch = new StopWatch(); - } - - @After - public void after() { - long overallDurationInNs = this.stopWatch.getDurationInNs(); - System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(overallDurationInNs) + " ms"); - } - - @Test - public void performAnalysisWithEprintsLogs() { - final TraceReconstructionAnalysis analysis = new TraceReconstructionAnalysis(); - analysis.setInputDir(new File("src/test/data/Eprints-logs")); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - StatisticsUtil.removeLeadingZeroThroughputs(analysis.getThroughputs()); - Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(analysis.getThroughputs()); - System.out.println("Median throughput: " + quintiles.get(0.5) + " elements/time unit"); - - assertEquals(50002, analysis.getNumRecords()); - assertEquals(2, analysis.getNumTraces()); - - TraceEventRecords trace6884 = analysis.getElementCollection().get(0); - assertEquals(6884, trace6884.getTraceMetadata().getTraceId()); - - TraceEventRecords trace6886 = analysis.getElementCollection().get(1); - assertEquals(6886, trace6886.getTraceMetadata().getTraceId()); - - assertThat(quintiles.get(0.5), is(both(greaterThan(34l)).and(lessThan(320l)))); - } - - @Test - public void performAnalysisWithKiekerLogs() { - final TraceReconstructionAnalysis analysis = new TraceReconstructionAnalysis(); - analysis.setInputDir(new File("src/test/data/kieker-logs")); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - StatisticsUtil.removeLeadingZeroThroughputs(analysis.getThroughputs()); - Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(analysis.getThroughputs()); - System.out.println("Median throughput: " + quintiles.get(0.5) + " elements/time unit"); - - assertEquals(1489902, analysis.getNumRecords()); - assertEquals(24013, analysis.getNumTraces()); - - TraceEventRecords trace0 = analysis.getElementCollection().get(0); - assertEquals(8974347286117089280l, trace0.getTraceMetadata().getTraceId()); - - TraceEventRecords trace1 = analysis.getElementCollection().get(1); - assertEquals(8974347286117089281l, trace1.getTraceMetadata().getTraceId()); - - assertThat(quintiles.get(0.5), is(both(greaterThan(1700l)).and(lessThan(1900l)))); - } - - @Test - public void performAnalysisWithKieker2Logs() { - final TraceReconstructionAnalysis analysis = new TraceReconstructionAnalysis(); - analysis.setInputDir(new File("src/test/data/kieker2-logs")); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - StatisticsUtil.removeLeadingZeroThroughputs(analysis.getThroughputs()); - Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(analysis.getThroughputs()); - System.out.println("Median throughput: " + quintiles.get(0.5) + " elements/time unit"); - - assertEquals(17371, analysis.getNumRecords()); - assertEquals(22, analysis.getNumTraces()); - - TraceEventRecords trace0 = analysis.getElementCollection().get(0); - assertEquals(0, trace0.getTraceMetadata().getTraceId()); - - TraceEventRecords trace1 = analysis.getElementCollection().get(1); - assertEquals(1, trace1.getTraceMetadata().getTraceId()); - - assertThat(quintiles.get(0.5), is(both(greaterThan(200l)).and(lessThan(250l)))); - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReconstruction/ChwWorkTcpTraceReconstructionAnalysisTest.java b/src/performancetest/java/teetime/examples/traceReconstruction/ChwWorkTcpTraceReconstructionAnalysisTest.java deleted file mode 100644 index 8bc965b84c26c72a8074ab469ae9ea76ba4ea72d..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstruction/ChwWorkTcpTraceReconstructionAnalysisTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.examples.traceReconstruction; - -import static org.junit.Assert.assertEquals; - -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import teetime.util.StopWatch; -import util.test.StatisticsUtil; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class ChwWorkTcpTraceReconstructionAnalysisTest { - - private static final int MIO = 1000000; - private static final int EXPECTED_NUM_TRACES = 10 * MIO; - private static final int EXPECTED_NUM_RECORDS = 21 * EXPECTED_NUM_TRACES + 1; - - private StopWatch stopWatch; - - @Before - public void before() { - this.stopWatch = new StopWatch(); - } - - @After - public void after() { - long overallDurationInNs = this.stopWatch.getDurationInNs(); - System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(overallDurationInNs) + " ms"); - } - - @Test - public void performAnalysis() { - final TcpTraceReconstructionAnalysis analysis = new TcpTraceReconstructionAnalysis(); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(analysis.getTraceThroughputs()); - System.out.println("Median throughput: " + quintiles.get(0.5) + " elements/time unit"); - - assertEquals(EXPECTED_NUM_RECORDS, analysis.getNumRecords()); - assertEquals(EXPECTED_NUM_TRACES, analysis.getNumTraces()); - - // TraceEventRecords trace6884 = analysis.getElementCollection().get(0); - // assertEquals(6884, trace6884.getTraceMetadata().getTraceId()); - // - // TraceEventRecords trace6886 = analysis.getElementCollection().get(1); - // assertEquals(6886, trace6886.getTraceMetadata().getTraceId()); - - // until 04.07.2014 (inkl.) - // Median throughput: 74 elements/time unit - // Duration: 17445 ms - // Median throughput: 78 elements/time unit - // Duration: 16608 ms - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReconstruction/ChwWorkTraceReconstructionAnalysisTest.java b/src/performancetest/java/teetime/examples/traceReconstruction/ChwWorkTraceReconstructionAnalysisTest.java deleted file mode 100644 index c7438eca97eedc4c28fafb7f1a367556c18f2ff0..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstruction/ChwWorkTraceReconstructionAnalysisTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.examples.traceReconstruction; - -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.assertThat; - -import java.io.File; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import teetime.util.StopWatch; -import util.test.StatisticsUtil; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -public class ChwWorkTraceReconstructionAnalysisTest { - - private StopWatch stopWatch; - - @Before - public void before() { - this.stopWatch = new StopWatch(); - } - - @After - public void after() { - long overallDurationInNs = this.stopWatch.getDurationInNs(); - System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(overallDurationInNs) + " ms"); - } - - @Test - public void performAnalysisWithEprintsLogs() { - final TraceReconstructionAnalysis analysis = new TraceReconstructionAnalysis(); - analysis.setInputDir(new File("src/test/data/Eprints-logs")); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - assertEquals(50002, analysis.getNumRecords()); - assertEquals(2, analysis.getNumTraces()); - - TraceEventRecords trace6884 = analysis.getElementCollection().get(0); - assertEquals(6884, trace6884.getTraceMetadata().getTraceId()); - - TraceEventRecords trace6886 = analysis.getElementCollection().get(1); - assertEquals(6886, trace6886.getTraceMetadata().getTraceId()); - - StatisticsUtil.removeLeadingZeroThroughputs(analysis.getThroughputs()); - Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(analysis.getThroughputs()); - System.out.println("Median throughput: " + quintiles.get(0.5) + " elements/time unit"); - } - - @Test - public void performAnalysisWithKiekerLogs() { - final TraceReconstructionAnalysis analysis = new TraceReconstructionAnalysis(); - analysis.setInputDir(new File("src/test/data/kieker-logs")); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - assertEquals(1489902, analysis.getNumRecords()); - assertEquals(24013, analysis.getNumTraces()); - - TraceEventRecords trace0 = analysis.getElementCollection().get(0); - assertEquals(8974347286117089280l, trace0.getTraceMetadata().getTraceId()); - - TraceEventRecords trace1 = analysis.getElementCollection().get(1); - assertEquals(8974347286117089281l, trace1.getTraceMetadata().getTraceId()); - - StatisticsUtil.removeLeadingZeroThroughputs(analysis.getThroughputs()); - Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(analysis.getThroughputs()); - System.out.println("Median throughput: " + quintiles.get(0.5) + " elements/time unit"); - - assertThat(quintiles.get(0.5), is(both(greaterThan(1100l)).and(lessThan(1400l)))); - } - - @Test - public void performAnalysisWithKieker2Logs() { - final TraceReconstructionAnalysis analysis = new TraceReconstructionAnalysis(); - analysis.setInputDir(new File("src/test/data/kieker2-logs")); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - assertEquals(17371, analysis.getNumRecords()); - assertEquals(22, analysis.getNumTraces()); - - TraceEventRecords trace0 = analysis.getElementCollection().get(0); - assertEquals(0, trace0.getTraceMetadata().getTraceId()); - - TraceEventRecords trace1 = analysis.getElementCollection().get(1); - assertEquals(1, trace1.getTraceMetadata().getTraceId()); - - StatisticsUtil.removeLeadingZeroThroughputs(analysis.getThroughputs()); - Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(analysis.getThroughputs()); - System.out.println("Median throughput: " + quintiles.get(0.5) + " elements/time unit"); - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReconstruction/KiekerTraceReconstructionAnalysis.java b/src/performancetest/java/teetime/examples/traceReconstruction/KiekerTraceReconstructionAnalysis.java deleted file mode 100644 index 40f0170f52558cc7b5a1a394cfc8f7518c88f099..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstruction/KiekerTraceReconstructionAnalysis.java +++ /dev/null @@ -1,146 +0,0 @@ -package teetime.examples.traceReconstruction; - -import java.io.File; -import java.util.LinkedList; -import java.util.List; - -import kieker.analysis.AnalysisController; -import kieker.analysis.IAnalysisController; -import kieker.analysis.IProjectContext; -import kieker.analysis.exception.AnalysisConfigurationException; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; -import kieker.analysis.plugin.filter.flow.EventRecordTraceReconstructionFilter; -import kieker.analysis.plugin.filter.flow.TraceEventRecords; -import kieker.analysis.plugin.filter.forward.AnalysisThroughputFilter; -import kieker.analysis.plugin.filter.forward.CountingFilter; -import kieker.analysis.plugin.filter.forward.StringBufferFilter; -import kieker.analysis.plugin.filter.select.TypeFilter; -import kieker.analysis.plugin.reader.AbstractReaderPlugin; -import kieker.analysis.plugin.reader.filesystem.FSReader; -import kieker.analysis.stage.CacheFilter; -import kieker.analysis.stage.CollectorSink; -import kieker.analysis.stage.TimeReader; -import kieker.common.configuration.Configuration; -import kieker.common.record.flow.IFlowRecord; - -public class KiekerTraceReconstructionAnalysis { - - private final IAnalysisController analysisController = new AnalysisController(); - - private final List<TraceEventRecords> elementCollection = new LinkedList<TraceEventRecords>(); - private final List<Long> throughputCollection = new LinkedList<Long>(); - - private CountingFilter recordCounter; - private CountingFilter traceCounter; - private AnalysisThroughputFilter throughputFilter; - - private final File inputDir; - - public KiekerTraceReconstructionAnalysis(final File inputDir) { - this.inputDir = inputDir; - } - - public void init() { - - final Configuration clockConfiguration = new Configuration(); - clockConfiguration.setProperty(TimeReader.CONFIG_PROPERTY_VALUE_UPDATE_INTERVAL_NS, Integer.toString(50 * 1000 * 1000)); - final AbstractReaderPlugin clock = new TimeReader(clockConfiguration, this.analysisController); - - final Configuration readerConfiguration = new Configuration(); - readerConfiguration.setProperty(FSReader.CONFIG_PROPERTY_NAME_INPUTDIRS, this.inputDir.getAbsolutePath()); - final AbstractReaderPlugin reader = new FinalTerminationReader(readerConfiguration, this.analysisController, clock); - - this.recordCounter = new CountingFilter(new Configuration(), this.analysisController); - - final AbstractFilterPlugin cache = new CacheFilter(new Configuration(), this.analysisController); - - final AbstractFilterPlugin stringBufferFilter = new StringBufferFilter(new Configuration(), this.analysisController); - - final Configuration typeFilterConfiguration = new Configuration(); - typeFilterConfiguration.setProperty(TypeFilter.CONFIG_PROPERTY_NAME_TYPES, IFlowRecord.class.getCanonicalName()); - final AbstractFilterPlugin typeFilter = new TypeFilter(typeFilterConfiguration, this.analysisController); - - this.throughputFilter = new AnalysisThroughputFilter(new Configuration(), this.analysisController); - final EventRecordTraceReconstructionFilter traceReconstructionFilter = new EventRecordTraceReconstructionFilter(new Configuration(), this.analysisController); - this.traceCounter = new CountingFilter(new Configuration(), this.analysisController); - final CollectorSink<TraceEventRecords> collector = new CollectorSink<TraceEventRecords>(new Configuration(), this.analysisController, this.elementCollection); - - final CollectorSink<Long> throughputCollector = new CollectorSink<Long>(new Configuration(), this.analysisController, this.throughputCollection); - - try { - this.analysisController.connect(reader, FSReader.OUTPUT_PORT_NAME_RECORDS, this.recordCounter, CountingFilter.INPUT_PORT_NAME_EVENTS); - this.analysisController.connect(this.recordCounter, CountingFilter.OUTPUT_PORT_NAME_RELAYED_EVENTS, cache, CacheFilter.INPUT_PORT_NAME); - - this.analysisController.connect(cache, CacheFilter.OUTPUT_PORT_NAME, stringBufferFilter, StringBufferFilter.INPUT_PORT_NAME_EVENTS); - - this.analysisController.connect(stringBufferFilter, StringBufferFilter.OUTPUT_PORT_NAME_RELAYED_EVENTS, typeFilter, TypeFilter.INPUT_PORT_NAME_EVENTS); - this.analysisController.connect(typeFilter, TypeFilter.OUTPUT_PORT_NAME_TYPE_MATCH, this.throughputFilter, - AnalysisThroughputFilter.INPUT_PORT_NAME_OBJECTS); - this.analysisController.connect(this.throughputFilter, AnalysisThroughputFilter.OUTPUT_PORT_NAME_RELAYED_OBJECTS, traceReconstructionFilter, - EventRecordTraceReconstructionFilter.INPUT_PORT_NAME_TRACE_RECORDS); - this.analysisController.connect(traceReconstructionFilter, EventRecordTraceReconstructionFilter.OUTPUT_PORT_NAME_TRACE_VALID, this.traceCounter, - CountingFilter.INPUT_PORT_NAME_EVENTS); - this.analysisController.connect(traceReconstructionFilter, EventRecordTraceReconstructionFilter.OUTPUT_PORT_NAME_TRACE_INVALID, this.traceCounter, - CountingFilter.INPUT_PORT_NAME_EVENTS); - this.analysisController.connect(this.traceCounter, CountingFilter.OUTPUT_PORT_NAME_RELAYED_EVENTS, collector, CollectorSink.INPUT_PORT_NAME); - this.analysisController.connect(this.throughputFilter, AnalysisThroughputFilter.OUTPUT_PORT_NAME_THROUGHPUT, throughputCollector, - CollectorSink.INPUT_PORT_NAME); - - this.analysisController.connect(clock, TimeReader.OUTPUT_PORT_NAME_TIMESTAMPS, this.throughputFilter, AnalysisThroughputFilter.INPUT_PORT_NAME_TIME); - } catch (IllegalStateException e) { - e.printStackTrace(); - } catch (AnalysisConfigurationException e) { - e.printStackTrace(); - } - - } - - public void start() { - - try { - this.analysisController.run(); - } catch (IllegalStateException e) { - e.printStackTrace(); - } catch (AnalysisConfigurationException e) { - e.printStackTrace(); - } - } - - public List<TraceEventRecords> getElementCollection() { - return this.elementCollection; - } - - public long getNumRecords() { - return this.recordCounter.getMessageCount(); - } - - public long getNumTraces() { - return this.traceCounter.getMessageCount(); - } - - public List<Long> getThroughputs() { - return this.throughputCollection; - } - - private static class FinalTerminationReader extends FSReader { - - private final AbstractReaderPlugin clock; - - public FinalTerminationReader(final Configuration configuration, final IProjectContext projectContext, final AbstractReaderPlugin clock) { - super(configuration, projectContext); - - this.clock = clock; - } - - @Override - public boolean read() { - final boolean result = super.read(); - - this.clock.terminate(result); - - return result; - } - - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReconstruction/NieWorkKiekerTraceReconstructionAnalysisTest.java b/src/performancetest/java/teetime/examples/traceReconstruction/NieWorkKiekerTraceReconstructionAnalysisTest.java deleted file mode 100644 index daa1b9aef5fdadbe13c7aa30480c5285d8d9c46f..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstruction/NieWorkKiekerTraceReconstructionAnalysisTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.examples.traceReconstruction; - -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.assertThat; - -import java.io.File; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import teetime.util.StopWatch; -import util.test.StatisticsUtil; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; - -/** - * @author Nils Christian Ehmke - */ -public class NieWorkKiekerTraceReconstructionAnalysisTest { - - private StopWatch stopWatch; - - @Before - public void before() { - this.stopWatch = new StopWatch(); - } - - @After - public void after() { - long overallDurationInNs = this.stopWatch.getDurationInNs(); - System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(overallDurationInNs) + " ms"); - } - - @Test - public void performAnalysisWithEprintsLogs() { - final KiekerTraceReconstructionAnalysis analysis = new KiekerTraceReconstructionAnalysis(new File("src/test/data/Eprints-logs")); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - assertEquals(50002, analysis.getNumRecords()); - assertEquals(2, analysis.getNumTraces()); - - TraceEventRecords trace6884 = analysis.getElementCollection().get(0); - assertEquals(6884, trace6884.getTraceMetadata().getTraceId()); - - TraceEventRecords trace6886 = analysis.getElementCollection().get(1); - assertEquals(6886, trace6886.getTraceMetadata().getTraceId()); - - Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(analysis.getThroughputs()); - System.out.println("Mean throughput: " + quintiles.get(0.5) + " time units/element"); - } - - @Test - public void performAnalysisWithKiekerLogs() { - final KiekerTraceReconstructionAnalysis analysis = new KiekerTraceReconstructionAnalysis(new File("src/test/data/kieker-logs")); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - assertEquals(1489901, analysis.getNumRecords()); - assertEquals(24013, analysis.getNumTraces()); - - TraceEventRecords trace0 = analysis.getElementCollection().get(0); - assertEquals(8974347286117089280l, trace0.getTraceMetadata().getTraceId()); - - TraceEventRecords trace1 = analysis.getElementCollection().get(1); - assertEquals(8974347286117089281l, trace1.getTraceMetadata().getTraceId()); - - Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(analysis.getThroughputs()); - System.out.println("Mean throughput: " + quintiles.get(0.5) + " time units/element"); - - assertThat(quintiles.get(0.5), is(both(greaterThan(1100l)).and(lessThan(1400l)))); - } - - @Test - public void performAnalysisWithKieker2Logs() { - final KiekerTraceReconstructionAnalysis analysis = new KiekerTraceReconstructionAnalysis(new File("src/test/data/kieker2-logs")); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - assertEquals(17371, analysis.getNumRecords()); - assertEquals(22, analysis.getNumTraces()); - - TraceEventRecords trace0 = analysis.getElementCollection().get(0); - assertEquals(0, trace0.getTraceMetadata().getTraceId()); - - TraceEventRecords trace1 = analysis.getElementCollection().get(1); - assertEquals(1, trace1.getTraceMetadata().getTraceId()); - - Map<Double, Long> quintiles = StatisticsUtil.calculateQuintiles(analysis.getThroughputs()); - System.out.println("Mean throughput: " + quintiles.get(0.5) + " time units/element"); - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReconstruction/TcpTraceReconstructionAnalysis.java b/src/performancetest/java/teetime/examples/traceReconstruction/TcpTraceReconstructionAnalysis.java deleted file mode 100644 index ff835b17817bc32b0bfe5d532b39b53a4822ca5d..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstruction/TcpTraceReconstructionAnalysis.java +++ /dev/null @@ -1,136 +0,0 @@ -package teetime.examples.traceReconstruction; - -import java.util.LinkedList; -import java.util.List; - -import teetime.framework.HeadPipeline; -import teetime.framework.RunnableStage; -import teetime.framework.pipe.SingleElementPipe; -import teetime.framework.pipe.SpScPipe; -import teetime.stage.Clock; -import teetime.stage.Counter; -import teetime.stage.ElementThroughputMeasuringStage; -import teetime.stage.InstanceOfFilter; -import teetime.stage.basic.Sink; -import teetime.stage.basic.distributor.Distributor; -import teetime.stage.io.TCPReader; -import teetime.stage.kieker.traceReconstruction.TraceReconstructionFilter; -import teetime.util.concurrent.hashmap.ConcurrentHashMapWithDefault; -import teetime.util.concurrent.hashmap.TraceBuffer; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.flow.IFlowRecord; - -public class TcpTraceReconstructionAnalysis { - - private static final int MIO = 1000000; - private static final int TCP_RELAY_MAX_SIZE = 2 * MIO; - - private final List<TraceEventRecords> elementCollection = new LinkedList<TraceEventRecords>(); - - private Thread clockThread; - private Thread clock2Thread; - private Thread workerThread; - - private final ConcurrentHashMapWithDefault<Long, TraceBuffer> traceId2trace = new ConcurrentHashMapWithDefault<Long, TraceBuffer>(new TraceBuffer()); - - private Counter<IMonitoringRecord> recordCounter; - private Counter<TraceEventRecords> traceCounter; - private ElementThroughputMeasuringStage<IFlowRecord> recordThroughputFilter; - private ElementThroughputMeasuringStage<TraceEventRecords> traceThroughputFilter; - - public void init() { - HeadPipeline<Clock, Distributor<Long>> clockStage = this.buildClockPipeline(1000); - this.clockThread = new Thread(new RunnableStage(clockStage)); - - HeadPipeline<Clock, Distributor<Long>> clock2Stage = this.buildClockPipeline(2000); - this.clock2Thread = new Thread(new RunnableStage(clock2Stage)); - - HeadPipeline<?, ?> pipeline = this.buildPipeline(clockStage.getLastStage(), clock2Stage.getLastStage()); - this.workerThread = new Thread(new RunnableStage(pipeline)); - } - - private HeadPipeline<Clock, Distributor<Long>> buildClockPipeline(final long intervalDelayInMs) { - Clock clock = new Clock(); - clock.setIntervalDelayInMs(intervalDelayInMs); - Distributor<Long> distributor = new Distributor<Long>(); - - SingleElementPipe.connect(clock.getOutputPort(), distributor.getInputPort()); - - // create and configure pipeline - HeadPipeline<Clock, Distributor<Long>> pipeline = new HeadPipeline<Clock, Distributor<Long>>(); - pipeline.setFirstStage(clock); - pipeline.setLastStage(distributor); - return pipeline; - } - - private HeadPipeline<TCPReader, Sink<TraceEventRecords>> buildPipeline(final Distributor<Long> clockStage, final Distributor<Long> clock2Stage) { - // create stages - TCPReader tcpReader = new TCPReader(); - this.recordCounter = new Counter<IMonitoringRecord>(); - final InstanceOfFilter<IMonitoringRecord, IFlowRecord> instanceOfFilter = new InstanceOfFilter<IMonitoringRecord, IFlowRecord>( - IFlowRecord.class); - this.recordThroughputFilter = new ElementThroughputMeasuringStage<IFlowRecord>(); - final TraceReconstructionFilter traceReconstructionFilter = new TraceReconstructionFilter(this.traceId2trace); - this.traceThroughputFilter = new ElementThroughputMeasuringStage<TraceEventRecords>(); - this.traceCounter = new Counter<TraceEventRecords>(); - Sink<TraceEventRecords> endStage = new Sink<TraceEventRecords>(); - - // connect stages - SpScPipe.connect(tcpReader.getOutputPort(), this.recordCounter.getInputPort(), TCP_RELAY_MAX_SIZE); - SingleElementPipe.connect(this.recordCounter.getOutputPort(), instanceOfFilter.getInputPort()); - // SingleElementPipe.connect(instanceOfFilter.getOutputPort(), this.recordThroughputFilter.getInputPort()); - // SingleElementPipe.connect(this.recordThroughputFilter.getOutputPort(), traceReconstructionFilter.getInputPort()); - SingleElementPipe.connect(instanceOfFilter.getOutputPort(), traceReconstructionFilter.getInputPort()); - SingleElementPipe.connect(traceReconstructionFilter.getTraceValidOutputPort(), this.traceThroughputFilter.getInputPort()); - SingleElementPipe.connect(this.traceThroughputFilter.getOutputPort(), this.traceCounter.getInputPort()); - // SingleElementPipe.connect(traceReconstructionFilter.getTraceValidOutputPort(), this.traceCounter.getInputPort()); - SingleElementPipe.connect(this.traceCounter.getOutputPort(), endStage.getInputPort()); - - SpScPipe.connect(clockStage.getNewOutputPort(), this.recordThroughputFilter.getTriggerInputPort(), 10); - SpScPipe.connect(clock2Stage.getNewOutputPort(), this.traceThroughputFilter.getTriggerInputPort(), 10); - - // create and configure pipeline - HeadPipeline<TCPReader, Sink<TraceEventRecords>> pipeline = new HeadPipeline<TCPReader, Sink<TraceEventRecords>>(); - pipeline.setFirstStage(tcpReader); - pipeline.setLastStage(endStage); - return pipeline; - } - - public void start() { - - this.workerThread.start(); - // this.clockThread.start(); - this.clock2Thread.start(); - - try { - this.workerThread.join(); - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - this.clockThread.interrupt(); - this.clock2Thread.interrupt(); - } - - public List<TraceEventRecords> getElementCollection() { - return this.elementCollection; - } - - public int getNumRecords() { - return this.recordCounter.getNumElementsPassed(); - } - - public int getNumTraces() { - return this.traceCounter.getNumElementsPassed(); - } - - public List<Long> getRecordThroughputs() { - return this.recordThroughputFilter.getThroughputs(); - } - - public List<Long> getTraceThroughputs() { - return this.traceThroughputFilter.getThroughputs(); - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReconstruction/TraceReconstructionAnalysis.java b/src/performancetest/java/teetime/examples/traceReconstruction/TraceReconstructionAnalysis.java deleted file mode 100644 index dd4545c820858902263ef4c5aca20a7490884c06..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstruction/TraceReconstructionAnalysis.java +++ /dev/null @@ -1,150 +0,0 @@ -package teetime.examples.traceReconstruction; - -import java.io.File; -import java.util.LinkedList; -import java.util.List; - -import teetime.framework.HeadPipeline; -import teetime.framework.RunnableStage; -import teetime.framework.pipe.SingleElementPipe; -import teetime.framework.pipe.SpScPipe; -import teetime.stage.Cache; -import teetime.stage.Clock; -import teetime.stage.CollectorSink; -import teetime.stage.Counter; -import teetime.stage.ElementThroughputMeasuringStage; -import teetime.stage.InitialElementProducer; -import teetime.stage.InstanceOfFilter; -import teetime.stage.basic.merger.Merger; -import teetime.stage.kieker.Dir2RecordsFilter; -import teetime.stage.kieker.className.ClassNameRegistryRepository; -import teetime.stage.kieker.traceReconstruction.TraceReconstructionFilter; -import teetime.stage.stringBuffer.StringBufferFilter; -import teetime.stage.stringBuffer.handler.IMonitoringRecordHandler; -import teetime.stage.stringBuffer.handler.StringHandler; -import teetime.util.concurrent.hashmap.ConcurrentHashMapWithDefault; -import teetime.util.concurrent.hashmap.TraceBuffer; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.flow.IFlowRecord; - -public class TraceReconstructionAnalysis { - - private final List<TraceEventRecords> elementCollection = new LinkedList<TraceEventRecords>(); - - private Thread clockThread; - private Thread workerThread; - - private ClassNameRegistryRepository classNameRegistryRepository; - private final ConcurrentHashMapWithDefault<Long, TraceBuffer> traceId2trace = new ConcurrentHashMapWithDefault<Long, TraceBuffer>(new TraceBuffer()); - - private Counter<IMonitoringRecord> recordCounter; - private Counter<TraceEventRecords> traceCounter; - private ElementThroughputMeasuringStage<IFlowRecord> throughputFilter; - - private File inputDir; - - public void init() { - Clock clockStage = this.buildClockPipeline(); - this.clockThread = new Thread(new RunnableStage(clockStage)); - - HeadPipeline<?, ?> pipeline = this.buildPipeline(clockStage); - this.workerThread = new Thread(new RunnableStage(pipeline)); - } - - private Clock buildClockPipeline() { - Clock clock = new Clock(); - clock.setIntervalDelayInMs(100); - - return clock; - } - - private HeadPipeline<?, ?> buildPipeline(final Clock clockStage) { - this.classNameRegistryRepository = new ClassNameRegistryRepository(); - - // create stages - InitialElementProducer<File> initialElementProducer = new InitialElementProducer<File>(this.inputDir); - final Dir2RecordsFilter dir2RecordsFilter = new Dir2RecordsFilter(this.classNameRegistryRepository); - this.recordCounter = new Counter<IMonitoringRecord>(); - final Cache<IMonitoringRecord> cache = new Cache<IMonitoringRecord>(); - - final StringBufferFilter<IMonitoringRecord> stringBufferFilter = new StringBufferFilter<IMonitoringRecord>(); - final InstanceOfFilter<IMonitoringRecord, IFlowRecord> instanceOfFilter = new InstanceOfFilter<IMonitoringRecord, IFlowRecord>( - IFlowRecord.class); - this.throughputFilter = new ElementThroughputMeasuringStage<IFlowRecord>(); - final TraceReconstructionFilter traceReconstructionFilter = new TraceReconstructionFilter(this.traceId2trace); - Merger<TraceEventRecords> merger = new Merger<TraceEventRecords>(); - this.traceCounter = new Counter<TraceEventRecords>(); - final CollectorSink<TraceEventRecords> collector = new CollectorSink<TraceEventRecords>(this.elementCollection); - - // configure stages - stringBufferFilter.getDataTypeHandlers().add(new IMonitoringRecordHandler()); - stringBufferFilter.getDataTypeHandlers().add(new StringHandler()); - - // connect stages - SingleElementPipe.connect(initialElementProducer.getOutputPort(), dir2RecordsFilter.getInputPort()); - SingleElementPipe.connect(dir2RecordsFilter.getOutputPort(), this.recordCounter.getInputPort()); - SingleElementPipe.connect(this.recordCounter.getOutputPort(), cache.getInputPort()); - SingleElementPipe.connect(cache.getOutputPort(), stringBufferFilter.getInputPort()); - SingleElementPipe.connect(stringBufferFilter.getOutputPort(), instanceOfFilter.getInputPort()); - SingleElementPipe.connect(instanceOfFilter.getOutputPort(), this.throughputFilter.getInputPort()); - SingleElementPipe.connect(this.throughputFilter.getOutputPort(), traceReconstructionFilter.getInputPort()); - // SingleElementPipe.connect(instanceOfFilter.getOutputPort(), traceReconstructionFilter.getInputPort()); - SingleElementPipe.connect(traceReconstructionFilter.getTraceValidOutputPort(), merger.getNewInputPort()); - SingleElementPipe.connect(traceReconstructionFilter.getTraceInvalidOutputPort(), merger.getNewInputPort()); - SingleElementPipe.connect(merger.getOutputPort(), this.traceCounter.getInputPort()); - SingleElementPipe.connect(this.traceCounter.getOutputPort(), collector.getInputPort()); - - SpScPipe.connect(clockStage.getOutputPort(), this.throughputFilter.getTriggerInputPort(), 1); - - // create and configure pipeline - HeadPipeline<InitialElementProducer<File>, CollectorSink<TraceEventRecords>> pipeline = new HeadPipeline<InitialElementProducer<File>, CollectorSink<TraceEventRecords>>(); - pipeline.setFirstStage(initialElementProducer); - pipeline.setLastStage(collector); - return pipeline; - } - - public void start() { - - this.clockThread.start(); - this.workerThread.start(); - - try { - this.workerThread.join(); - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - - this.clockThread.interrupt(); - try { - this.clockThread.join(); - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - } - - public List<TraceEventRecords> getElementCollection() { - return this.elementCollection; - } - - public int getNumRecords() { - return this.recordCounter.getNumElementsPassed(); - } - - public int getNumTraces() { - return this.traceCounter.getNumElementsPassed(); - } - - public List<Long> getThroughputs() { - return this.throughputFilter.getThroughputs(); - } - - public File getInputDir() { - return this.inputDir; - } - - public void setInputDir(final File inputDir) { - this.inputDir = inputDir; - } -} diff --git a/src/performancetest/java/teetime/examples/traceReconstructionWithThreads/ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest.java b/src/performancetest/java/teetime/examples/traceReconstructionWithThreads/ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest.java deleted file mode 100644 index 5e3af5a5935d97cb2dd7e6ea0dfd37712327b1ba..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstructionWithThreads/ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -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.assertThat; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import teetime.framework.Analysis; -import teetime.framework.pipe.SpScPipe; -import teetime.util.ListUtil; -import teetime.util.StopWatch; -import util.test.StatisticsUtil; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest { - - private static final int MIO = 1000000; - private static final int EXPECTED_NUM_TRACES = 10 * MIO; - private static final int EXPECTED_NUM_RECORDS = 21 * EXPECTED_NUM_TRACES + 1; - - private StopWatch stopWatch; - - @Before - public void before() { - this.stopWatch = new StopWatch(); - } - - @After - public void after() { - long overallDurationInNs = this.stopWatch.getDurationInNs(); - System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(overallDurationInNs) + " ms"); - } - - @Test - public void performAnalysisWith1Thread() { - this.performAnalysis(1); - } - - @Test - public void performAnalysisWith2Threads() { - this.performAnalysis(2); - } - - @Test - public void performAnalysisWith4Threads() { - this.performAnalysis(4); - } - - void performAnalysis(final int numWorkerThreads) { - final TcpTraceReconstructionAnalysisWithThreadsConfiguration configuration = new TcpTraceReconstructionAnalysisWithThreadsConfiguration(); - configuration.setNumWorkerThreads(numWorkerThreads); - configuration.buildConfiguration(); - - Analysis analysis = new Analysis(configuration); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - int maxNumWaits = 0; - for (SpScPipe pipe : configuration.getTcpRelayPipes()) { - maxNumWaits = Math.max(maxNumWaits, pipe.getNumWaits()); - } - System.out.println("max #waits of TcpRelayPipes: " + maxNumWaits); - - // System.out.println("#traceMetadata read: " + analysis.getNumTraceMetadatas()); - // System.out.println("Max #trace created: " + analysis.getMaxElementsCreated()); - - // Map<Double, Long> recordQuintiles = StatisticsUtil.calculateQuintiles(analysis.getRecordDelays()); - // System.out.println("Median record delay: " + recordQuintiles.get(0.5) + " time units/record"); - - // Map<Double, Long> traceQuintiles = StatisticsUtil.calculateQuintiles(analysis.getTraceDelays()); - // System.out.println("Median trace delay: " + traceQuintiles.get(0.5) + " time units/trace"); - - List<Long> recordThroughputs = ListUtil.removeFirstHalfElements(configuration.getRecordThroughputs()); - Map<Double, Long> recordQuintiles = StatisticsUtil.calculateQuintiles(recordThroughputs); - System.out.println("Median record throughput: " + recordQuintiles.get(0.5) + " elements/time unit"); - - // List<Long> traceThroughputs = ListUtil.removeFirstHalfElements(analysis.getTraceThroughputs()); - // Map<Double, Long> traceQuintiles = StatisticsUtil.calculateQuintiles(traceThroughputs); - // System.out.println("Median trace throughput: " + traceQuintiles.get(0.5) + " traces/time unit"); - - // TraceEventRecords trace6884 = analysis.getElementCollection().get(0); - // assertEquals(6884, trace6884.getTraceMetadata().getTraceId()); - // - // TraceEventRecords trace6886 = analysis.getElementCollection().get(1); - // assertEquals(6886, trace6886.getTraceMetadata().getTraceId()); - - assertEquals("#records", EXPECTED_NUM_RECORDS, configuration.getNumRecords()); - assertEquals("#traces", EXPECTED_NUM_TRACES, configuration.getNumTraces()); - - for (Integer count : configuration.getNumTraceMetadatas()) { - assertEquals("#traceMetadata per worker thread", EXPECTED_NUM_TRACES / numWorkerThreads, count.intValue()); // even distribution - } - - // 08.07.2014 (incl.) - assertThat(recordQuintiles.get(0.5), is(both(greaterThan(3100L)).and(lessThan(3500L)))); - } - - public static void main(final String[] args) { - ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest analysis = new ChwHomeTcpTraceReconstructionAnalysisWithThreadsTest(); - analysis.before(); - try { - analysis.performAnalysisWith1Thread(); - } catch (Exception e) { - System.err.println(e); - } - analysis.after(); - - analysis.before(); - try { - analysis.performAnalysisWith2Threads(); - } catch (Exception e) { - System.err.println(e); - } - analysis.after(); - - analysis.before(); - try { - analysis.performAnalysisWith4Threads(); - } catch (Exception e) { - System.err.println(e); - } - analysis.after(); - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReconstructionWithThreads/ChwWorkTcpTraceReconstructionAnalysisWithThreadsTest.java b/src/performancetest/java/teetime/examples/traceReconstructionWithThreads/ChwWorkTcpTraceReconstructionAnalysisWithThreadsTest.java deleted file mode 100644 index 3082beaf4fc092e57df7728ec4c9c55ab0fce79f..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstructionWithThreads/ChwWorkTcpTraceReconstructionAnalysisWithThreadsTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.examples.traceReconstructionWithThreads; - -import static org.junit.Assert.assertEquals; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import teetime.framework.Analysis; -import teetime.framework.pipe.SpScPipe; -import teetime.util.ListUtil; -import teetime.util.StopWatch; -import util.test.StatisticsUtil; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ChwWorkTcpTraceReconstructionAnalysisWithThreadsTest { - - private static final int MIO = 1000000; - private static final int EXPECTED_NUM_TRACES = 1 * MIO; - - private StopWatch stopWatch; - - @Before - public void before() { - this.stopWatch = new StopWatch(); - } - - @After - public void after() { - long overallDurationInNs = this.stopWatch.getDurationInNs(); - System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(overallDurationInNs) + " ms"); - } - - @Test - public void performAnalysisWith1Thread() { - this.performAnalysis(1); - } - - @Test - public void performAnalysisWith2Threads() { - this.performAnalysis(2); - } - - @Test - public void performAnalysisWith4Threads() { - this.performAnalysis(4); - } - - // until 04.07.2014 (incl.) - // Max size of tcp-relay pipe: 143560 - // Median trace throughput: 115 traces/time unit - // Duration: 12907 ms - - // Max size of tcp-relay pipe: 51948 - // Median trace throughput: 42 traces/time unit - // Duration: 21614 ms - - // [2014-07-04 01:06:10 PM] WARNUNG: Reader interrupted (teetime.stage.io.TCPReader$TCPStringReader run) - // Max size of tcp-relay pipe: 167758 - // Median trace throughput: 6 traces/time unit - // Duration: 22373 ms - - void performAnalysis(final int numWorkerThreads) { - final TcpTraceReconstructionAnalysisWithThreadsConfiguration configuration = new TcpTraceReconstructionAnalysisWithThreadsConfiguration(); - configuration.setNumWorkerThreads(numWorkerThreads); - configuration.buildConfiguration(); - - Analysis analysis = new Analysis(configuration); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - int maxNumWaits = 0; - for (SpScPipe pipe : configuration.getTcpRelayPipes()) { - maxNumWaits = Math.max(maxNumWaits, pipe.getNumWaits()); - } - System.out.println("max #waits of TcpRelayPipes: " + maxNumWaits); - - // System.out.println("#traceMetadata read: " + analysis.getNumTraceMetadatas()); - // System.out.println("Max #trace created: " + analysis.getMaxElementsCreated()); - - // Map<Double, Long> recordQuintiles = StatisticsUtil.calculateQuintiles(analysis.getRecordDelays()); - // System.out.println("Median record delay: " + recordQuintiles.get(0.5) + " time units/record"); - - // Map<Double, Long> traceQuintiles = StatisticsUtil.calculateQuintiles(analysis.getTraceDelays()); - // System.out.println("Median trace delay: " + traceQuintiles.get(0.5) + " time units/trace"); - - List<Long> traceThroughputs = ListUtil.removeFirstHalfElements(configuration.getTraceThroughputs()); - Map<Double, Long> traceQuintiles = StatisticsUtil.calculateQuintiles(traceThroughputs); - System.out.println("Median trace throughput: " + traceQuintiles.get(0.5) + " traces/time unit"); - - // TraceEventRecords trace6884 = analysis.getElementCollection().get(0); - // assertEquals(6884, trace6884.getTraceMetadata().getTraceId()); - // - // TraceEventRecords trace6886 = analysis.getElementCollection().get(1); - // assertEquals(6886, trace6886.getTraceMetadata().getTraceId()); - - assertEquals("#records", 21000001, configuration.getNumRecords()); - - for (Integer count : configuration.getNumTraceMetadatas()) { - assertEquals("#traceMetadata per worker thread", EXPECTED_NUM_TRACES / numWorkerThreads, count.intValue()); // even distribution - } - - assertEquals("#traces", EXPECTED_NUM_TRACES, configuration.getNumTraces()); - } - - public static void main(final String[] args) { - ChwWorkTcpTraceReconstructionAnalysisWithThreadsTest analysis = new ChwWorkTcpTraceReconstructionAnalysisWithThreadsTest(); - analysis.before(); - try { - analysis.performAnalysisWith1Thread(); - } catch (Exception e) { - System.err.println(e); - } - analysis.after(); - - analysis.before(); - try { - analysis.performAnalysisWith2Threads(); - } catch (Exception e) { - System.err.println(e); - } - analysis.after(); - - analysis.before(); - try { - analysis.performAnalysisWith4Threads(); - } catch (Exception e) { - System.err.println(e); - } - analysis.after(); - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReconstructionWithThreads/TcpTraceReconstructionAnalysisWithThreadsConfiguration.java b/src/performancetest/java/teetime/examples/traceReconstructionWithThreads/TcpTraceReconstructionAnalysisWithThreadsConfiguration.java deleted file mode 100644 index bddeaf9a7c1758e1810f2bb6ad6f35cbbee3bae7..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReconstructionWithThreads/TcpTraceReconstructionAnalysisWithThreadsConfiguration.java +++ /dev/null @@ -1,263 +0,0 @@ -package teetime.examples.traceReconstructionWithThreads; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import teetime.framework.AnalysisConfiguration; -import teetime.framework.HeadPipeline; -import teetime.framework.Stage; -import teetime.framework.pipe.SingleElementPipe; -import teetime.framework.pipe.SpScPipe; -import teetime.stage.Clock; -import teetime.stage.Counter; -import teetime.stage.ElementDelayMeasuringStage; -import teetime.stage.ElementThroughputMeasuringStage; -import teetime.stage.InstanceCounter; -import teetime.stage.InstanceOfFilter; -import teetime.stage.Relay; -import teetime.stage.basic.Sink; -import teetime.stage.basic.distributor.Distributor; -import teetime.stage.io.TCPReader; -import teetime.stage.kieker.traceReconstruction.TraceReconstructionFilter; -import teetime.util.concurrent.hashmap.ConcurrentHashMapWithDefault; -import teetime.util.concurrent.hashmap.TraceBuffer; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.flow.IFlowRecord; -import kieker.common.record.flow.trace.TraceMetadata; - -public class TcpTraceReconstructionAnalysisWithThreadsConfiguration extends AnalysisConfiguration { - - private static final int NUM_VIRTUAL_CORES = Runtime.getRuntime().availableProcessors(); - private static final int MIO = 1000000; - private static final int TCP_RELAY_MAX_SIZE = 2 * MIO; - - private final List<TraceEventRecords> elementCollection = new LinkedList<TraceEventRecords>(); - - private int numWorkerThreads; - - private final ConcurrentHashMapWithDefault<Long, TraceBuffer> traceId2trace = new ConcurrentHashMapWithDefault<Long, TraceBuffer>(new TraceBuffer()); - - private final StageFactory<Counter<IMonitoringRecord>> recordCounterFactory; - private final StageFactory<ElementDelayMeasuringStage<IMonitoringRecord>> recordDelayFilterFactory; - private final StageFactory<ElementThroughputMeasuringStage<IMonitoringRecord>> recordThroughputFilterFactory; - private final StageFactory<InstanceCounter<IMonitoringRecord, TraceMetadata>> traceMetadataCounterFactory; - private final StageFactory<TraceReconstructionFilter> traceReconstructionFilterFactory; - private final StageFactory<Counter<TraceEventRecords>> traceCounterFactory; - private final StageFactory<ElementThroughputMeasuringStage<TraceEventRecords>> traceThroughputFilterFactory; - - private final List<SpScPipe> tcpRelayPipes = new LinkedList<SpScPipe>(); - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public TcpTraceReconstructionAnalysisWithThreadsConfiguration() { - super(); - - try { - this.recordCounterFactory = new StageFactory(Counter.class.getConstructor()); - this.recordDelayFilterFactory = new StageFactory(ElementDelayMeasuringStage.class.getConstructor()); - this.recordThroughputFilterFactory = new StageFactory(ElementThroughputMeasuringStage.class.getConstructor()); - this.traceMetadataCounterFactory = new StageFactory(InstanceCounter.class.getConstructor(Class.class)); - this.traceReconstructionFilterFactory = new StageFactory(TraceReconstructionFilter.class.getConstructor(ConcurrentHashMapWithDefault.class)); - this.traceCounterFactory = new StageFactory(Counter.class.getConstructor()); - this.traceThroughputFilterFactory = new StageFactory(ElementThroughputMeasuringStage.class.getConstructor()); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException(e); - } catch (SecurityException e) { - throw new IllegalArgumentException(e); - } - } - - public void buildConfiguration() { - final HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> tcpPipeline = this.buildTcpPipeline(); - this.getFiniteProducerStages().add(tcpPipeline); - - final HeadPipeline<Clock, Distributor<Long>> clockStage = this.buildClockPipeline(1000); - this.getInfiniteProducerStages().add(clockStage); - - final HeadPipeline<Clock, Distributor<Long>> clock2Stage = this.buildClockPipeline(2000); - this.getInfiniteProducerStages().add(clock2Stage); - - this.numWorkerThreads = Math.min(NUM_VIRTUAL_CORES, this.numWorkerThreads); - for (int i = 0; i < this.numWorkerThreads; i++) { - HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>> pipeline = this.buildPipeline(tcpPipeline.getLastStage(), clockStage.getLastStage(), - clock2Stage.getLastStage()); - this.getConsumerStages().add(pipeline); - } - } - - private HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> buildTcpPipeline() { - TCPReader tcpReader = new TCPReader(); - Distributor<IMonitoringRecord> distributor = new Distributor<IMonitoringRecord>(); - - SingleElementPipe.connect(tcpReader.getOutputPort(), distributor.getInputPort()); - - // create and configure pipeline - HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> pipeline = new HeadPipeline<TCPReader, Distributor<IMonitoringRecord>>("TCP reader pipeline"); - pipeline.setFirstStage(tcpReader); - pipeline.setLastStage(distributor); - return pipeline; - } - - private HeadPipeline<Clock, Distributor<Long>> buildClockPipeline(final long intervalDelayInMs) { - Clock clock = new Clock(); - clock.setInitialDelayInMs(intervalDelayInMs); - clock.setIntervalDelayInMs(intervalDelayInMs); - Distributor<Long> distributor = new Distributor<Long>(); - - SingleElementPipe.connect(clock.getOutputPort(), distributor.getInputPort()); - - // create and configure pipeline - HeadPipeline<Clock, Distributor<Long>> pipeline = new HeadPipeline<Clock, Distributor<Long>>(); - pipeline.setFirstStage(clock); - pipeline.setLastStage(distributor); - return pipeline; - } - - private static class StageFactory<T extends Stage> { - - private final Constructor<T> constructor; - private final List<T> stages = new ArrayList<T>(); - - public StageFactory(final Constructor<T> constructor) { - this.constructor = constructor; - } - - public T create(final Object... initargs) { - try { - T stage = this.constructor.newInstance(initargs); - this.stages.add(stage); - return stage; - } catch (InstantiationException e) { - throw new IllegalStateException(e); - } catch (IllegalAccessException e) { - throw new IllegalStateException(e); - } catch (IllegalArgumentException e) { - throw new IllegalStateException(e); - } catch (InvocationTargetException e) { - throw new IllegalStateException(e); - } - } - - public List<T> getStages() { - return this.stages; - } - } - - private HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>> buildPipeline(final Distributor<IMonitoringRecord> tcpReaderPipeline, - final Distributor<Long> clockStage, final Distributor<Long> clock2Stage) { - // create stages - Relay<IMonitoringRecord> relay = new Relay<IMonitoringRecord>(); - Counter<IMonitoringRecord> recordCounter = this.recordCounterFactory.create(); - ElementThroughputMeasuringStage<IMonitoringRecord> recordThroughputFilter = this.recordThroughputFilterFactory.create(); - // ElementDelayMeasuringStage<IMonitoringRecord> recordThroughputFilter = this.recordDelayFilterFactory.create(); - InstanceCounter<IMonitoringRecord, TraceMetadata> traceMetadataCounter = this.traceMetadataCounterFactory.create(TraceMetadata.class); - new InstanceCounter<IMonitoringRecord, TraceMetadata>(TraceMetadata.class); - final InstanceOfFilter<IMonitoringRecord, IFlowRecord> instanceOfFilter = new InstanceOfFilter<IMonitoringRecord, IFlowRecord>( - IFlowRecord.class); - final TraceReconstructionFilter traceReconstructionFilter = this.traceReconstructionFilterFactory.create(this.traceId2trace); - Counter<TraceEventRecords> traceCounter = this.traceCounterFactory.create(); - ElementThroughputMeasuringStage<TraceEventRecords> traceThroughputFilter = this.traceThroughputFilterFactory.create(); - Sink<TraceEventRecords> endStage = new Sink<TraceEventRecords>(); - // EndStage<IMonitoringRecord> endStage = new EndStage<IMonitoringRecord>(); - - // connect stages - SpScPipe tcpRelayPipe = SpScPipe.connect(tcpReaderPipeline.getNewOutputPort(), relay.getInputPort(), TCP_RELAY_MAX_SIZE); - this.tcpRelayPipes.add(tcpRelayPipe); - // SysOutFilter<TraceEventRecords> sysout = new SysOutFilter<TraceEventRecords>(tcpRelayPipe); - - SpScPipe.connect(clockStage.getNewOutputPort(), recordThroughputFilter.getTriggerInputPort(), 10); - SpScPipe.connect(clock2Stage.getNewOutputPort(), traceThroughputFilter.getTriggerInputPort(), 10); - - SingleElementPipe.connect(relay.getOutputPort(), recordCounter.getInputPort()); - SingleElementPipe.connect(recordCounter.getOutputPort(), recordThroughputFilter.getInputPort()); - SingleElementPipe.connect(recordThroughputFilter.getOutputPort(), traceMetadataCounter.getInputPort()); - SingleElementPipe.connect(traceMetadataCounter.getOutputPort(), instanceOfFilter.getInputPort()); - SingleElementPipe.connect(instanceOfFilter.getOutputPort(), traceReconstructionFilter.getInputPort()); - SingleElementPipe.connect(traceReconstructionFilter.getTraceValidOutputPort(), traceCounter.getInputPort()); - // SingleElementPipe.connect(traceReconstructionFilter.getOutputPort(), traceThroughputFilter.getInputPort()); - // SingleElementPipe.connect(traceThroughputFilter.getOutputPort(), traceCounter.getInputPort()); - SingleElementPipe.connect(traceCounter.getOutputPort(), endStage.getInputPort()); - - // create and configure pipeline - HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>> pipeline = new HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>>( - "Worker pipeline"); - pipeline.setFirstStage(relay); - // pipeline.addIntermediateStage(sysout); - pipeline.setLastStage(endStage); - - return pipeline; - } - - public List<TraceEventRecords> getElementCollection() { - return this.elementCollection; - } - - public int getNumRecords() { - int sum = 0; - for (Counter<IMonitoringRecord> stage : this.recordCounterFactory.getStages()) { - sum += stage.getNumElementsPassed(); - } - return sum; - } - - public int getNumTraces() { - int sum = 0; - for (Counter<TraceEventRecords> stage : this.traceCounterFactory.getStages()) { - sum += stage.getNumElementsPassed(); - } - return sum; - } - - public List<Long> getRecordDelays() { - List<Long> throughputs = new LinkedList<Long>(); - for (ElementDelayMeasuringStage<IMonitoringRecord> stage : this.recordDelayFilterFactory.getStages()) { - throughputs.addAll(stage.getDelays()); - } - return throughputs; - } - - public List<Long> getRecordThroughputs() { - List<Long> throughputs = new LinkedList<Long>(); - for (ElementThroughputMeasuringStage<IMonitoringRecord> stage : this.recordThroughputFilterFactory.getStages()) { - throughputs.addAll(stage.getThroughputs()); - } - return throughputs; - } - - public List<Long> getTraceThroughputs() { - List<Long> throughputs = new LinkedList<Long>(); - for (ElementThroughputMeasuringStage<TraceEventRecords> stage : this.traceThroughputFilterFactory.getStages()) { - throughputs.addAll(stage.getThroughputs()); - } - return throughputs; - } - - public List<Integer> getNumTraceMetadatas() { - List<Integer> numTraceMetadatas = new LinkedList<Integer>(); - for (InstanceCounter<IMonitoringRecord, TraceMetadata> stage : this.traceMetadataCounterFactory.getStages()) { - numTraceMetadatas.add(stage.getCounter()); - } - return numTraceMetadatas; - } - - public List<SpScPipe> getTcpRelayPipes() { - return this.tcpRelayPipes; - } - - public int getNumWorkerThreads() { - return this.numWorkerThreads; - } - - public void setNumWorkerThreads(final int numWorkerThreads) { - this.numWorkerThreads = numWorkerThreads; - } - - public int getMaxElementsCreated() { - return this.traceId2trace.getMaxElements(); - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReductionWithThreads/ChwWorkTcpTraceReductionAnalysisWithThreadsTest.java b/src/performancetest/java/teetime/examples/traceReductionWithThreads/ChwWorkTcpTraceReductionAnalysisWithThreadsTest.java deleted file mode 100644 index d7b58674de3cbc73deaac48deef643a4c7d80d2e..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReductionWithThreads/ChwWorkTcpTraceReductionAnalysisWithThreadsTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ -package teetime.examples.traceReductionWithThreads; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import teetime.util.ListUtil; -import teetime.util.StopWatch; -import util.MooBenchStarter; -import util.test.StatisticsUtil; - -/** - * @author Christian Wulf - * - * @since 1.10 - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ChwWorkTcpTraceReductionAnalysisWithThreadsTest { - - private static final int EXPECTED_NUM_TRACES = 1000000; - private static final int EXPECTED_NUM_SAME_TRACES = 1; - - private static MooBenchStarter mooBenchStarter; - - private StopWatch stopWatch; - - @BeforeClass - public static void beforeClass() { - mooBenchStarter = new MooBenchStarter(); - } - - @Before - public void before() { - this.stopWatch = new StopWatch(); - } - - @After - public void after() { - long overallDurationInNs = this.stopWatch.getDurationInNs(); - System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(overallDurationInNs) + " ms"); - } - - @Test - public void performAnalysisWith1Thread() throws InterruptedException, IOException { - Runnable runnable = new Runnable() { - @Override - public void run() { - ChwWorkTcpTraceReductionAnalysisWithThreadsTest.this.performAnalysis(1); - } - }; - this.startTest(runnable); - } - - @Test - public void performAnalysisWith2Threads() throws InterruptedException, IOException { - Runnable runnable = new Runnable() { - @Override - public void run() { - ChwWorkTcpTraceReductionAnalysisWithThreadsTest.this.performAnalysis(2); - } - }; - this.startTest(runnable); - } - - @Test - public void performAnalysisWith4Threads() throws InterruptedException, IOException { - Runnable runnable = new Runnable() { - @Override - public void run() { - ChwWorkTcpTraceReductionAnalysisWithThreadsTest.this.performAnalysis(4); - } - }; - this.startTest(runnable); - } - - void performAnalysis(final int numWorkerThreads) { - final TcpTraceReductionAnalysisWithThreads analysis = new TcpTraceReductionAnalysisWithThreads(); - analysis.setNumWorkerThreads(numWorkerThreads); - analysis.init(); - - this.stopWatch.start(); - try { - analysis.start(); - } finally { - this.stopWatch.end(); - } - - System.out.println("#waits of tcp-relay pipe: " + analysis.getTcpRelayPipe().getNumWaits()); - // System.out.println("#traceMetadata read: " + analysis.getNumTraceMetadatas()); - // System.out.println("Max #trace created: " + analysis.getMaxElementsCreated()); - System.out.println("TraceThroughputs: " + analysis.getTraceThroughputs()); - - // Map<Double, Long> recordQuintiles = StatisticsUtil.calculateQuintiles(analysis.getRecordDelays()); - // System.out.println("Median record delay: " + recordQuintiles.get(0.5) + " time units/record"); - - // Map<Double, Long> traceQuintiles = StatisticsUtil.calculateQuintiles(analysis.getTraceDelays()); - // System.out.println("Median trace delay: " + traceQuintiles.get(0.5) + " time units/trace"); - - List<Long> traceThroughputs = ListUtil.removeFirstHalfElements(analysis.getTraceThroughputs()); - Map<Double, Long> traceQuintiles = StatisticsUtil.calculateQuintiles(traceThroughputs); - System.out.println("Median trace throughput: " + traceQuintiles.get(0.5) + " traces/time unit"); - - assertEquals("#records", 21000001, analysis.getNumRecords()); - - for (Integer count : analysis.getNumTraceMetadatas()) { - assertEquals("#traceMetadata per worker thread", EXPECTED_NUM_TRACES / numWorkerThreads, count.intValue()); // even distribution - } - - assertEquals("#traces", EXPECTED_NUM_SAME_TRACES, analysis.getNumTraces()); - } - - private void startTest(final Runnable runnable) throws InterruptedException, IOException { - Thread thread = new Thread(runnable); - thread.start(); - - Thread.sleep(1000); - - mooBenchStarter.start(1, EXPECTED_NUM_TRACES); - - thread.join(); - } - - public static void main(final String[] args) { - ChwWorkTcpTraceReductionAnalysisWithThreadsTest analysis = new ChwWorkTcpTraceReductionAnalysisWithThreadsTest(); - analysis.before(); - try { - analysis.performAnalysisWith1Thread(); - } catch (Exception e) { - System.err.println(e); - } - analysis.after(); - - analysis.before(); - try { - analysis.performAnalysisWith2Threads(); - } catch (Exception e) { - System.err.println(e); - } - analysis.after(); - - analysis.before(); - try { - analysis.performAnalysisWith4Threads(); - } catch (Exception e) { - System.err.println(e); - } - analysis.after(); - } - -} diff --git a/src/performancetest/java/teetime/examples/traceReductionWithThreads/TcpTraceReductionAnalysisWithThreads.java b/src/performancetest/java/teetime/examples/traceReductionWithThreads/TcpTraceReductionAnalysisWithThreads.java deleted file mode 100644 index f1b4e5df4f2f5fc01a8d6412a7e7b917878c7dd8..0000000000000000000000000000000000000000 --- a/src/performancetest/java/teetime/examples/traceReductionWithThreads/TcpTraceReductionAnalysisWithThreads.java +++ /dev/null @@ -1,276 +0,0 @@ -package teetime.examples.traceReductionWithThreads; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import teetime.framework.HeadPipeline; -import teetime.framework.RunnableStage; -import teetime.framework.Stage; -import teetime.framework.pipe.SingleElementPipe; -import teetime.framework.pipe.SpScPipe; -import teetime.stage.Clock; -import teetime.stage.Counter; -import teetime.stage.ElementDelayMeasuringStage; -import teetime.stage.ElementThroughputMeasuringStage; -import teetime.stage.InstanceCounter; -import teetime.stage.InstanceOfFilter; -import teetime.stage.Relay; -import teetime.stage.basic.Sink; -import teetime.stage.basic.distributor.Distributor; -import teetime.stage.io.TCPReader; -import teetime.stage.kieker.traceReconstruction.TraceReconstructionFilter; -import teetime.stage.kieker.traceReduction.TraceAggregationBuffer; -import teetime.stage.kieker.traceReduction.TraceComperator; -import teetime.stage.kieker.traceReduction.TraceReductionFilter; -import teetime.util.concurrent.hashmap.ConcurrentHashMapWithDefault; -import teetime.util.concurrent.hashmap.TraceBuffer; - -import kieker.analysis.plugin.filter.flow.TraceEventRecords; -import kieker.common.record.IMonitoringRecord; -import kieker.common.record.flow.IFlowRecord; -import kieker.common.record.flow.trace.TraceMetadata; - -public class TcpTraceReductionAnalysisWithThreads { - - private static final int NUM_VIRTUAL_CORES = Runtime.getRuntime().availableProcessors(); - private static final int MIO = 1000000; - private static final int TCP_RELAY_MAX_SIZE = (int) (0.5 * MIO); - - private final List<TraceEventRecords> elementCollection = new LinkedList<TraceEventRecords>(); - - private Thread tcpThread; - private Thread clockThread; - private Thread clock2Thread; - private Thread[] workerThreads; - - private SpScPipe tcpRelayPipe; - private int numWorkerThreads; - - public void init() { - HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> tcpPipeline = this.buildTcpPipeline(); - this.tcpThread = new Thread(new RunnableStage(tcpPipeline)); - - HeadPipeline<Clock, Distributor<Long>> clockStage = this.buildClockPipeline(1000); - this.clockThread = new Thread(new RunnableStage(clockStage)); - - HeadPipeline<Clock, Distributor<Long>> clock2Stage = this.buildClockPipeline(5000); - this.clock2Thread = new Thread(new RunnableStage(clock2Stage)); - - this.numWorkerThreads = Math.min(NUM_VIRTUAL_CORES, this.numWorkerThreads); - this.workerThreads = new Thread[this.numWorkerThreads]; - - for (int i = 0; i < this.workerThreads.length; i++) { - HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>> pipeline = this.buildPipeline(tcpPipeline, clockStage, clock2Stage); - this.workerThreads[i] = new Thread(new RunnableStage(pipeline)); - } - } - - private HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> buildTcpPipeline() { - TCPReader tcpReader = new TCPReader(); - Distributor<IMonitoringRecord> distributor = new Distributor<IMonitoringRecord>(); - - SingleElementPipe.connect(tcpReader.getOutputPort(), distributor.getInputPort()); - - // create and configure pipeline - HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> pipeline = new HeadPipeline<TCPReader, Distributor<IMonitoringRecord>>(); - pipeline.setFirstStage(tcpReader); - pipeline.setLastStage(distributor); - return pipeline; - } - - private HeadPipeline<Clock, Distributor<Long>> buildClockPipeline(final long intervalDelayInMs) { - Clock clock = new Clock(); - clock.setInitialDelayInMs(intervalDelayInMs); - clock.setIntervalDelayInMs(intervalDelayInMs); - Distributor<Long> distributor = new Distributor<Long>(); - - SingleElementPipe.connect(clock.getOutputPort(), distributor.getInputPort()); - - // create and configure pipeline - HeadPipeline<Clock, Distributor<Long>> pipeline = new HeadPipeline<Clock, Distributor<Long>>(); - pipeline.setFirstStage(clock); - pipeline.setLastStage(distributor); - return pipeline; - } - - private static class StageFactory<T extends Stage> { - - private final Constructor<T> constructor; - private final List<T> stages = new ArrayList<T>(); - - public StageFactory(final Constructor<T> constructor) { - this.constructor = constructor; - } - - public T create(final Object... initargs) { - try { - T stage = this.constructor.newInstance(initargs); - this.stages.add(stage); - return stage; - } catch (InstantiationException e) { - throw new IllegalStateException(e); - } catch (IllegalAccessException e) { - throw new IllegalStateException(e); - } catch (IllegalArgumentException e) { - throw new IllegalStateException(e); - } catch (InvocationTargetException e) { - throw new IllegalStateException(e); - } - } - - public List<T> getStages() { - return this.stages; - } - } - - private final ConcurrentHashMapWithDefault<Long, TraceBuffer> traceId2trace = new ConcurrentHashMapWithDefault<Long, TraceBuffer>(new TraceBuffer()); - private final Map<TraceEventRecords, TraceAggregationBuffer> trace2buffer = new TreeMap<TraceEventRecords, TraceAggregationBuffer>(new TraceComperator()); - - private final StageFactory<Counter<IMonitoringRecord>> recordCounterFactory; - private final StageFactory<ElementDelayMeasuringStage<IMonitoringRecord>> recordThroughputFilterFactory; - private final StageFactory<InstanceCounter<IMonitoringRecord, TraceMetadata>> traceMetadataCounterFactory; - private final StageFactory<Counter<TraceEventRecords>> traceCounterFactory; - private final StageFactory<ElementThroughputMeasuringStage<TraceEventRecords>> traceThroughputFilterFactory; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public TcpTraceReductionAnalysisWithThreads() { - try { - this.recordCounterFactory = new StageFactory(Counter.class.getConstructor()); - this.recordThroughputFilterFactory = new StageFactory(ElementDelayMeasuringStage.class.getConstructor()); - this.traceMetadataCounterFactory = new StageFactory(InstanceCounter.class.getConstructor(Class.class)); - this.traceCounterFactory = new StageFactory(Counter.class.getConstructor()); - this.traceThroughputFilterFactory = new StageFactory(ElementThroughputMeasuringStage.class.getConstructor()); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException(e); - } catch (SecurityException e) { - throw new IllegalArgumentException(e); - } - } - - private HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>> buildPipeline( - final HeadPipeline<TCPReader, Distributor<IMonitoringRecord>> tcpReaderPipeline, - final HeadPipeline<Clock, Distributor<Long>> clockStage, - final HeadPipeline<Clock, Distributor<Long>> clock2Stage) { - // create stages - Relay<IMonitoringRecord> relay = new Relay<IMonitoringRecord>(); - Counter<IMonitoringRecord> recordCounter = this.recordCounterFactory.create(); - InstanceCounter<IMonitoringRecord, TraceMetadata> traceMetadataCounter = this.traceMetadataCounterFactory.create(TraceMetadata.class); - final InstanceOfFilter<IMonitoringRecord, IFlowRecord> instanceOfFilter = new InstanceOfFilter<IMonitoringRecord, IFlowRecord>( - IFlowRecord.class); - // ElementDelayMeasuringStage<IMonitoringRecord> recordThroughputFilter = this.recordThroughputFilterFactory.create(); - final TraceReconstructionFilter traceReconstructionFilter = new TraceReconstructionFilter(this.traceId2trace); - TraceReductionFilter traceReductionFilter = new TraceReductionFilter(this.trace2buffer); - Counter<TraceEventRecords> traceCounter = this.traceCounterFactory.create(); - ElementThroughputMeasuringStage<TraceEventRecords> traceThroughputFilter = this.traceThroughputFilterFactory.create(); - Sink<TraceEventRecords> endStage = new Sink<TraceEventRecords>(); - - // connect stages - this.tcpRelayPipe = SpScPipe.connect(tcpReaderPipeline.getLastStage().getNewOutputPort(), relay.getInputPort(), TCP_RELAY_MAX_SIZE); - - SingleElementPipe.connect(relay.getOutputPort(), recordCounter.getInputPort()); - SingleElementPipe.connect(recordCounter.getOutputPort(), traceMetadataCounter.getInputPort()); - SingleElementPipe.connect(traceMetadataCounter.getOutputPort(), instanceOfFilter.getInputPort()); - SingleElementPipe.connect(instanceOfFilter.getOutputPort(), traceReconstructionFilter.getInputPort()); - SingleElementPipe.connect(traceReconstructionFilter.getTraceValidOutputPort(), traceReductionFilter.getInputPort()); - SingleElementPipe.connect(traceReductionFilter.getOutputPort(), traceCounter.getInputPort()); - SingleElementPipe.connect(traceCounter.getOutputPort(), traceThroughputFilter.getInputPort()); - SingleElementPipe.connect(traceThroughputFilter.getOutputPort(), endStage.getInputPort()); - - // SingleElementPipe.connect(traceReconstructionFilter.getOutputPort(), traceThroughputFilter.getInputPort()); - // SingleElementPipe.connect(traceThroughputFilter.getOutputPort(), endStage.getInputPort()); - - SpScPipe.connect(clock2Stage.getLastStage().getNewOutputPort(), traceReductionFilter.getTriggerInputPort(), 10); - SpScPipe.connect(clockStage.getLastStage().getNewOutputPort(), traceThroughputFilter.getTriggerInputPort(), 10); - - // create and configure pipeline - HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>> pipeline = new HeadPipeline<Relay<IMonitoringRecord>, Sink<TraceEventRecords>>(); - pipeline.setFirstStage(relay); - pipeline.setLastStage(endStage); - return pipeline; - } - - public void start() { - - this.tcpThread.start(); - this.clockThread.start(); - // this.clock2Thread.start(); - - for (Thread workerThread : this.workerThreads) { - workerThread.start(); - } - - try { - this.tcpThread.join(); - - for (Thread workerThread : this.workerThreads) { - workerThread.join(); - } - } catch (InterruptedException e) { - throw new IllegalStateException(e); - } - this.clockThread.interrupt(); - this.clock2Thread.interrupt(); - } - - public List<TraceEventRecords> getElementCollection() { - return this.elementCollection; - } - - public int getNumRecords() { - int sum = 0; - for (Counter<IMonitoringRecord> stage : this.recordCounterFactory.getStages()) { - sum += stage.getNumElementsPassed(); - } - return sum; - } - - public int getNumTraces() { - int sum = 0; - for (Counter<TraceEventRecords> stage : this.traceCounterFactory.getStages()) { - sum += stage.getNumElementsPassed(); - } - return sum; - } - - public List<Long> getRecordDelays() { - List<Long> throughputs = new LinkedList<Long>(); - for (ElementDelayMeasuringStage<IMonitoringRecord> stage : this.recordThroughputFilterFactory.getStages()) { - throughputs.addAll(stage.getDelays()); - } - return throughputs; - } - - public List<Long> getTraceThroughputs() { - List<Long> throughputs = new LinkedList<Long>(); - for (ElementThroughputMeasuringStage<TraceEventRecords> stage : this.traceThroughputFilterFactory.getStages()) { - throughputs.addAll(stage.getThroughputs()); - } - return throughputs; - } - - public SpScPipe getTcpRelayPipe() { - return this.tcpRelayPipe; - } - - public int getNumWorkerThreads() { - return this.numWorkerThreads; - } - - public void setNumWorkerThreads(final int numWorkerThreads) { - this.numWorkerThreads = numWorkerThreads; - } - - public List<Integer> getNumTraceMetadatas() { - List<Integer> numTraceMetadatas = new LinkedList<Integer>(); - for (InstanceCounter<IMonitoringRecord, TraceMetadata> stage : this.traceMetadataCounterFactory.getStages()) { - numTraceMetadatas.add(stage.getCounter()); - } - return numTraceMetadatas; - } - -}