diff --git a/pom.xml b/pom.xml index d6b8981a29c3922c1190b252166607f6137b8484..a3014df98ca88605fa8827fac397ca9c5f0873b4 100644 --- a/pom.xml +++ b/pom.xml @@ -9,13 +9,13 @@ <name>TeeTime</name> <description>TeeTime is a Pipe-and-Filter framework for Java</description> - <url>http://teetime.sourceforge.org</url> + <url>http://christianwulf.github.io/teetime/</url> <inceptionYear>2015</inceptionYear> <licenses> <license> <name>Apache License, Version 2.0</name> - <url>http://teetime.sourceforge.net/LICENSE.txt</url> + <url>http://christianwulf.github.io/teetime/LICENSE.txt</url> </license> </licenses> @@ -310,12 +310,6 @@ <artifactId>doxia-module-markdown-teetime</artifactId> <version>1.6</version> </dependency> - <!-- add support for ssh/scp --> - <dependency> - <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-ssh</artifactId> - <version>2.9-SNAPSHOT</version> - </dependency> <!-- skin --> <dependency> <groupId>lt.velykis.maven.skins</groupId> diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 23c5758a7a62d1b93f768473b3066d374ba5c6a1..6ed7a57dd69949696e17dd850c36b61a52c536c3 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -6,7 +6,7 @@ </properties> <body> <release version="Snapshot" date="Daily basis" - description="Unstable preview of oncoming versions"> + description="Unstable preview of oncoming versions - 2.0-SNAPSHOT"> <action dev="ntd" type="add" issue="33"> TeeTime automatically chooses the correct type of pipe for all connections. @@ -21,19 +21,24 @@ </action> <action dev="ntd" type="add" issue="171"> Configurations are now - built within an AnalysisContext which is passed on to nested + built within the Configuration class which is passed on to nested CompositeStages. This removes any constraints on CompositeStages and enables therefore multiple connections and multithreading. </action> + <action dev="ntd" type="update"> + Renamed Analysis to Execution + </action> <action dev="ntd" type="remove"> - Marked Pair class as deprecated. + Removed pair class. </action> <action dev="ntd" type="add" issue="154"> All stages will be initialized before starting the analysis. </action> - + <action dev="ntd" type="add" issue="122"> + Threads can be named for better debugging. + </action> </release> <release version="1.1.2" date="12.05.2015" description="Minor bugfixes for 1.1"> diff --git a/src/main/java/teetime/framework/AbstractCompositeStage.java b/src/main/java/teetime/framework/AbstractCompositeStage.java index 0ffd7602798fd70b1852659e0e098bdf76367575..26e8685ef260a18ca2dcf1705cf71f98bff4ba92 100644 --- a/src/main/java/teetime/framework/AbstractCompositeStage.java +++ b/src/main/java/teetime/framework/AbstractCompositeStage.java @@ -43,6 +43,18 @@ public abstract class AbstractCompositeStage { return context; } + /** + * Execute this method, to add a stage to the configuration, which should be executed in a own thread. + * + * @param stage + * A arbitrary stage, which will be added to the configuration and executed in a thread. + * @param threadName + * A string which can be used for debugging. + */ + protected final void addThreadableStage(final Stage stage, final String threadName) { + context.addThreadableStage(stage, threadName); + } + /** * Execute this method, to add a stage to the configuration, which should be executed in a own thread. * @@ -50,7 +62,7 @@ public abstract class AbstractCompositeStage { * A arbitrary stage, which will be added to the configuration and executed in a thread. */ protected final void addThreadableStage(final Stage stage) { - context.addThreadableStage(stage); + this.addThreadableStage(stage, stage.getId()); } /** diff --git a/src/main/java/teetime/framework/AbstractPort.java b/src/main/java/teetime/framework/AbstractPort.java index 0544c4798cdfcdb500f88db3cb974f73db506a3f..f6664b54da56cd08a45f2acf6ddfef021baed278 100644 --- a/src/main/java/teetime/framework/AbstractPort.java +++ b/src/main/java/teetime/framework/AbstractPort.java @@ -19,47 +19,43 @@ import teetime.framework.pipe.IPipe; public abstract class AbstractPort<T> { - private final String portName; - - protected IPipe pipe; /** * The type of this port. * <p> * <i>Used to validate the connection between two ports at runtime.</i> * </p> */ - protected final Class<T> type; + private final Class<T> type; private final Stage owningStage; + private final String name; - public AbstractPort(final Class<T> type, final Stage owningStage, final String portName) { + protected IPipe pipe; + + public AbstractPort(final Class<T> type, final Stage owningStage, final String name) { super(); - this.portName = portName; this.type = type; this.owningStage = owningStage; + this.name = (name != null) ? name : super.toString(); } - public IPipe getPipe() { - return this.pipe; + public Class<T> getType() { + return this.type; } - public void setPipe(final IPipe pipe) { - this.pipe = pipe; + public Stage getOwningStage() { + return owningStage; } - public Class<T> getType() { - return this.type; + public IPipe getPipe() { + return this.pipe; } - public final Stage getOwningStage() { - return owningStage; + public void setPipe(final IPipe pipe) { + this.pipe = pipe; } @Override - public final String toString() { - if (portName == null) { - return super.toString(); - } else { - return portName; - } + public String toString() { + return name; } } diff --git a/src/main/java/teetime/framework/Configuration.java b/src/main/java/teetime/framework/Configuration.java index ea1a69f123e7b74a651274c2c13949e3d36f532f..bfaf92150fc223a0abc6347e96cf0f812ff4488b 100644 --- a/src/main/java/teetime/framework/Configuration.java +++ b/src/main/java/teetime/framework/Configuration.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime.sourceforge.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.framework; /** diff --git a/src/main/java/teetime/framework/ConfigurationContext.java b/src/main/java/teetime/framework/ConfigurationContext.java index e039883240a4c5809febb778d19d3f9c42c5a7d5..483b1ecbdb93ee23cfd9fec89906d947ba1d9787 100644 --- a/src/main/java/teetime/framework/ConfigurationContext.java +++ b/src/main/java/teetime/framework/ConfigurationContext.java @@ -15,8 +15,8 @@ */ package teetime.framework; -import java.util.HashSet; -import java.util.Set; +import java.util.HashMap; +import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,19 +33,19 @@ public final class ConfigurationContext { private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationContext.class); - private final Set<Stage> threadableStages = new HashSet<Stage>(); + private final Map<Stage, String> threadableStages = new HashMap<Stage, String>(); ConfigurationContext() {} - Set<Stage> getThreadableStages() { + Map<Stage, String> getThreadableStages() { return this.threadableStages; } /** * @see AbstractCompositeStage#addThreadableStage(Stage) */ - final void addThreadableStage(final Stage stage) { - if (!this.threadableStages.add(stage)) { + final void addThreadableStage(final Stage stage, final String threadName) { + if (this.threadableStages.put(stage, threadName) != null) { LOGGER.warn("Stage " + stage.getId() + " was already marked as threadable stage."); } } @@ -54,8 +54,10 @@ public final class ConfigurationContext { * @see AbstractCompositeStage#connectPorts(OutputPort, InputPort, int) */ final <T> void connectPorts(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) { - if (sourcePort.getOwningStage().getInputPorts().length == 0 && !threadableStages.contains(sourcePort.getOwningStage())) { - addThreadableStage(sourcePort.getOwningStage()); + if (sourcePort.getOwningStage().getInputPorts().length == 0) { + if (!threadableStages.containsKey(sourcePort.getOwningStage())) { + addThreadableStage(sourcePort.getOwningStage(), sourcePort.getOwningStage().getId()); + } } if (sourcePort.getPipe() != null || targetPort.getPipe() != null) { LOGGER.warn("Overwriting existing pipe while connecting stages " + diff --git a/src/main/java/teetime/framework/Execution.java b/src/main/java/teetime/framework/Execution.java index dd01458bf8b217120564e7780c239a717d2d0937..b2bcb38d5665e89fa0d25d39ae55864b98a273ad 100644 --- a/src/main/java/teetime/framework/Execution.java +++ b/src/main/java/teetime/framework/Execution.java @@ -19,6 +19,7 @@ import java.lang.Thread.UncaughtExceptionHandler; import java.util.Collection; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentLinkedQueue; @@ -27,7 +28,7 @@ import org.slf4j.LoggerFactory; import teetime.framework.exceptionHandling.AbstractExceptionListener; import teetime.framework.exceptionHandling.IExceptionListenerFactory; -import teetime.framework.exceptionHandling.IgnoringExceptionListenerFactory; +import teetime.framework.exceptionHandling.TerminatingExceptionListenerFactory; import teetime.framework.signal.InitializingSignal; import teetime.framework.signal.ValidatingSignal; import teetime.framework.validation.AnalysisNotValidException; @@ -72,11 +73,11 @@ public final class Execution<T extends Configuration> implements UncaughtExcepti * to be used for the analysis */ public Execution(final T configuration) { - this(configuration, false, new IgnoringExceptionListenerFactory()); + this(configuration, false, new TerminatingExceptionListenerFactory()); } public Execution(final T configuration, final boolean validationEnabled) { - this(configuration, validationEnabled, new IgnoringExceptionListenerFactory()); + this(configuration, validationEnabled, new TerminatingExceptionListenerFactory()); } /** @@ -102,8 +103,8 @@ public final class Execution<T extends Configuration> implements UncaughtExcepti // BETTER validate concurrently private void validateStages() { - final Set<Stage> threadableStageJobs = this.configuration.getContext().getThreadableStages(); - for (Stage stage : threadableStageJobs) { + final Map<Stage, String> threadableStageJobs = this.configuration.getContext().getThreadableStages(); + for (Stage stage : threadableStageJobs.keySet()) { // // portConnectionValidator.validate(stage); // } @@ -123,7 +124,7 @@ public final class Execution<T extends Configuration> implements UncaughtExcepti ExecutionInstantiation executionInstantiation = new ExecutionInstantiation(configuration.getContext()); executionInstantiation.instantiatePipes(); - final Set<Stage> threadableStageJobs = this.configuration.getContext().getThreadableStages(); + final Set<Stage> threadableStageJobs = this.configuration.getContext().getThreadableStages().keySet(); if (threadableStageJobs.isEmpty()) { throw new IllegalStateException("No stage was added using the addThreadableStage(..) method. Add at least one stage."); } @@ -182,7 +183,7 @@ public final class Execution<T extends Configuration> implements UncaughtExcepti private Thread createThread(final AbstractRunnableStage runnable, final String name) { final Thread thread = new Thread(runnable); thread.setUncaughtExceptionHandler(this); - thread.setName(name); + thread.setName(configuration.getContext().getThreadableStages().get(runnable.stage)); return thread; } @@ -303,7 +304,7 @@ public final class Execution<T extends Configuration> implements UncaughtExcepti if (!executionInterrupted) { executionInterrupted = true; LOGGER.warn("Thread " + thread + " was interrupted. Terminating analysis now."); - for (Stage stage : configuration.getContext().getThreadableStages()) { + for (Stage stage : configuration.getContext().getThreadableStages().keySet()) { if (stage.getOwningThread() != thread) { if (stage.getTerminationStrategy() == TerminationStrategy.BY_SELF_DECISION) { stage.terminate(); diff --git a/src/main/java/teetime/framework/ExecutionInstantiation.java b/src/main/java/teetime/framework/ExecutionInstantiation.java index 8a8de620134b47b154abcec31ee1f6b41861e43a..cea2bcf2e29f8ba38a86033100186e7fcb9655a1 100644 --- a/src/main/java/teetime/framework/ExecutionInstantiation.java +++ b/src/main/java/teetime/framework/ExecutionInstantiation.java @@ -45,7 +45,7 @@ class ExecutionInstantiation { @SuppressWarnings("rawtypes") Integer colorAndConnectStages(final Integer i, final Map<Stage, Integer> colors, final Stage threadableStage, final ConfigurationContext configuration) { Integer createdConnections = new Integer(0); - Set<Stage> threadableStageJobs = configuration.getThreadableStages(); + Set<Stage> threadableStageJobs = configuration.getThreadableStages().keySet(); for (OutputPort outputPort : threadableStage.getOutputPorts()) { if (outputPort.pipe != null) { if (outputPort.pipe instanceof InstantiationPipe) { @@ -82,7 +82,7 @@ class ExecutionInstantiation { void instantiatePipes() { Integer i = new Integer(0); Map<Stage, Integer> colors = new HashMap<Stage, Integer>(); - Set<Stage> threadableStageJobs = configuration.getThreadableStages(); + Set<Stage> threadableStageJobs = configuration.getThreadableStages().keySet(); Integer createdConnections = 0; for (Stage threadableStage : threadableStageJobs) { i++; diff --git a/src/main/java/teetime/framework/RunnableConsumerStage.java b/src/main/java/teetime/framework/RunnableConsumerStage.java index 0043ef7dcca7d25fa04c27acd3c805d2204588cf..6021e9ffb9f8177029006530b1a54685c58e0d92 100644 --- a/src/main/java/teetime/framework/RunnableConsumerStage.java +++ b/src/main/java/teetime/framework/RunnableConsumerStage.java @@ -15,24 +15,18 @@ */ package teetime.framework; -import teetime.framework.idle.IdleStrategy; -import teetime.framework.idle.YieldStrategy; import teetime.framework.signal.ISignal; import teetime.framework.signal.TerminatingSignal; final class RunnableConsumerStage extends AbstractRunnableStage { /** - * Creates a new instance with the {@link YieldStrategy} as default idle strategy. + * Creates a new instance. * * @param stage * to execute within an own thread */ public RunnableConsumerStage(final Stage stage) { - this(stage, new YieldStrategy()); - } - - public RunnableConsumerStage(final Stage stage, final IdleStrategy idleStrategy) { super(stage); } diff --git a/src/main/java/teetime/framework/idle/IdleStrategy.java b/src/main/java/teetime/framework/idle/IdleStrategy.java deleted file mode 100644 index 454a128739564e097cfcfd4acd329cc6a81146f1..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/framework/idle/IdleStrategy.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime.sourceforge.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.framework.idle; - -/** - * - * @author Christian Wulf - * - * @deprecated since 1.1 - */ -@Deprecated -public interface IdleStrategy { - - void execute() throws InterruptedException; -} diff --git a/src/main/java/teetime/framework/idle/SleepStrategy.java b/src/main/java/teetime/framework/idle/SleepStrategy.java deleted file mode 100644 index aa88c78b8fe59eaaf80fcf41898ec052f4cdb05b..0000000000000000000000000000000000000000 --- a/src/main/java/teetime/framework/idle/SleepStrategy.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime.sourceforge.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.framework.idle; - -public final class SleepStrategy implements IdleStrategy { - - private final long timeoutInMs; - - public SleepStrategy(final long timeoutInMs) { - super(); - this.timeoutInMs = timeoutInMs; - } - - @Override - public void execute() throws InterruptedException { - Thread.sleep(timeoutInMs); - } - -} diff --git a/src/main/java/teetime/stage/basic/AbstractTransformation.java b/src/main/java/teetime/stage/basic/AbstractTransformation.java index 39cc348154866c1e7467c3dff9bd4d1bec804f53..1e65a45a81f69ff60c6b87b271b82a1cb5e9906c 100644 --- a/src/main/java/teetime/stage/basic/AbstractTransformation.java +++ b/src/main/java/teetime/stage/basic/AbstractTransformation.java @@ -18,7 +18,7 @@ package teetime.stage.basic; import teetime.framework.AbstractConsumerStage; import teetime.framework.OutputPort; -public abstract class AbstractTransformation<I, O> extends AbstractConsumerStage<I> { +public abstract class AbstractTransformation<I, O> extends AbstractConsumerStage<I> implements ITransformation<I, O> { private final OutputPort<O> outputPort = createOutputPort(); @@ -26,7 +26,8 @@ public abstract class AbstractTransformation<I, O> extends AbstractConsumerStage super(); } - public OutputPort<O> getOutputPort() { + @Override + public final OutputPort<O> getOutputPort() { return outputPort; } } diff --git a/src/main/java/teetime/framework/idle/YieldStrategy.java b/src/main/java/teetime/stage/basic/ITransformation.java similarity index 73% rename from src/main/java/teetime/framework/idle/YieldStrategy.java rename to src/main/java/teetime/stage/basic/ITransformation.java index 52bddcbd1511cef773286129d798c54809f66f0f..f4c0bd8a37e1fdf5ecf800e17c4bdf442ec57449 100644 --- a/src/main/java/teetime/framework/idle/YieldStrategy.java +++ b/src/main/java/teetime/stage/basic/ITransformation.java @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package teetime.framework.idle; +package teetime.stage.basic; -/** - * @deprecated since 1.1 - */ -@Deprecated -public final class YieldStrategy implements IdleStrategy { +import teetime.framework.InputPort; +import teetime.framework.OutputPort; + +public interface ITransformation<I, O> { + + public abstract InputPort<I> getInputPort(); - @Override - public void execute() throws InterruptedException { - Thread.yield(); - } + public abstract OutputPort<O> getOutputPort(); } diff --git a/src/main/java/teetime/stage/string/WordCounter.java b/src/main/java/teetime/stage/string/WordCounter.java index 08e10ed9de237288fd615d62676d7e7b01d01e60..1508c15edbf052f26a265df4253c750ef2917944 100644 --- a/src/main/java/teetime/stage/string/WordCounter.java +++ b/src/main/java/teetime/stage/string/WordCounter.java @@ -15,13 +15,10 @@ */ package teetime.stage.string; -import java.util.ArrayList; - import teetime.framework.AbstractCompositeStage; import teetime.framework.ConfigurationContext; import teetime.framework.InputPort; import teetime.framework.OutputPort; -import teetime.framework.Stage; import teetime.stage.MappingCounter; import teetime.stage.util.CountingMap; @@ -36,24 +33,18 @@ import teetime.stage.util.CountingMap; */ public final class WordCounter extends AbstractCompositeStage { - // This fields are needed for the methods to work. - private final Tokenizer tokenizer = new Tokenizer(" "); - private final MappingCounter<String> mapCounter = new MappingCounter<String>(); - private final ArrayList<Stage> lastStages = new ArrayList<Stage>(); + private final Tokenizer tokenizer; + private final MappingCounter<String> mapCounter; - // The connection of the different stages is realized within the construction of a instance of this class. public WordCounter(final ConfigurationContext context) { super(context); - this.lastStages.add(this.mapCounter); + + this.tokenizer = new Tokenizer(" "); final ToLowerCase toLowerCase = new ToLowerCase(); + this.mapCounter = new MappingCounter<String>(); connectPorts(this.tokenizer.getOutputPort(), toLowerCase.getInputPort()); connectPorts(toLowerCase.getOutputPort(), this.mapCounter.getInputPort()); - // connectStages(wordcharacterFilter.getOutputPort(), this.mapCounter.getInputPort()); - } - - public Stage getFirstStage() { - return this.tokenizer; } public InputPort<String> getInputPort() { diff --git a/src/site/resources/_config.yml b/src/site/resources/_config.yml new file mode 100644 index 0000000000000000000000000000000000000000..19af8f356b656fd22f94df2a9b6bf633ea37ac97 --- /dev/null +++ b/src/site/resources/_config.yml @@ -0,0 +1,4 @@ +include: [".htaccess"] + +gems: + - jekyll-redirect-from diff --git a/src/site/site.xml b/src/site/site.xml index 25d1340c5b72b72385c394707af69c49a6566b2d..534be27fbd7a2f05e3909b524d86619b32c4defc 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -8,10 +8,10 @@ <bannerLeft> <name> <![CDATA[ - <img src="http://teetime.sourceforge.net/images/teetime-path.svg" id="logo"> + <img src="http://christianwulf.github.io/teetime/images/teetime-path.svg" id="logo"> ]]> </name> - <href>http://teetime.sourceforge.net</href> + <href>http://christianwulf.github.io/teetime/</href> </bannerLeft> <poweredBy> <logo name="Maven" href="http://maven.apache.org/" @@ -54,7 +54,7 @@ <item name="Wiki" href="wiki/" /> </links> <menu name="Documentation"> - <item name="JavaDoc" href="stabledocs/index.html" /> + <item name="JavaDoc" href="http://teetime.sourceforge.net/stabledocs/index.html" /> <item name="Release Notes" href="changes-report.html" /> <item name="Project Dependencies" href="dependencies.html" /> <item name="License" href="license.html" /> @@ -82,7 +82,7 @@ <topNav>News|Download|Wiki|Documentation|Get Involved</topNav> <!-- <toc>sidebar</toc> --> <!-- <tocTopMax>4</tocTopMax> --> - <absoluteResourceURL>http://teetime.sourceforge.net + <absoluteResourceURL>http://christianwulf.github.io/teetime/ </absoluteResourceURL> <theme>default</theme> <highlightJs>true</highlightJs> @@ -91,7 +91,7 @@ <name> TeeTime </name> - <href>http://teetime.sourceforge.net</href> + <href>http://christianwulf.github.io/teetime/</href> </brand> <slogan> <![CDATA[ diff --git a/src/test/java/teetime/framework/AbstractCompositeStageTest.java b/src/test/java/teetime/framework/AbstractCompositeStageTest.java index 4f093cf0f58ddf4b39fcc6bcd6e5f113d9bf8884..3ca971fb3f31ea250e8ebcc718693f526e8df1f5 100644 --- a/src/test/java/teetime/framework/AbstractCompositeStageTest.java +++ b/src/test/java/teetime/framework/AbstractCompositeStageTest.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime.sourceforge.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.framework; diff --git a/src/test/java/teetime/framework/AbstractPortTest.java b/src/test/java/teetime/framework/AbstractPortTest.java index 5c711d8761acbd2d21d5e92f52902022be7ae31e..d8d14a37eb8f02ec3a3fdac0d43eb1ddde0a58fc 100644 --- a/src/test/java/teetime/framework/AbstractPortTest.java +++ b/src/test/java/teetime/framework/AbstractPortTest.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime.sourceforge.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.framework; import static org.hamcrest.Matchers.is; diff --git a/src/test/java/teetime/framework/ExecutionTest.java b/src/test/java/teetime/framework/ExecutionTest.java index 028513cf2a29be48d60d00445efb186fade57d70..bc7d850c158edd47da941c1f9bbea2dbd896ec95 100644 --- a/src/test/java/teetime/framework/ExecutionTest.java +++ b/src/test/java/teetime/framework/ExecutionTest.java @@ -176,4 +176,23 @@ public class ExecutionTest { } + @Test + public void threadNameing() { + NameConfig configuration = new NameConfig(); + Execution<NameConfig> execution = new Execution<NameConfig>(configuration); + assertThat(configuration.stageWithNamedThread.getOwningThread().getName(), is("TestName")); + } + + private class NameConfig extends Configuration { + + public InitialElementProducer<Object> stageWithNamedThread; + + public NameConfig() { + stageWithNamedThread = new InitialElementProducer<Object>(new Object()); + addThreadableStage(stageWithNamedThread, "TestName"); + connectPorts(stageWithNamedThread.getOutputPort(), new Sink().getInputPort()); + } + + } + } diff --git a/src/test/java/teetime/framework/TraversorTest.java b/src/test/java/teetime/framework/TraversorTest.java index 0b312dcdadb5ad77776754d5d4d8f370075123dd..dcbb167a883ad83e30543a798066963cdef098d3 100644 --- a/src/test/java/teetime/framework/TraversorTest.java +++ b/src/test/java/teetime/framework/TraversorTest.java @@ -83,8 +83,7 @@ public class TraversorTest { connectPorts(distributor.getNewOutputPort(), wc.getInputPort()); connectPorts(wc.getOutputPort(), merger.getNewInputPort()); // Add WordCounter as a threadable stage, so it runs in its own thread - addThreadableStage(wc.getFirstStage()); - + addThreadableStage(wc.getInputPort().getOwningStage()); } // Connect the stages of the last part