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

Renamed AnalysisConfiguration to AnalysisContext

parent 0d73dd20
No related branches found
No related tags found
No related merge requests found
Showing
with 36 additions and 40 deletions
...@@ -25,11 +25,9 @@ package teetime.framework; ...@@ -25,11 +25,9 @@ package teetime.framework;
*/ */
public abstract class AbstractCompositeStage extends Network { public abstract class AbstractCompositeStage extends Network {
private final AnalysisConfiguration context; private final AnalysisContext context;
public abstract Stage getFirstStage(); public AbstractCompositeStage(final AnalysisContext context) {
public AbstractCompositeStage(final AnalysisConfiguration context) {
this.context = context; this.context = context;
} }
...@@ -48,7 +46,7 @@ public abstract class AbstractCompositeStage extends Network { ...@@ -48,7 +46,7 @@ public abstract class AbstractCompositeStage extends Network {
context.addThreadableStage(stage); context.addThreadableStage(stage);
} }
AnalysisConfiguration getContext() { protected AnalysisContext getContext() {
return context; return context;
} }
......
...@@ -35,7 +35,7 @@ import teetime.util.Pair; ...@@ -35,7 +35,7 @@ import teetime.util.Pair;
/** /**
* Represents an Analysis to which stages can be added and executed later. * Represents an Analysis to which stages can be added and executed later.
* This needs a {@link AnalysisConfiguration}, * This needs a {@link AnalysisContext},
* in which the adding and configuring of stages takes place. * in which the adding and configuring of stages takes place.
* To start the analysis {@link #executeBlocking()} needs to be executed. * To start the analysis {@link #executeBlocking()} needs to be executed.
* This class will automatically create threads and join them without any further commitment. * This class will automatically create threads and join them without any further commitment.
...@@ -43,9 +43,9 @@ import teetime.util.Pair; ...@@ -43,9 +43,9 @@ import teetime.util.Pair;
* @author Christian Wulf, Nelson Tavares de Sousa * @author Christian Wulf, Nelson Tavares de Sousa
* *
* @param <T> * @param <T>
* the type of the {@link AnalysisConfiguration} * the type of the {@link AnalysisContext}
*/ */
public final class Analysis<T extends AnalysisConfiguration> implements UncaughtExceptionHandler { public final class Analysis<T extends AnalysisContext> implements UncaughtExceptionHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(Analysis.class); private static final Logger LOGGER = LoggerFactory.getLogger(Analysis.class);
......
...@@ -29,7 +29,7 @@ import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; ...@@ -29,7 +29,7 @@ import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
* Represents a configuration of connected stages, which is needed to run a analysis. * Represents a configuration of connected stages, which is needed to run a analysis.
* Stages can be added by executing {@link #addThreadableStage(Stage)}. * Stages can be added by executing {@link #addThreadableStage(Stage)}.
*/ */
public abstract class AnalysisConfiguration extends Network { public abstract class AnalysisContext extends Network {
private final Set<Stage> threadableStages = new HashSet<Stage>(); private final Set<Stage> threadableStages = new HashSet<Stage>();
......
...@@ -36,14 +36,14 @@ class AnalysisInstantiation { ...@@ -36,14 +36,14 @@ class AnalysisInstantiation {
private final IPipeFactory interUnboundedThreadPipeFactory = new UnboundedSpScPipeFactory(); private final IPipeFactory interUnboundedThreadPipeFactory = new UnboundedSpScPipeFactory();
private final IPipeFactory intraThreadPipeFactory = new SingleElementPipeFactory(); private final IPipeFactory intraThreadPipeFactory = new SingleElementPipeFactory();
private final AnalysisConfiguration configuration; private final AnalysisContext configuration;
public AnalysisInstantiation(final AnalysisConfiguration configuration) { public AnalysisInstantiation(final AnalysisContext configuration) {
this.configuration = configuration; this.configuration = configuration;
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
Integer colorAndConnectStages(final Integer i, final Map<Stage, Integer> colors, final Stage threadableStage, final AnalysisConfiguration configuration) { Integer colorAndConnectStages(final Integer i, final Map<Stage, Integer> colors, final Stage threadableStage, final AnalysisContext configuration) {
Integer createdConnections = new Integer(0); Integer createdConnections = new Integer(0);
Set<Stage> threadableStageJobs = configuration.getThreadableStages(); Set<Stage> threadableStageJobs = configuration.getThreadableStages();
for (OutputPort outputPort : threadableStage.getOutputPorts()) { for (OutputPort outputPort : threadableStage.getOutputPorts()) {
......
...@@ -20,7 +20,7 @@ import java.util.Arrays; ...@@ -20,7 +20,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import teetime.framework.Analysis; import teetime.framework.Analysis;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisContext;
import teetime.framework.AnalysisException; import teetime.framework.AnalysisException;
import teetime.framework.Stage; import teetime.framework.Stage;
import teetime.framework.StageState; import teetime.framework.StageState;
...@@ -78,12 +78,12 @@ public final class StageTester { ...@@ -78,12 +78,12 @@ public final class StageTester {
* *
*/ */
public void start() { public void start() {
final AnalysisConfiguration configuration = new Configuration(inputHolders, stage, outputHolders); final AnalysisContext configuration = new Configuration(inputHolders, stage, outputHolders);
final Analysis<AnalysisConfiguration> analysis = new Analysis<AnalysisConfiguration>(configuration); final Analysis<AnalysisContext> analysis = new Analysis<AnalysisContext>(configuration);
analysis.executeBlocking(); analysis.executeBlocking();
} }
private final class Configuration extends AnalysisConfiguration { private final class Configuration extends AnalysisContext {
public Configuration(final List<InputHolder<?>> inputHolders, final Stage stage, final List<OutputHolder<?>> outputHolders) { public Configuration(final List<InputHolder<?>> inputHolders, final Stage stage, final List<OutputHolder<?>> outputHolders) {
for (InputHolder<?> inputHolder : inputHolders) { for (InputHolder<?> inputHolder : inputHolders) {
......
...@@ -19,7 +19,7 @@ import java.util.ArrayList; ...@@ -19,7 +19,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import teetime.framework.AbstractCompositeStage; import teetime.framework.AbstractCompositeStage;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisContext;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort; import teetime.framework.OutputPort;
import teetime.framework.Stage; import teetime.framework.Stage;
...@@ -32,7 +32,7 @@ public final class EveryXthPrinter<T> extends AbstractCompositeStage { ...@@ -32,7 +32,7 @@ public final class EveryXthPrinter<T> extends AbstractCompositeStage {
private final Distributor<T> distributor; private final Distributor<T> distributor;
private final List<Stage> lastStages = new ArrayList<Stage>(); private final List<Stage> lastStages = new ArrayList<Stage>();
public EveryXthPrinter(final int threshold, final AnalysisConfiguration context) { public EveryXthPrinter(final int threshold, final AnalysisContext context) {
super(context); super(context);
distributor = new Distributor<T>(new CopyByReferenceStrategy()); distributor = new Distributor<T>(new CopyByReferenceStrategy());
EveryXthStage<T> everyXthStage = new EveryXthStage<T>(threshold); EveryXthStage<T> everyXthStage = new EveryXthStage<T>(threshold);
...@@ -52,7 +52,6 @@ public final class EveryXthPrinter<T> extends AbstractCompositeStage { ...@@ -52,7 +52,6 @@ public final class EveryXthPrinter<T> extends AbstractCompositeStage {
return distributor.getNewOutputPort(); return distributor.getNewOutputPort();
} }
@Override
public Stage getFirstStage() { public Stage getFirstStage() {
return distributor; return distributor;
} }
......
...@@ -18,7 +18,7 @@ package teetime.stage.string; ...@@ -18,7 +18,7 @@ package teetime.stage.string;
import java.util.ArrayList; import java.util.ArrayList;
import teetime.framework.AbstractCompositeStage; import teetime.framework.AbstractCompositeStage;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisContext;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort; import teetime.framework.OutputPort;
import teetime.framework.Stage; import teetime.framework.Stage;
...@@ -42,7 +42,7 @@ public final class WordCounter extends AbstractCompositeStage { ...@@ -42,7 +42,7 @@ public final class WordCounter extends AbstractCompositeStage {
private final ArrayList<Stage> lastStages = new ArrayList<Stage>(); 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. // The connection of the different stages is realized within the construction of a instance of this class.
public WordCounter(final AnalysisConfiguration context) { public WordCounter(final AnalysisContext context) {
super(context); super(context);
this.lastStages.add(this.mapCounter); this.lastStages.add(this.mapCounter);
final ToLowerCase toLowerCase = new ToLowerCase(); final ToLowerCase toLowerCase = new ToLowerCase();
...@@ -52,7 +52,6 @@ public final class WordCounter extends AbstractCompositeStage { ...@@ -52,7 +52,6 @@ public final class WordCounter extends AbstractCompositeStage {
// connectStages(wordcharacterFilter.getOutputPort(), this.mapCounter.getInputPort()); // connectStages(wordcharacterFilter.getOutputPort(), this.mapCounter.getInputPort());
} }
@Override
public Stage getFirstStage() { public Stage getFirstStage() {
return this.tokenizer; return this.tokenizer;
} }
......
...@@ -17,7 +17,7 @@ package teetime.examples.cipher; ...@@ -17,7 +17,7 @@ package teetime.examples.cipher;
import java.io.File; import java.io.File;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisContext;
import teetime.stage.CipherStage; import teetime.stage.CipherStage;
import teetime.stage.CipherStage.CipherMode; import teetime.stage.CipherStage.CipherMode;
import teetime.stage.InitialElementProducer; import teetime.stage.InitialElementProducer;
...@@ -26,7 +26,7 @@ import teetime.stage.ZipByteArray.ZipMode; ...@@ -26,7 +26,7 @@ import teetime.stage.ZipByteArray.ZipMode;
import teetime.stage.io.ByteArrayFileWriter; import teetime.stage.io.ByteArrayFileWriter;
import teetime.stage.io.File2ByteArray; import teetime.stage.io.File2ByteArray;
public class CipherConfiguration extends AnalysisConfiguration { public class CipherConfiguration extends AnalysisContext {
public CipherConfiguration(final String inputFile, final String outputFile, final String password) { public CipherConfiguration(final String inputFile, final String outputFile, final String password) {
final File input = new File(inputFile); final File input = new File(inputFile);
......
...@@ -22,7 +22,7 @@ import org.junit.Assert; ...@@ -22,7 +22,7 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import teetime.framework.Analysis; import teetime.framework.Analysis;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisContext;
import com.google.common.io.Files; import com.google.common.io.Files;
...@@ -43,7 +43,7 @@ public class CipherTest { ...@@ -43,7 +43,7 @@ public class CipherTest {
final String outputFile = "src/test/resources/data/output.txt"; final String outputFile = "src/test/resources/data/output.txt";
final String password = "Password"; final String password = "Password";
final AnalysisConfiguration configuration = new CipherConfiguration(inputFile, outputFile, password); final AnalysisContext configuration = new CipherConfiguration(inputFile, outputFile, password);
final Analysis analysis = new Analysis(configuration); final Analysis analysis = new Analysis(configuration);
analysis.executeBlocking(); analysis.executeBlocking();
......
...@@ -17,7 +17,7 @@ package teetime.examples.tokenizer; ...@@ -17,7 +17,7 @@ package teetime.examples.tokenizer;
import java.io.File; import java.io.File;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisContext;
import teetime.stage.ByteArray2String; import teetime.stage.ByteArray2String;
import teetime.stage.CipherStage; import teetime.stage.CipherStage;
import teetime.stage.CipherStage.CipherMode; import teetime.stage.CipherStage.CipherMode;
...@@ -28,7 +28,7 @@ import teetime.stage.ZipByteArray.ZipMode; ...@@ -28,7 +28,7 @@ import teetime.stage.ZipByteArray.ZipMode;
import teetime.stage.io.File2ByteArray; import teetime.stage.io.File2ByteArray;
import teetime.stage.string.Tokenizer; import teetime.stage.string.Tokenizer;
public class TokenizerConfiguration extends AnalysisConfiguration { public class TokenizerConfiguration extends AnalysisContext {
private final Counter<String> counter; private final Counter<String> counter;
......
...@@ -70,7 +70,7 @@ public class AnalysisTest { ...@@ -70,7 +70,7 @@ public class AnalysisTest {
assertThat(watch.getDurationInMs() + ABSOLUTE_MAX_ERROR_IN_MS, is(greaterThanOrEqualTo(DELAY_IN_MS))); assertThat(watch.getDurationInMs() + ABSOLUTE_MAX_ERROR_IN_MS, is(greaterThanOrEqualTo(DELAY_IN_MS)));
} }
private static class TestConfig extends AnalysisConfiguration { private static class TestConfig extends AnalysisContext {
public final DelayAndTerminate delay; public final DelayAndTerminate delay;
public TestConfig() { public TestConfig() {
...@@ -112,7 +112,7 @@ public class AnalysisTest { ...@@ -112,7 +112,7 @@ public class AnalysisTest {
assertThat(intraAnalysis.getConfiguration().init.getOwningThread(), is(intraAnalysis.getConfiguration().sink.getOwningThread())); assertThat(intraAnalysis.getConfiguration().init.getOwningThread(), is(intraAnalysis.getConfiguration().sink.getOwningThread()));
} }
private class AnalysisTestConfig extends AnalysisConfiguration { private class AnalysisTestConfig extends AnalysisContext {
public InitialElementProducer<Object> init = new InitialElementProducer<Object>(); public InitialElementProducer<Object> init = new InitialElementProducer<Object>();
public Sink<Object> sink = new Sink<Object>(); public Sink<Object> sink = new Sink<Object>();
...@@ -136,7 +136,7 @@ public class AnalysisTest { ...@@ -136,7 +136,7 @@ public class AnalysisTest {
new Analysis<InvalidTestConfig>(configuration); new Analysis<InvalidTestConfig>(configuration);
} }
private class InvalidTestConfig extends AnalysisConfiguration { private class InvalidTestConfig extends AnalysisContext {
public InitialElementProducer<Object> init = new InitialElementProducer<Object>(); public InitialElementProducer<Object> init = new InitialElementProducer<Object>();
public InstanceOfFilter<Object, Object> iof = new InstanceOfFilter<Object, Object>(Object.class); public InstanceOfFilter<Object, Object> iof = new InstanceOfFilter<Object, Object>(Object.class);
public Sink<Object> sink = new Sink<Object>(); public Sink<Object> sink = new Sink<Object>();
......
...@@ -21,7 +21,7 @@ import java.util.List; ...@@ -21,7 +21,7 @@ import java.util.List;
import teetime.stage.CollectorSink; import teetime.stage.CollectorSink;
import teetime.stage.InitialElementProducer; import teetime.stage.InitialElementProducer;
public class RunnableConsumerStageTestConfiguration extends AnalysisConfiguration { public class RunnableConsumerStageTestConfiguration extends AnalysisContext {
private final List<Integer> collectedElements = new ArrayList<Integer>(); private final List<Integer> collectedElements = new ArrayList<Integer>();
private final CollectorSink<Integer> collectorSink; private final CollectorSink<Integer> collectorSink;
......
...@@ -53,7 +53,7 @@ public class StageTest { ...@@ -53,7 +53,7 @@ public class StageTest {
assertEquals(tc.init.exceptionHandler, tc.delay.exceptionHandler); assertEquals(tc.init.exceptionHandler, tc.delay.exceptionHandler);
} }
private static class TestConfig extends AnalysisConfiguration { private static class TestConfig extends AnalysisContext {
public final DelayAndTerminate delay; public final DelayAndTerminate delay;
public InitialElementProducer<String> init; public InitialElementProducer<String> init;
......
...@@ -53,7 +53,7 @@ public class TraversorTest { ...@@ -53,7 +53,7 @@ public class TraversorTest {
} }
// WordCounterConfiguration // WordCounterConfiguration
private class TestConfiguration extends AnalysisConfiguration { private class TestConfiguration extends AnalysisContext {
public final CountingMapMerger<String> result = new CountingMapMerger<String>(); public final CountingMapMerger<String> result = new CountingMapMerger<String>();
public final InitialElementProducer<File> init; public final InitialElementProducer<File> init;
......
...@@ -21,7 +21,7 @@ import teetime.stage.InitialElementProducer; ...@@ -21,7 +21,7 @@ import teetime.stage.InitialElementProducer;
import teetime.stage.Relay; import teetime.stage.Relay;
import teetime.stage.basic.Delay; import teetime.stage.basic.Delay;
class WaitStrategyConfiguration extends AnalysisConfiguration { class WaitStrategyConfiguration extends AnalysisContext {
private Delay<Object> delay; private Delay<Object> delay;
private CollectorSink<Object> collectorSink; private CollectorSink<Object> collectorSink;
......
...@@ -19,7 +19,7 @@ import teetime.stage.CollectorSink; ...@@ -19,7 +19,7 @@ import teetime.stage.CollectorSink;
import teetime.stage.InitialElementProducer; import teetime.stage.InitialElementProducer;
import teetime.stage.Relay; import teetime.stage.Relay;
class YieldStrategyConfiguration extends AnalysisConfiguration { class YieldStrategyConfiguration extends AnalysisContext {
private CollectorSink<Object> collectorSink; private CollectorSink<Object> collectorSink;
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
*/ */
package teetime.framework.exceptionHandling; package teetime.framework.exceptionHandling;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisContext;
public class ExceptionTestConfiguration extends AnalysisConfiguration { public class ExceptionTestConfiguration extends AnalysisContext {
ExceptionTestProducerStage first; ExceptionTestProducerStage first;
ExceptionTestConsumerStage second; ExceptionTestConsumerStage second;
......
...@@ -30,7 +30,7 @@ import org.junit.Before; ...@@ -30,7 +30,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import teetime.framework.Analysis; import teetime.framework.Analysis;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisContext;
import teetime.framework.AnalysisException; import teetime.framework.AnalysisException;
import teetime.util.Pair; import teetime.util.Pair;
...@@ -122,7 +122,7 @@ public class InstanceOfFilterTest { ...@@ -122,7 +122,7 @@ public class InstanceOfFilterTest {
} }
} }
private static class InstanceOfFilterTestConfig extends AnalysisConfiguration { private static class InstanceOfFilterTestConfig extends AnalysisContext {
public InstanceOfFilterTestConfig() { public InstanceOfFilterTestConfig() {
InitialElementProducer<Object> elementProducer = new InitialElementProducer<Object>(); InitialElementProducer<Object> elementProducer = new InitialElementProducer<Object>();
......
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