From 3f4b129996d9b3f77674d1966cc80469c5bb4999 Mon Sep 17 00:00:00 2001 From: Nelson Tavares de Sousa <stu103017@mail.uni-kiel.de> Date: Tue, 16 Jun 2015 10:51:39 +0200 Subject: [PATCH] finished new instatiation method and removed obsolete class --- src/main/java/teetime/framework/Analysis.java | 17 ++-- .../framework/AnalysisConfiguration.java | 12 --- src/main/java/teetime/util/Connection.java | 87 ------------------- 3 files changed, 6 insertions(+), 110 deletions(-) delete mode 100644 src/main/java/teetime/util/Connection.java diff --git a/src/main/java/teetime/framework/Analysis.java b/src/main/java/teetime/framework/Analysis.java index d4343a97..f8a141b6 100644 --- a/src/main/java/teetime/framework/Analysis.java +++ b/src/main/java/teetime/framework/Analysis.java @@ -38,7 +38,6 @@ import teetime.framework.pipe.UnboundedSpScPipeFactory; import teetime.framework.signal.InitializingSignal; import teetime.framework.signal.ValidatingSignal; import teetime.framework.validation.AnalysisNotValidException; -import teetime.util.Connection; import teetime.util.Pair; /** @@ -198,22 +197,18 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught Set<Stage> threadableStageJobs = configuration.getThreadableStageJobs(); for (Stage threadableStage : threadableStageJobs) { i++; - colors.put(threadableStage, i); // Markiere den threadHead + colors.put(threadableStage, i); colorAndConnectStages(i, colors, threadableStage); } - // if (configuration.getConnections().size() != createdConnections) { - // throw new IllegalStateException("Remaining " + (configuration.getConnections().size() - createdConnections) + " connection(s)"); - // } + LOGGER.debug("Created " + createdConnections + "connections"); } public void colorAndConnectStages(final Integer i, final Map<Stage, Integer> colors, final Stage threadableStage) { Set<Stage> threadableStageJobs = configuration.getThreadableStageJobs(); for (OutputPort outputPort : threadableStage.getOutputPorts()) { if (outputPort.pipe != null) { - InstantiationPipe pipe; if (outputPort.pipe instanceof InstantiationPipe) { - pipe = (InstantiationPipe) outputPort.pipe; - Connection connection = new Connection(outputPort, pipe.getTargetPort(), pipe.getCapacity()); + InstantiationPipe pipe = (InstantiationPipe) outputPort.pipe; Stage targetStage = pipe.getTargetPort().getOwningStage(); Integer targetColor = new Integer(0); if (colors.containsKey(targetStage)) { @@ -221,9 +216,9 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught } if (threadableStageJobs.contains(targetStage) && targetColor.compareTo(i) != 0) { if (pipe.getCapacity() != 0) { - interBoundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), connection.getCapacity()); + interBoundedThreadPipeFactory.create(outputPort, pipe.getTarget(), pipe.getCapacity()); } else { - interUnboundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), 4); + interUnboundedThreadPipeFactory.create(outputPort, pipe.getTarget(), 4); } } else { if (colors.containsKey(targetStage)) { @@ -231,7 +226,7 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught throw new IllegalStateException("Crossing threads"); // One stage is connected to a stage of another thread (but not its "headstage") } } - intraThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort()); + intraThreadPipeFactory.create(outputPort, pipe.getTarget()); colors.put(targetStage, i); colorAndConnectStages(i, colors, targetStage); } diff --git a/src/main/java/teetime/framework/AnalysisConfiguration.java b/src/main/java/teetime/framework/AnalysisConfiguration.java index 7b91b583..8d80d14b 100644 --- a/src/main/java/teetime/framework/AnalysisConfiguration.java +++ b/src/main/java/teetime/framework/AnalysisConfiguration.java @@ -24,7 +24,6 @@ import teetime.framework.pipe.InstantiationPipe; import teetime.framework.pipe.PipeFactoryRegistry; import teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering; import teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication; -import teetime.util.Connection; /** * Represents a configuration of connected stages, which is needed to run a analysis. @@ -33,7 +32,6 @@ import teetime.util.Connection; public abstract class AnalysisConfiguration { private final Set<Stage> threadableStageJobs = new HashSet<Stage>(); - private final Set<Connection<?>> connections = new HashSet<Connection<?>>(); @SuppressWarnings("deprecation") private static final PipeFactoryRegistry PIPE_FACTORY_REGISTRY = PipeFactoryRegistry.INSTANCE; @@ -73,7 +71,6 @@ public abstract class AnalysisConfiguration { */ protected void addThreadableStage(final AbstractCompositeStage stage) { this.threadableStageJobs.add(stage.getFirstStage()); - this.connections.addAll(stage.getConnections()); for (Stage threadableStage : stage.getThreadableStageJobs()) { this.addThreadableStage(threadableStage); } @@ -183,13 +180,4 @@ public abstract class AnalysisConfiguration { // connections.add(new Connection<T>(sourcePort, targetPort, capacity)); } - /** - * Returns a list of pairs, which describe the connections among all stages. - * - * @return a list of pairs of Out- and InputPorts, which are connected - */ - protected Set<Connection<?>> getConnections() { - return connections; - } - } diff --git a/src/main/java/teetime/util/Connection.java b/src/main/java/teetime/util/Connection.java deleted file mode 100644 index f110c3da..00000000 --- a/src/main/java/teetime/util/Connection.java +++ /dev/null @@ -1,87 +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.util; - -import teetime.framework.InputPort; -import teetime.framework.OutputPort; - -public class Connection<T> { - - private final OutputPort<? extends T> sourcePort; - private final InputPort<T> targetPort; - private final int capacity; - - public Connection(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) { - this(sourcePort, targetPort, 4); - } - - public Connection(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) { - this.sourcePort = sourcePort; - this.targetPort = targetPort; - this.capacity = capacity; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((sourcePort == null) ? 0 : sourcePort.hashCode()); - result = prime * result + ((targetPort == null) ? 0 : targetPort.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Connection<?> other = (Connection<?>) obj; - if (sourcePort == null) { - if (other.sourcePort != null) { - return false; - } - } else if (!sourcePort.equals(other.sourcePort)) { - return false; - } - if (targetPort == null) { - if (other.targetPort != null) { - return false; - } - } else if (!targetPort.equals(other.targetPort)) { - return false; - } - return true; - } - - public int getCapacity() { - return capacity; - } - - public OutputPort<? extends T> getSourcePort() { - return sourcePort; - } - - public InputPort<T> getTargetPort() { - return targetPort; - } - -} -- GitLab