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

fixed bug, which didn't pass on signals if there is a 1:1 relation

parent dd4038d3
No related branches found
No related tags found
No related merge requests found
......@@ -74,9 +74,10 @@ public final class Merger<T> extends AbstractStage {
* @param inputPort
* The port which the signal was sent to
*/
@SuppressWarnings("unchecked")
@Override
public void onSignal(final ISignal signal, final InputPort<?> inputPort) {
this.logger.trace("Got signal: " + signal + " from input port: " + inputPort);
this.logger.info("Got signal: " + signal + " from input port: " + inputPort);
if (signalMap.containsKey(signal.getClass())) {
Set<InputPort<?>> set = signalMap.get(signal.getClass());
......@@ -84,17 +85,19 @@ public final class Merger<T> extends AbstractStage {
this.logger.warn("Received more than one signal - " + signal + " - from input port: " + inputPort);
}
if (set.size() == this.getInputPorts().length) {
signal.trigger(this);
this.outputPort.sendSignal(signal);
signalMap.remove(signal.getClass());
}
} else {
Set<InputPort<?>> tempSet = new HashSet<InputPort<?>>();
tempSet.add(inputPort);
signalMap.put((Class<ISignal>) signal.getClass(), tempSet);
}
if (signalMap.get(signal.getClass()).size() == this.getInputPorts().length) {
System.out.println("SENT");
signal.trigger(this);
this.outputPort.sendSignal(signal);
signalMap.remove(signal.getClass());
}
}
public IMergerStrategy getMergerStrategy() {
......
......@@ -38,7 +38,7 @@ public class WordCountingTest {
@Test
public void test1() throws IOException {
int threads = 2;
int threads = 1;
WordCountingConfiguration wcc = new WordCountingConfiguration(threads, testFile, testFile);
Analysis analysis = new Analysis(wcc);
analysis.start();
......
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