diff --git a/java/com.sap.sse.datamining.test/src/com/sap/sse/datamining/test/components/util/BlockingInstructionWrapper.java b/java/com.sap.sse.datamining.test/src/com/sap/sse/datamining/test/components/util/BlockingInstructionWrapper.java new file mode 100644 index 00000000000..ea1829a3226 --- /dev/null +++ b/java/com.sap.sse.datamining.test/src/com/sap/sse/datamining/test/components/util/BlockingInstructionWrapper.java @@ -0,0 +1,31 @@ +package com.sap.sse.datamining.test.components.util; + +import com.sap.sse.datamining.test.util.ConcurrencyTestsUtil; + +public class BlockingInstructionWrapper implements Runnable { + + private Runnable innerInstruction; + + private boolean workIsInProgress; + + public BlockingInstructionWrapper(Runnable innerInstruction) { + this.innerInstruction = innerInstruction; + workIsInProgress = true; + } + + @Override + public void run() { + while (workIsInProgress) { + ConcurrencyTestsUtil.sleepFor(100); + } + innerInstruction.run(); + } + + /** + * Tells the instruction, that the work is now done. It won't block it's inner instruction anymore and calls the run method of it. + */ + public void workIsNowFinished() { + workIsInProgress = false; + } + +} diff --git a/java/com.sap.sse.datamining.test/src/com/sap/sse/datamining/test/components/util/Number.java b/java/com.sap.sse.datamining.test/src/com/sap/sse/datamining/test/components/util/Number.java index 6b983f5abe0..fc25ca7fce0 100644 --- a/java/com.sap.sse.datamining.test/src/com/sap/sse/datamining/test/components/util/Number.java +++ b/java/com.sap.sse.datamining.test/src/com/sap/sse/datamining/test/components/util/Number.java @@ -23,6 +23,7 @@ public class Number { @Dimension("crossSum") public int getCrossSum() { int crossSum = 0; + int value = this.value; while (value != 0) { crossSum += value % 10; value /= 10; @@ -30,4 +31,9 @@ public class Number { return crossSum; } + @Override + public String toString() { + return "Number " + value; + } + } diff --git a/java/com.sap.sse.datamining/src/com/sap/sse/datamining/impl/components/AbstractDirectForwardProcessingInstruction.java b/java/com.sap.sse.datamining/src/com/sap/sse/datamining/impl/components/AbstractDirectForwardProcessingInstruction.java index d9f407b807e..6fdc0b29436 100644 --- a/java/com.sap.sse.datamining/src/com/sap/sse/datamining/impl/components/AbstractDirectForwardProcessingInstruction.java +++ b/java/com.sap.sse.datamining/src/com/sap/sse/datamining/impl/components/AbstractDirectForwardProcessingInstruction.java @@ -6,34 +6,32 @@ import com.sap.sse.datamining.components.ProcessingInstruction; import com.sap.sse.datamining.components.Processor; /** - * A processing construction, that processes the input and directly forwards - * it to the result receivers. + * A processing construction, that processes the input and directly forwards it to the result receivers. */ -public abstract class AbstractDirectForwardProcessingInstruction - implements ProcessingInstruction { - - private final InputType input; - private ResultType result; - private final Collection> resultReceivers; +public abstract class AbstractDirectForwardProcessingInstruction implements + ProcessingInstruction { - public AbstractDirectForwardProcessingInstruction(InputType input, Collection> resultReceivers) { - this.input = input; - this.resultReceivers = resultReceivers; - } + private final InputType input; + private ResultType result; + private final Collection> resultReceivers; - @Override - public void run() { - result = processInput(input); - forwardResult(); - } + public AbstractDirectForwardProcessingInstruction(InputType input, Collection> resultReceivers) { + this.input = input; + this.resultReceivers = resultReceivers; + } - private void forwardResult() { - for (Processor resultReceiver : resultReceivers) { - resultReceiver.onElement(result); - } - } + @Override + public void run() { + result = processInput(input); + forwardResult(); + } - protected abstract ResultType processInput(InputType input); + private void forwardResult() { + for (Processor resultReceiver : resultReceivers) { + resultReceiver.onElement(result); + } + } + + protected abstract ResultType processInput(InputType input); - } diff --git a/java/com.sap.sse.datamining/src/com/sap/sse/datamining/impl/components/AbstractPartitioningParallelProcessor.java b/java/com.sap.sse.datamining/src/com/sap/sse/datamining/impl/components/AbstractPartitioningParallelProcessor.java index 8a773494762..1aab4306641 100644 --- a/java/com.sap.sse.datamining/src/com/sap/sse/datamining/impl/components/AbstractPartitioningParallelProcessor.java +++ b/java/com.sap.sse.datamining/src/com/sap/sse/datamining/impl/components/AbstractPartitioningParallelProcessor.java @@ -30,7 +30,6 @@ public abstract class AbstractPartitioningParallelProcessor> getResultReceivers() { return resultReceivers; } @@ -80,12 +75,13 @@ public abstract class AbstractPartitioningParallelProcessor { return dataEntry; } + @Override + public String toString() { + return "[" + key + ", " + dataEntry + "]"; + } + }