From ca4eb37b2639981e3a450f9def72b827287c25b9 Mon Sep 17 00:00:00 2001 From: Christian Wulf <chw@informatik.uni-kiel.de> Date: Sun, 31 Aug 2014 22:40:58 +0200 Subject: [PATCH] made PipeFactory singleton --- .../framework/core/ProducerStage.java | 4 ---- .../framework/core/pipe/PipeFactory.java | 4 +++- .../stage/kieker/Dir2RecordsFilter.java | 2 +- .../experiment14/MethodCallThroughputAnalysis14.java | 12 ++++++------ .../experiment17/MethodCallThroughputAnalysis17.java | 2 +- .../recordReader/RecordReaderConfiguration.java | 6 +----- .../runtime/typeCheck/ConnectionTypeTest.java | 10 +++++----- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/main/java/teetime/variant/methodcallWithPorts/framework/core/ProducerStage.java b/src/main/java/teetime/variant/methodcallWithPorts/framework/core/ProducerStage.java index 37f95fac..48cb06fb 100644 --- a/src/main/java/teetime/variant/methodcallWithPorts/framework/core/ProducerStage.java +++ b/src/main/java/teetime/variant/methodcallWithPorts/framework/core/ProducerStage.java @@ -3,10 +3,6 @@ package teetime.variant.methodcallWithPorts.framework.core; /** * The <code>ProducerStage</code> produces at least one element at each execution.<br> * - * @reschedulability - * This stage is executed as long as its execute() method decided to do so.<br> - * Refer to {@link AbstractStage#isReschedulable} for more information. - * * @author Christian Wulf * * @param <O> diff --git a/src/main/java/teetime/variant/methodcallWithPorts/framework/core/pipe/PipeFactory.java b/src/main/java/teetime/variant/methodcallWithPorts/framework/core/pipe/PipeFactory.java index a68dbb2b..5a8177a7 100644 --- a/src/main/java/teetime/variant/methodcallWithPorts/framework/core/pipe/PipeFactory.java +++ b/src/main/java/teetime/variant/methodcallWithPorts/framework/core/pipe/PipeFactory.java @@ -30,7 +30,9 @@ public class PipeFactory { private final Map<String, IPipeFactory> pipeFactories = new HashMap<String, IPipeFactory>(); - public PipeFactory() { + public static PipeFactory INSTANCE = new PipeFactory(); + + private PipeFactory() { try { List<IPipeFactory> pipeFactories = PipeFactoryLoader.loadFromFile("conf/pipe-factories.conf"); for (IPipeFactory pipeFactory : pipeFactories) { diff --git a/src/main/java/teetime/variant/methodcallWithPorts/stage/kieker/Dir2RecordsFilter.java b/src/main/java/teetime/variant/methodcallWithPorts/stage/kieker/Dir2RecordsFilter.java index d6759a26..df94500c 100644 --- a/src/main/java/teetime/variant/methodcallWithPorts/stage/kieker/Dir2RecordsFilter.java +++ b/src/main/java/teetime/variant/methodcallWithPorts/stage/kieker/Dir2RecordsFilter.java @@ -45,7 +45,7 @@ import kieker.common.util.filesystem.FSUtil; */ public class Dir2RecordsFilter extends Pipeline<ClassNameRegistryCreationFilter, Merger<IMonitoringRecord>> { - private final PipeFactory pipeFactory = new PipeFactory(); + private final PipeFactory pipeFactory = PipeFactory.INSTANCE; private ClassNameRegistryRepository classNameRegistryRepository; /** diff --git a/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment14/MethodCallThroughputAnalysis14.java b/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment14/MethodCallThroughputAnalysis14.java index 176e6757..76b3f3c6 100644 --- a/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment14/MethodCallThroughputAnalysis14.java +++ b/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment14/MethodCallThroughputAnalysis14.java @@ -44,6 +44,7 @@ public class MethodCallThroughputAnalysis14 extends Analysis { private int numNoopFilters; private List<TimestampObject> timestampObjects; private Runnable runnable; + private final PipeFactory pipeFactory = PipeFactory.INSTANCE; @Override public void init() { @@ -73,18 +74,17 @@ public class MethodCallThroughputAnalysis14 extends Analysis { pipeline.setFirstStage(objectProducer); pipeline.setLastStage(collectorSink); - PipeFactory pipeFactory = new PipeFactory(); - IPipe<TimestampObject> pipe = pipeFactory.create(ThreadCommunication.INTRA); + IPipe<TimestampObject> pipe = this.pipeFactory.create(ThreadCommunication.INTRA); pipe.connectPorts(objectProducer.getOutputPort(), startTimestampFilter.getInputPort()); - pipe = pipeFactory.create(ThreadCommunication.INTRA); + pipe = this.pipeFactory.create(ThreadCommunication.INTRA); pipe.connectPorts(startTimestampFilter.getOutputPort(), noopFilters[0].getInputPort()); for (int i = 0; i < noopFilters.length - 1; i++) { - pipe = pipeFactory.create(ThreadCommunication.INTRA); + pipe = this.pipeFactory.create(ThreadCommunication.INTRA); pipe.connectPorts(noopFilters[i].getOutputPort(), noopFilters[i + 1].getInputPort()); } - pipe = pipeFactory.create(ThreadCommunication.INTRA); + pipe = this.pipeFactory.create(ThreadCommunication.INTRA); pipe.connectPorts(noopFilters[noopFilters.length - 1].getOutputPort(), stopTimestampFilter.getInputPort()); - pipe = pipeFactory.create(ThreadCommunication.INTRA); + pipe = this.pipeFactory.create(ThreadCommunication.INTRA); pipe.connectPorts(stopTimestampFilter.getOutputPort(), collectorSink.getInputPort()); return pipeline; diff --git a/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment17/MethodCallThroughputAnalysis17.java b/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment17/MethodCallThroughputAnalysis17.java index 7d662b6a..751a9f23 100644 --- a/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment17/MethodCallThroughputAnalysis17.java +++ b/src/test/java/teetime/variant/methodcallWithPorts/examples/experiment17/MethodCallThroughputAnalysis17.java @@ -54,7 +54,7 @@ public class MethodCallThroughputAnalysis17 extends Analysis { private ConstructorClosure<TimestampObject> inputObjectCreator; private int numNoopFilters; - private final PipeFactory pipeFactory = new PipeFactory(); + private final PipeFactory pipeFactory = PipeFactory.INSTANCE; private final List<List<TimestampObject>> timestampObjectsList = new LinkedList<List<TimestampObject>>(); private Thread producerThread; diff --git a/src/test/java/teetime/variant/methodcallWithPorts/examples/recordReader/RecordReaderConfiguration.java b/src/test/java/teetime/variant/methodcallWithPorts/examples/recordReader/RecordReaderConfiguration.java index 57570a8a..f7afedad 100644 --- a/src/test/java/teetime/variant/methodcallWithPorts/examples/recordReader/RecordReaderConfiguration.java +++ b/src/test/java/teetime/variant/methodcallWithPorts/examples/recordReader/RecordReaderConfiguration.java @@ -40,11 +40,7 @@ import kieker.common.record.IMonitoringRecord; public class RecordReaderConfiguration extends Configuration { private final List<IMonitoringRecord> elementCollection = new LinkedList<IMonitoringRecord>(); - private final PipeFactory pipeFactory; - - public RecordReaderConfiguration() { - this.pipeFactory = new PipeFactory(); - } + private final PipeFactory pipeFactory = PipeFactory.INSTANCE; public void buildConfiguration() { HeadPipeline<?, ?> producerPipeline = this.buildProducerPipeline(); diff --git a/src/test/java/teetime/variant/methodcallWithPorts/runtime/typeCheck/ConnectionTypeTest.java b/src/test/java/teetime/variant/methodcallWithPorts/runtime/typeCheck/ConnectionTypeTest.java index bafea6a5..f6472699 100644 --- a/src/test/java/teetime/variant/methodcallWithPorts/runtime/typeCheck/ConnectionTypeTest.java +++ b/src/test/java/teetime/variant/methodcallWithPorts/runtime/typeCheck/ConnectionTypeTest.java @@ -21,6 +21,8 @@ import teetime.variant.methodcallWithPorts.stage.basic.Sink; public class ConnectionTypeTest { + private final PipeFactory pipeFactory = PipeFactory.INSTANCE; + // tests for load-time validation @SuppressWarnings({ "unchecked", "rawtypes" }) @@ -44,13 +46,11 @@ public class ConnectionTypeTest { StopTimestampFilter stopTimestampFilter = StopTimestampFilter.class.newInstance(); Sink sink = Sink.class.newInstance(); - PipeFactory pipeFactory = new PipeFactory(); - - IPipe pipe = pipeFactory.create(ThreadCommunication.INTRA); + IPipe pipe = this.pipeFactory.create(ThreadCommunication.INTRA); pipe.connectPorts(objectProducer.getOutputPort(), startTimestampFilter.getInputPort()); - pipe = pipeFactory.create(ThreadCommunication.INTRA); + pipe = this.pipeFactory.create(ThreadCommunication.INTRA); pipe.connectPorts(startTimestampFilter.getOutputPort(), stopTimestampFilter.getInputPort()); - pipe = pipeFactory.create(ThreadCommunication.INTRA); + pipe = this.pipeFactory.create(ThreadCommunication.INTRA); pipe.connectPorts(stopTimestampFilter.getOutputPort(), sink.getInputPort()); // TypeVariable<Class<ObjectProducer>>[] objectProducerTypeParameters = ObjectProducer.class.getTypeParameters(); -- GitLab