Skip to content
Snippets Groups Projects
Commit e6cac26c authored by Christian Wulf's avatar Christian Wulf
Browse files

refactored CipherTest;

renamed PipeFactory to PipeFactoryRegistry
parent aed45ffa
No related branches found
No related tags found
No related merge requests found
Showing
with 59 additions and 62 deletions
...@@ -2,8 +2,8 @@ package teetime.framework.pipe; ...@@ -2,8 +2,8 @@ package teetime.framework.pipe;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort; import teetime.framework.OutputPort;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
public interface IPipeFactory { public interface IPipeFactory {
......
...@@ -2,8 +2,8 @@ package teetime.framework.pipe; ...@@ -2,8 +2,8 @@ package teetime.framework.pipe;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort; import teetime.framework.OutputPort;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
public class OrderedGrowableArrayPipeFactory implements IPipeFactory { public class OrderedGrowableArrayPipeFactory implements IPipeFactory {
......
...@@ -8,9 +8,9 @@ import java.util.Map; ...@@ -8,9 +8,9 @@ import java.util.Map;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class PipeFactory { public class PipeFactoryRegistry {
private static final Logger LOGGER = LoggerFactory.getLogger(PipeFactory.class); private static final Logger LOGGER = LoggerFactory.getLogger(PipeFactoryRegistry.class);
public enum ThreadCommunication { public enum ThreadCommunication {
INTER, INTRA INTER, INTRA
...@@ -30,9 +30,9 @@ public class PipeFactory { ...@@ -30,9 +30,9 @@ public class PipeFactory {
private final Map<String, IPipeFactory> pipeFactories = new HashMap<String, IPipeFactory>(); private final Map<String, IPipeFactory> pipeFactories = new HashMap<String, IPipeFactory>();
public static PipeFactory INSTANCE = new PipeFactory(); public static PipeFactoryRegistry INSTANCE = new PipeFactoryRegistry();
private PipeFactory() { private PipeFactoryRegistry() {
try { try {
List<IPipeFactory> pipeFactories = PipeFactoryLoader.loadFromFile("conf/pipe-factories.conf"); List<IPipeFactory> pipeFactories = PipeFactoryLoader.loadFromFile("conf/pipe-factories.conf");
for (IPipeFactory pipeFactory : pipeFactories) { for (IPipeFactory pipeFactory : pipeFactories) {
......
...@@ -2,8 +2,8 @@ package teetime.framework.pipe; ...@@ -2,8 +2,8 @@ package teetime.framework.pipe;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort; import teetime.framework.OutputPort;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
public class SingleElementPipeFactory implements IPipeFactory { public class SingleElementPipeFactory implements IPipeFactory {
......
...@@ -2,8 +2,8 @@ package teetime.framework.pipe; ...@@ -2,8 +2,8 @@ package teetime.framework.pipe;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort; import teetime.framework.OutputPort;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
public class SpScPipeFactory implements IPipeFactory { public class SpScPipeFactory implements IPipeFactory {
......
...@@ -2,8 +2,8 @@ package teetime.framework.pipe; ...@@ -2,8 +2,8 @@ package teetime.framework.pipe;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort; import teetime.framework.OutputPort;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
public class UnorderedGrowablePipeFactory implements IPipeFactory { public class UnorderedGrowablePipeFactory implements IPipeFactory {
......
...@@ -20,10 +20,10 @@ import java.io.File; ...@@ -20,10 +20,10 @@ import java.io.File;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort; import teetime.framework.OutputPort;
import teetime.framework.Pipeline; import teetime.framework.Pipeline;
import teetime.framework.pipe.PipeFactory; import teetime.framework.pipe.PipeFactoryRegistry;
import teetime.framework.pipe.SingleElementPipe; import teetime.framework.pipe.SingleElementPipe;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
import teetime.stage.FileExtensionSwitch; import teetime.stage.FileExtensionSwitch;
import teetime.stage.basic.merger.Merger; import teetime.stage.basic.merger.Merger;
import teetime.stage.io.Directory2FilesFilter; import teetime.stage.io.Directory2FilesFilter;
...@@ -44,7 +44,7 @@ import kieker.common.util.filesystem.FSUtil; ...@@ -44,7 +44,7 @@ import kieker.common.util.filesystem.FSUtil;
*/ */
public class Dir2RecordsFilter extends Pipeline<ClassNameRegistryCreationFilter, Merger<IMonitoringRecord>> { public class Dir2RecordsFilter extends Pipeline<ClassNameRegistryCreationFilter, Merger<IMonitoringRecord>> {
private final PipeFactory pipeFactory = PipeFactory.INSTANCE; private final PipeFactoryRegistry pipeFactory = PipeFactoryRegistry.INSTANCE;
private ClassNameRegistryRepository classNameRegistryRepository; private ClassNameRegistryRepository classNameRegistryRepository;
/** /**
......
...@@ -22,9 +22,9 @@ import teetime.framework.HeadStage; ...@@ -22,9 +22,9 @@ import teetime.framework.HeadStage;
import teetime.framework.OldAnalysis; import teetime.framework.OldAnalysis;
import teetime.framework.RunnableStage; import teetime.framework.RunnableStage;
import teetime.framework.pipe.IPipeFactory; import teetime.framework.pipe.IPipeFactory;
import teetime.framework.pipe.PipeFactory; import teetime.framework.pipe.PipeFactoryRegistry;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
import teetime.stage.CollectorSink; import teetime.stage.CollectorSink;
import teetime.stage.NoopFilter; import teetime.stage.NoopFilter;
import teetime.stage.ObjectProducer; import teetime.stage.ObjectProducer;
...@@ -45,7 +45,7 @@ public class MethodCallThroughputAnalysis14 extends OldAnalysis { ...@@ -45,7 +45,7 @@ public class MethodCallThroughputAnalysis14 extends OldAnalysis {
private int numNoopFilters; private int numNoopFilters;
private List<TimestampObject> timestampObjects; private List<TimestampObject> timestampObjects;
private Runnable runnable; private Runnable runnable;
private final PipeFactory pipeFactory = PipeFactory.INSTANCE; private final PipeFactoryRegistry pipeFactory = PipeFactoryRegistry.INSTANCE;
@Override @Override
public void init() { public void init() {
......
...@@ -25,7 +25,7 @@ import teetime.framework.RunnableStage; ...@@ -25,7 +25,7 @@ import teetime.framework.RunnableStage;
import teetime.framework.StageWithPort; import teetime.framework.StageWithPort;
import teetime.framework.pipe.DummyPipe; import teetime.framework.pipe.DummyPipe;
import teetime.framework.pipe.IPipe; import teetime.framework.pipe.IPipe;
import teetime.framework.pipe.PipeFactory; import teetime.framework.pipe.PipeFactoryRegistry;
import teetime.framework.pipe.RelayTestPipe; import teetime.framework.pipe.RelayTestPipe;
import teetime.framework.pipe.UnorderedGrowablePipe; import teetime.framework.pipe.UnorderedGrowablePipe;
import teetime.framework.signal.TerminatingSignal; import teetime.framework.signal.TerminatingSignal;
...@@ -54,7 +54,7 @@ public class MethodCallThroughputAnalysis17 extends OldAnalysis { ...@@ -54,7 +54,7 @@ public class MethodCallThroughputAnalysis17 extends OldAnalysis {
private ConstructorClosure<TimestampObject> inputObjectCreator; private ConstructorClosure<TimestampObject> inputObjectCreator;
private int numNoopFilters; private int numNoopFilters;
private final PipeFactory pipeFactory = PipeFactory.INSTANCE; private final PipeFactoryRegistry pipeFactory = PipeFactoryRegistry.INSTANCE;
private final List<List<TimestampObject>> timestampObjectsList = new LinkedList<List<TimestampObject>>(); private final List<List<TimestampObject>> timestampObjectsList = new LinkedList<List<TimestampObject>>();
private Thread producerThread; private Thread producerThread;
......
...@@ -2,15 +2,15 @@ package teetime.examples.loopStage; ...@@ -2,15 +2,15 @@ package teetime.examples.loopStage;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisConfiguration;
import teetime.framework.pipe.IPipeFactory; import teetime.framework.pipe.IPipeFactory;
import teetime.framework.pipe.PipeFactory; import teetime.framework.pipe.PipeFactoryRegistry;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
import teetime.examples.loopStage.Countdown; import teetime.examples.loopStage.Countdown;
public class LoopStageAnalysisConfiguration extends AnalysisConfiguration { public class LoopStageAnalysisConfiguration extends AnalysisConfiguration {
private final PipeFactory pipeFactory = PipeFactory.INSTANCE; private final PipeFactoryRegistry pipeFactory = PipeFactoryRegistry.INSTANCE;
public LoopStageAnalysisConfiguration() { public LoopStageAnalysisConfiguration() {
Countdown countdown = new Countdown(10); Countdown countdown = new Countdown(10);
......
...@@ -21,9 +21,9 @@ import java.util.List; ...@@ -21,9 +21,9 @@ import java.util.List;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisConfiguration;
import teetime.framework.HeadStage; import teetime.framework.HeadStage;
import teetime.framework.pipe.PipeFactory; import teetime.framework.pipe.PipeFactoryRegistry;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
import teetime.stage.CollectorSink; import teetime.stage.CollectorSink;
import teetime.stage.InitialElementProducer; import teetime.stage.InitialElementProducer;
import teetime.stage.kieker.Dir2RecordsFilter; import teetime.stage.kieker.Dir2RecordsFilter;
...@@ -39,7 +39,7 @@ import kieker.common.record.IMonitoringRecord; ...@@ -39,7 +39,7 @@ import kieker.common.record.IMonitoringRecord;
public class RecordReaderConfiguration extends AnalysisConfiguration { public class RecordReaderConfiguration extends AnalysisConfiguration {
private final List<IMonitoringRecord> elementCollection = new LinkedList<IMonitoringRecord>(); private final List<IMonitoringRecord> elementCollection = new LinkedList<IMonitoringRecord>();
private final PipeFactory pipeFactory = PipeFactory.INSTANCE; private final PipeFactoryRegistry pipeFactory = PipeFactoryRegistry.INSTANCE;
public RecordReaderConfiguration() { public RecordReaderConfiguration() {
this.buildConfiguration(); this.buildConfiguration();
......
...@@ -9,9 +9,9 @@ import java.lang.reflect.InvocationTargetException; ...@@ -9,9 +9,9 @@ import java.lang.reflect.InvocationTargetException;
import org.junit.Test; import org.junit.Test;
import teetime.framework.pipe.IPipeFactory; import teetime.framework.pipe.IPipeFactory;
import teetime.framework.pipe.PipeFactory; import teetime.framework.pipe.PipeFactoryRegistry;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
import teetime.stage.ObjectProducer; import teetime.stage.ObjectProducer;
import teetime.stage.PortTypeConfiguration; import teetime.stage.PortTypeConfiguration;
import teetime.stage.StartTimestampFilter; import teetime.stage.StartTimestampFilter;
...@@ -22,7 +22,7 @@ import teetime.util.TimestampObject; ...@@ -22,7 +22,7 @@ import teetime.util.TimestampObject;
public class ConnectionTypeTest { public class ConnectionTypeTest {
private final PipeFactory pipeFactory = PipeFactory.INSTANCE; private final PipeFactoryRegistry pipeFactory = PipeFactoryRegistry.INSTANCE;
// tests for load-time validation // tests for load-time validation
......
...@@ -3,20 +3,21 @@ package teetime.examples.cipher; ...@@ -3,20 +3,21 @@ package teetime.examples.cipher;
import java.io.File; import java.io.File;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisConfiguration;
import teetime.framework.pipe.PipeFactory; import teetime.framework.pipe.PipeFactoryRegistry;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
import teetime.stage.CipherByteArray; import teetime.stage.CipherByteArray;
import teetime.stage.CipherByteArray.CipherMode;
import teetime.stage.InitialElementProducer; import teetime.stage.InitialElementProducer;
import teetime.stage.ZipByteArray; import teetime.stage.ZipByteArray;
import teetime.stage.CipherByteArray.CipherMode;
import teetime.stage.ZipByteArray.ZipMode; 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 AnalysisConfiguration {
private final PipeFactory pipeFactory = PipeFactory.INSTANCE; private static final PipeFactoryRegistry pipeFactoryRegistry = PipeFactoryRegistry.INSTANCE;
private final File input, output; private final File input, output;
private final String password; private final String password;
...@@ -33,17 +34,17 @@ public class CipherConfiguration extends AnalysisConfiguration { ...@@ -33,17 +34,17 @@ public class CipherConfiguration extends AnalysisConfiguration {
CipherByteArray decrypt = new CipherByteArray(this.password, CipherMode.DECRYPT); CipherByteArray decrypt = new CipherByteArray(this.password, CipherMode.DECRYPT);
ByteArrayFileWriter writer = new ByteArrayFileWriter(output); ByteArrayFileWriter writer = new ByteArrayFileWriter(output);
this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
.create(init.getOutputPort(), f2b.getInputPort()); .create(init.getOutputPort(), f2b.getInputPort());
this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
.create(f2b.getOutputPort(), enc.getInputPort()); .create(f2b.getOutputPort(), enc.getInputPort());
this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
.create(enc.getOutputPort(), comp.getInputPort()); .create(enc.getOutputPort(), comp.getInputPort());
this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
.create(comp.getOutputPort(), decomp.getInputPort()); .create(comp.getOutputPort(), decomp.getInputPort());
this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
.create(decomp.getOutputPort(), decrypt.getInputPort()); .create(decomp.getOutputPort(), decrypt.getInputPort());
this.pipeFactory.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false) pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false)
.create(decrypt.getOutputPort(), writer.getInputPort()); .create(decrypt.getOutputPort(), writer.getInputPort());
this.getFiniteProducerStages().add(init); this.getFiniteProducerStages().add(init);
......
...@@ -13,21 +13,17 @@ import com.google.common.io.Files; ...@@ -13,21 +13,17 @@ import com.google.common.io.Files;
public class CipherTest { public class CipherTest {
static String inputFile = "src/test/resources/data/input.txt";
static String outputFile = "src/test/resources/data/output.txt";
static String password = "Password";
static long start;
long stop;
static AnalysisConfiguration configuration = new CipherConfiguration(inputFile, outputFile, password);
final static Analysis analysis = new Analysis(configuration);
@Test @Test
public void executeTest() throws IOException { public void executeTest() throws IOException {
final String inputFile = "src/test/resources/data/input.txt";
final String outputFile = "src/test/resources/data/output.txt";
final String password = "Password";
AnalysisConfiguration configuration = new CipherConfiguration(inputFile, outputFile, password);
Analysis analysis = new Analysis(configuration);
analysis.init(); analysis.init();
start = System.currentTimeMillis();
analysis.start(); analysis.start();
Assert.assertTrue(Files.equal(new File(inputFile), new File(outputFile))); Assert.assertTrue(Files.equal(new File(inputFile), new File(outputFile)));
} }
......
...@@ -3,9 +3,9 @@ package teetime.examples.tokenizer; ...@@ -3,9 +3,9 @@ package teetime.examples.tokenizer;
import java.io.File; import java.io.File;
import teetime.framework.AnalysisConfiguration; import teetime.framework.AnalysisConfiguration;
import teetime.framework.pipe.PipeFactory; import teetime.framework.pipe.PipeFactoryRegistry;
import teetime.framework.pipe.PipeFactory.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering;
import teetime.framework.pipe.PipeFactory.ThreadCommunication; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication;
import teetime.stage.ByteArray2String; import teetime.stage.ByteArray2String;
import teetime.stage.CipherByteArray; import teetime.stage.CipherByteArray;
import teetime.stage.CipherByteArray.CipherMode; import teetime.stage.CipherByteArray.CipherMode;
...@@ -18,7 +18,7 @@ import teetime.stage.io.File2ByteArray; ...@@ -18,7 +18,7 @@ import teetime.stage.io.File2ByteArray;
public class TokenizerConfiguration extends AnalysisConfiguration { public class TokenizerConfiguration extends AnalysisConfiguration {
private final PipeFactory pipeFactory = PipeFactory.INSTANCE; private final PipeFactoryRegistry pipeFactory = PipeFactoryRegistry.INSTANCE;
private final File input; private final File input;
private final String password; private final String password;
private final TokenCounter counter; private final TokenCounter counter;
......
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