Skip to content
Snippets Groups Projects
Commit 28d1023d authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

Merge remote-tracking branch 'origin/master' into threadNameing

parents 7ee2b2c3 c09392e8
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory; ...@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
import teetime.framework.exceptionHandling.AbstractExceptionListener; import teetime.framework.exceptionHandling.AbstractExceptionListener;
import teetime.framework.exceptionHandling.IExceptionListenerFactory; import teetime.framework.exceptionHandling.IExceptionListenerFactory;
import teetime.framework.exceptionHandling.IgnoringExceptionListenerFactory; import teetime.framework.exceptionHandling.TerminatingExceptionListenerFactory;
import teetime.framework.signal.InitializingSignal; import teetime.framework.signal.InitializingSignal;
import teetime.framework.signal.ValidatingSignal; import teetime.framework.signal.ValidatingSignal;
import teetime.framework.validation.AnalysisNotValidException; import teetime.framework.validation.AnalysisNotValidException;
...@@ -73,11 +73,11 @@ public final class Execution<T extends Configuration> implements UncaughtExcepti ...@@ -73,11 +73,11 @@ public final class Execution<T extends Configuration> implements UncaughtExcepti
* to be used for the analysis * to be used for the analysis
*/ */
public Execution(final T configuration) { public Execution(final T configuration) {
this(configuration, false, new IgnoringExceptionListenerFactory()); this(configuration, false, new TerminatingExceptionListenerFactory());
} }
public Execution(final T configuration, final boolean validationEnabled) { public Execution(final T configuration, final boolean validationEnabled) {
this(configuration, validationEnabled, new IgnoringExceptionListenerFactory()); this(configuration, validationEnabled, new TerminatingExceptionListenerFactory());
} }
/** /**
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
*/ */
package teetime.framework; package teetime.framework;
import teetime.framework.idle.IdleStrategy;
import teetime.framework.idle.YieldStrategy;
import teetime.framework.signal.ISignal; import teetime.framework.signal.ISignal;
import teetime.framework.signal.TerminatingSignal; import teetime.framework.signal.TerminatingSignal;
...@@ -26,16 +24,12 @@ final class RunnableConsumerStage extends AbstractRunnableStage { ...@@ -26,16 +24,12 @@ final class RunnableConsumerStage extends AbstractRunnableStage {
private final InputPort<?>[] inputPorts; private final InputPort<?>[] inputPorts;
/** /**
* Creates a new instance with the {@link YieldStrategy} as default idle strategy. * Creates a new instance.
* *
* @param stage * @param stage
* to execute within an own thread * to execute within an own thread
*/ */
public RunnableConsumerStage(final Stage stage) { public RunnableConsumerStage(final Stage stage) {
this(stage, new YieldStrategy());
}
public RunnableConsumerStage(final Stage stage, final IdleStrategy idleStrategy) {
super(stage); super(stage);
this.inputPorts = stage.getInputPorts(); // FIXME should getInputPorts() really be defined in Stage? this.inputPorts = stage.getInputPorts(); // FIXME should getInputPorts() really be defined in Stage?
} }
......
/**
* 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;
}
/**
* 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);
}
}
/**
* 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;
/**
* @deprecated since 1.1
*/
@Deprecated
public final class YieldStrategy implements IdleStrategy {
@Override
public void execute() throws InterruptedException {
Thread.yield();
}
}
...@@ -18,7 +18,7 @@ package teetime.stage.basic; ...@@ -18,7 +18,7 @@ package teetime.stage.basic;
import teetime.framework.AbstractConsumerStage; import teetime.framework.AbstractConsumerStage;
import teetime.framework.OutputPort; 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(); private final OutputPort<O> outputPort = createOutputPort();
...@@ -26,7 +26,8 @@ public abstract class AbstractTransformation<I, O> extends AbstractConsumerStage ...@@ -26,7 +26,8 @@ public abstract class AbstractTransformation<I, O> extends AbstractConsumerStage
super(); super();
} }
public OutputPort<O> getOutputPort() { @Override
public final OutputPort<O> getOutputPort() {
return outputPort; return outputPort;
} }
} }
package teetime.stage.basic;
import teetime.framework.InputPort;
import teetime.framework.OutputPort;
public interface ITransformation<I, O> {
public abstract InputPort<I> getInputPort();
public abstract OutputPort<O> getOutputPort();
}
...@@ -15,13 +15,10 @@ ...@@ -15,13 +15,10 @@
*/ */
package teetime.stage.string; package teetime.stage.string;
import java.util.ArrayList;
import teetime.framework.AbstractCompositeStage; import teetime.framework.AbstractCompositeStage;
import teetime.framework.ConfigurationContext; import teetime.framework.ConfigurationContext;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort; import teetime.framework.OutputPort;
import teetime.framework.Stage;
import teetime.stage.MappingCounter; import teetime.stage.MappingCounter;
import teetime.stage.util.CountingMap; import teetime.stage.util.CountingMap;
...@@ -36,24 +33,18 @@ import teetime.stage.util.CountingMap; ...@@ -36,24 +33,18 @@ import teetime.stage.util.CountingMap;
*/ */
public final class WordCounter extends AbstractCompositeStage { public final class WordCounter extends AbstractCompositeStage {
// This fields are needed for the methods to work. private final Tokenizer tokenizer;
private final Tokenizer tokenizer = new Tokenizer(" "); private final MappingCounter<String> mapCounter;
private final MappingCounter<String> mapCounter = new MappingCounter<String>();
private final ArrayList<Stage> lastStages = new ArrayList<Stage>();
// The connection of the different stages is realized within the construction of a instance of this class.
public WordCounter(final ConfigurationContext context) { public WordCounter(final ConfigurationContext context) {
super(context); super(context);
this.lastStages.add(this.mapCounter);
this.tokenizer = new Tokenizer(" ");
final ToLowerCase toLowerCase = new ToLowerCase(); final ToLowerCase toLowerCase = new ToLowerCase();
this.mapCounter = new MappingCounter<String>();
connectPorts(this.tokenizer.getOutputPort(), toLowerCase.getInputPort()); connectPorts(this.tokenizer.getOutputPort(), toLowerCase.getInputPort());
connectPorts(toLowerCase.getOutputPort(), this.mapCounter.getInputPort()); connectPorts(toLowerCase.getOutputPort(), this.mapCounter.getInputPort());
// connectStages(wordcharacterFilter.getOutputPort(), this.mapCounter.getInputPort());
}
public Stage getFirstStage() {
return this.tokenizer;
} }
public InputPort<String> getInputPort() { public InputPort<String> getInputPort() {
......
wiki @ 0a5bd4dd
Subproject commit 0a5bd4ddb82684ce1ae2ec84c67ff2117ebff143
...@@ -83,8 +83,7 @@ public class TraversorTest { ...@@ -83,8 +83,7 @@ public class TraversorTest {
connectPorts(distributor.getNewOutputPort(), wc.getInputPort()); connectPorts(distributor.getNewOutputPort(), wc.getInputPort());
connectPorts(wc.getOutputPort(), merger.getNewInputPort()); connectPorts(wc.getOutputPort(), merger.getNewInputPort());
// Add WordCounter as a threadable stage, so it runs in its own thread // 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 // Connect the stages of the last part
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment