removed all files, which are still present in teetime

parent 77a0eec8
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
......@@ -3,13 +3,11 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.sourceforge.teetime</groupId>
<artifactId>teetime</artifactId>
<artifactId>kieker-teetime-stages</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TeeTime</name>
<description>TeeTime is a Pipes-and-Filters framework for Java</description>
<url>http://teetime.sourceforge.org</url>
<licenses>
<license>
......@@ -23,40 +21,6 @@
<java.version>1.6</java.version>
</properties>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<developers>
<developer>
<id>chw</id>
<name>Christian Wulf</name>
<email>chw@informatik.uni-kiel.de</email>
<organization>Christian-Albrechts-Universitaet zu Kiel</organization>
<organizationUrl>http://www.se.informatik.uni-kiel.de/en/team/christian-wulf</organizationUrl>
</developer>
<developer>
<id>ntd</id>
<name>Nelson Tavares de Sousa</name>
<email>ntd@informatik.uni-kiel.de</email>
<organization>Christian-Albrechts-Universitaet zu Kiel</organization>
<organizationUrl>http://www.se.uni-kiel.de/en</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:https://build.se.informatik.uni-kiel.de/gitlab/chw/teetime.git</connection>
<developerConnection>scm:git:ssh://gitlab@build.se.informatik.uni-kiel.de:chw/teetime.git</developerConnection>
<url>https://build.se.informatik.uni-kiel.de/gitlab/chw/teetime/</url>
</scm>
<repositories>
<repository>
<!-- kieker:1.10-SNAPSHOT -->
......@@ -66,6 +30,11 @@
</repositories>
<dependencies>
<dependency>
<groupId>net.sourceforge.teetime</groupId>
<artifactId>teetime</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
......
package teetime.framework;
import teetime.framework.pipe.IPipe;
public abstract class AbstractPort<T> {
protected IPipe pipe;
/**
* The type of this port.
* <p>
* <i>Used to validate the connection between two ports at runtime.</i>
* </p>
*/
protected Class<T> type;
public IPipe getPipe() {
return this.pipe;
}
public void setPipe(final IPipe pipe) {
this.pipe = pipe;
}
public Class<T> getType() {
return this.type;
}
public void setType(final Class<T> type) {
this.type = type;
}
}
package teetime.framework;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import teetime.framework.pipe.DummyPipe;
import teetime.framework.pipe.IPipe;
import teetime.framework.signal.ISignal;
import teetime.framework.validation.InvalidPortConnection;
public abstract class AbstractStage implements Stage {
private final String id;
/**
* A unique logger instance per stage instance
*/
protected final Logger logger;
private Stage parentStage;
private final List<InputPort<?>> inputPortList = new ArrayList<InputPort<?>>();
private final List<OutputPort<?>> outputPortList = new ArrayList<OutputPort<?>>();
/** A cached instance of <code>inputPortList</code> to avoid creating an iterator each time iterating it */
protected InputPort<?>[] cachedInputPorts;
/** A cached instance of <code>outputPortList</code> to avoid creating an iterator each time iterating it */
protected OutputPort<?>[] cachedOutputPorts;
private final Map<ISignal, Void> visited = new HashMap<ISignal, Void>();
public AbstractStage() {
this.id = UUID.randomUUID().toString(); // the id should only be represented by a UUID, not additionally by the class name
this.logger = LoggerFactory.getLogger(this.getClass().getName() + "(" + this.id + ")");
}
/**
* Sends the given <code>element</code> using the default output port
*
* @param element
* @return <code>true</code> iff the given element could be sent, <code>false</code> otherwise (then use a re-try strategy)
*/
protected final <O> boolean send(final OutputPort<O> outputPort, final O element) {
if (!outputPort.send(element)) {
return false;
}
outputPort.reportNewElement();
return true;
// return outputPort.send(element);
}
private void connectUnconnectedOutputPorts() {
for (OutputPort<?> outputPort : this.cachedOutputPorts) {
if (null == outputPort.getPipe()) { // if port is unconnected
this.logger.warn("Unconnected output port: " + outputPort + ". Connecting with a dummy output port.");
outputPort.setPipe(new DummyPipe());
}
}
}
protected InputPort<?>[] getInputPorts() {
return this.cachedInputPorts;
}
protected OutputPort<?>[] getOutputPorts() {
return this.cachedOutputPorts;
}
@Override
public Stage getParentStage() {
return this.parentStage;
}
@Override
public void setParentStage(final Stage parentStage, final int index) {
this.parentStage = parentStage;
}
@Override
public String getId() {
return this.id;
}
/**
* May not be invoked outside of IPipe implementations
*/
@Override
public void onSignal(final ISignal signal, final InputPort<?> inputPort) {
if (!this.alreadyVisited(signal, inputPort)) {
signal.trigger(this);
for (OutputPort<?> outputPort : this.outputPortList) {
outputPort.sendSignal(signal);
}
}
}
protected boolean alreadyVisited(final ISignal signal, final InputPort<?> inputPort) {
if (this.visited.containsKey(signal)) {
this.logger.trace("Got signal: " + signal + " again from input port: " + inputPort);
return true;
} else {
this.logger.trace("Got signal: " + signal + " from input port: " + inputPort);
this.visited.put(signal, null);
return false;
}
}
public void onValidating(final List<InvalidPortConnection> invalidPortConnections) {
this.validateOutputPorts(invalidPortConnections);
}
public void onStarting() {
this.cachedInputPorts = this.inputPortList.toArray(new InputPort<?>[0]);
this.cachedOutputPorts = this.outputPortList.toArray(new OutputPort<?>[0]);
this.connectUnconnectedOutputPorts();
}
public void onTerminating() {
// empty default implementation
}
protected <T> InputPort<T> createInputPort() {
InputPort<T> inputPort = new InputPort<T>(this);
// inputPort.setType(portType);
this.inputPortList.add(inputPort);
return inputPort;
}
protected <T> OutputPort<T> createOutputPort() {
OutputPort<T> outputPort = new OutputPort<T>();
// outputPort.setType(portType);
this.outputPortList.add(outputPort);
return outputPort;
}
@Override
public void validateOutputPorts(final List<InvalidPortConnection> invalidPortConnections) {
for (OutputPort<?> outputPort : this.getOutputPorts()) {
IPipe pipe = outputPort.getPipe();
if (null != pipe) { // if output port is connected with another one
Class<?> sourcePortType = outputPort.getType();
Class<?> targetPortType = pipe.getTargetPort().getType();
if (null == sourcePortType || !sourcePortType.equals(targetPortType)) {
InvalidPortConnection invalidPortConnection = new InvalidPortConnection(outputPort, pipe.getTargetPort());
invalidPortConnections.add(invalidPortConnection);
}
}
}
}
@Override
public String toString() {
return this.getClass().getName() + ": " + this.id;
}
}
package teetime.framework;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import teetime.util.Pair;
public class Analysis implements UncaughtExceptionHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(Analysis.class);
private final AnalysisConfiguration configuration;
private final List<Thread> consumerThreads = new LinkedList<Thread>();
private final List<Thread> finiteProducerThreads = new LinkedList<Thread>();
private final List<Thread> infiniteProducerThreads = new LinkedList<Thread>();
private final Collection<Pair<Thread, Throwable>> exceptions = new ConcurrentLinkedQueue<Pair<Thread, Throwable>>();
public Analysis(final AnalysisConfiguration configuration) {
this.configuration = configuration;
}
public void init() {
for (HeadStage stage : this.configuration.getConsumerStages()) {
Thread thread = new Thread(new RunnableStage(stage));
this.consumerThreads.add(thread);
}
for (HeadStage stage : this.configuration.getFiniteProducerStages()) {
Thread thread = new Thread(new RunnableStage(stage));
this.finiteProducerThreads.add(thread);
}
for (HeadStage stage : this.configuration.getInfiniteProducerStages()) {
Thread thread = new Thread(new RunnableStage(stage));
this.infiniteProducerThreads.add(thread);
}
}
/**
*
* @return a map of thread/throwable pair
*/
public Collection<Pair<Thread, Throwable>> start() {
// start analysis
for (Thread thread : this.consumerThreads) {
thread.setUncaughtExceptionHandler(this);
thread.start();
}
for (Thread thread : this.finiteProducerThreads) {
thread.setUncaughtExceptionHandler(this);
thread.start();
}
for (Thread thread : this.infiniteProducerThreads) {
thread.setUncaughtExceptionHandler(this);
thread.start();
}
// wait for the analysis to complete
try {
for (Thread thread : this.finiteProducerThreads) {
thread.join();
}
for (Thread thread : this.consumerThreads) {
thread.join();
}
} catch (InterruptedException e) {
LOGGER.error("Analysis has stopped unexpectedly", e);
for (Thread thread : this.finiteProducerThreads) {
thread.interrupt();
}
for (Thread thread : this.consumerThreads) {
thread.interrupt();
}
}
for (Thread thread : this.infiniteProducerThreads) {
thread.interrupt();
}
return this.exceptions;
}
public AnalysisConfiguration getConfiguration() {
return this.configuration;
}
@Override
public void uncaughtException(final Thread t, final Throwable e) {
this.exceptions.add(Pair.of(t, e));
}
}
package teetime.framework;
import java.util.LinkedList;
import java.util.List;
import teetime.framework.pipe.PipeFactoryRegistry;
public class AnalysisConfiguration {
protected static final PipeFactoryRegistry PIPE_FACTORY_REGISTRY = PipeFactoryRegistry.INSTANCE;
private final List<HeadStage> consumerStages = new LinkedList<HeadStage>();
private final List<HeadStage> finiteProducerStages = new LinkedList<HeadStage>();
private final List<HeadStage> infiniteProducerStages = new LinkedList<HeadStage>();
public List<HeadStage> getConsumerStages() {
return this.consumerStages;
}
public List<HeadStage> getFiniteProducerStages() {
return this.finiteProducerStages;
}
public List<HeadStage> getInfiniteProducerStages() {
return this.infiniteProducerStages;
}
}
package teetime.framework;
public abstract class ConsumerStage<I> extends AbstractStage {
protected final InputPort<I> inputPort = this.createInputPort();
public final InputPort<I> getInputPort() {
return this.inputPort;
}
@Override
public void executeWithPorts() {
I element = this.getInputPort().receive();
this.execute(element);
}
protected abstract void execute(I element);
}
package teetime.framework;
public class HeadPipeline<FirstStage extends HeadStage, LastStage extends Stage> extends OldPipeline<FirstStage, LastStage> implements HeadStage {
public HeadPipeline() {}
public HeadPipeline(final String name) {}
@Override
public boolean shouldBeTerminated() {
return this.firstStage.shouldBeTerminated();
}
@Override
public void terminate() {
this.firstStage.terminate();
}
}
package teetime.framework;
public interface HeadStage extends Stage {
boolean shouldBeTerminated();
void terminate();
}
package teetime.framework;
import teetime.framework.pipe.IPipe;
public class InputPort<T> extends AbstractPort<T> {
private final Stage owningStage;
InputPort(final Stage owningStage) {
super();
this.owningStage = owningStage;
}
public T receive() {
@SuppressWarnings("unchecked")
T element = (T) this.pipe.removeLast();
return element;
}
public T read() {
@SuppressWarnings("unchecked")
T element = (T) this.pipe.readLast();
return element;
}
/**
* Connects this input port with the given <code>pipe</code> bi-directionally
*
* @param pipe
*/
@Override
public void setPipe(final IPipe pipe) {
this.pipe = pipe;
}
public Stage getOwningStage() {
return this.owningStage;
}
}
package teetime.framework;
import java.util.List;
import teetime.framework.signal.ISignal;
import teetime.framework.validation.InvalidPortConnection;
public class OldPipeline<FirstStage extends Stage, LastStage extends Stage> implements Stage {
protected FirstStage firstStage;
protected LastStage lastStage;
public FirstStage getFirstStage() {
return this.firstStage;
}
public void setFirstStage(final FirstStage firstStage) {
this.firstStage = firstStage;
}
public LastStage getLastStage() {
return this.lastStage;
}
public void setLastStage(final LastStage lastStage) {
this.lastStage = lastStage;
}
@Override
public String getId() {
return this.firstStage.getId();
}
@Override
public void executeWithPorts() {
this.firstStage.executeWithPorts();
}
@Override
public Stage getParentStage() {
return this.firstStage.getParentStage();
}
@Override
public void setParentStage(final Stage parentStage, final int index) {
this.firstStage.setParentStage(parentStage, index);
}
@Override
public void onSignal(final ISignal signal, final InputPort<?> inputPort) {
this.firstStage.onSignal(signal, inputPort);
}
@Override
public void validateOutputPorts(final List<InvalidPortConnection> invalidPortConnections) {
this.lastStage.validateOutputPorts(invalidPortConnections);
}
}
package teetime.framework;
import teetime.framework.signal.ISignal;
public final class OutputPort<T> extends AbstractPort<T> {
OutputPort() {
super();
}
/**
*
* @param element
* @return <code>true</code> iff the given <code>element</code> could be sent, <code>false</code> otherwise (then use a re-try strategy)
*/
public boolean send(final T element) {
return this.pipe.add(element);
}
public void sendSignal(final ISignal signal) {
this.pipe.sendSignal(signal);
}
public void reportNewElement() {
this.pipe.reportNewElement();
}
}
package teetime.framework;
/**
* The <code>ProducerStage</code> produces at least one element at each execution.<br>
*
* @author Christian Wulf
*
* @param <O>
* the type of the default output port
*
*/
public abstract class ProducerStage<O> extends AbstractStage implements HeadStage {
protected final OutputPort<O> outputPort = this.createOutputPort();
private boolean shouldTerminate;
public final OutputPort<O> getOutputPort() {
return this.outputPort;
}
@Override
public void executeWithPorts() {
this.execute();
}
@Override
public void terminate() {
this.shouldTerminate = true;
}
@Override
public boolean shouldBeTerminated() {
return this.shouldTerminate;
}
protected abstract void execute();
}
package teetime.framework;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import teetime.framework.signal.StartingSignal;
import teetime.framework.signal.TerminatingSignal;