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

changed package structure for distributor and merger

parent a7134823
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 26 deletions
......@@ -31,11 +31,11 @@ public abstract class AbstractPort<T> {
protected IPipe pipe;
public AbstractPort(final Class<T> type, final Stage owningStage, final String name) {
protected AbstractPort(final Class<T> type, final Stage owningStage, final String name) {
super();
this.type = type;
this.owningStage = owningStage;
this.name = (name != null) ? name : super.toString();
this.name = name;
}
public Class<T> getType() {
......@@ -56,6 +56,6 @@ public abstract class AbstractPort<T> {
@Override
public String toString() {
return name;
return (name != null) ? name : super.toString();
}
}
......@@ -17,6 +17,8 @@ package teetime.stage.basic.distributor;
import teetime.framework.AbstractConsumerStage;
import teetime.framework.OutputPort;
import teetime.stage.basic.distributor.strategy.IDistributorStrategy;
import teetime.stage.basic.distributor.strategy.RoundRobinStrategy2;
/**
* @author Christian Wulf
......
......@@ -8,8 +8,8 @@ import teetime.framework.OutputPortRemovedListener;
import teetime.framework.Stage;
import teetime.framework.signal.TerminatingSignal;
import teetime.stage.basic.distributor.Distributor;
import teetime.stage.basic.distributor.IDistributorStrategy;
import teetime.stage.basic.distributor.RoundRobinStrategy2;
import teetime.stage.basic.distributor.strategy.IDistributorStrategy;
import teetime.stage.basic.distributor.strategy.RoundRobinStrategy2;
import teetime.util.framework.port.PortAction;
import teetime.util.framework.port.PortActionHelper;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package teetime.stage.basic.distributor;
package teetime.stage.basic.distributor.strategy;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
......@@ -57,13 +57,11 @@ public final class CloneStrategy implements IDistributorStrategy {
return newInstance;
} catch (InstantiationException e) {
throw new UnsupportedOperationException();
throw new IllegalStateException(e);
} catch (IllegalAccessException e) {
throw new UnsupportedOperationException();
} catch (IllegalArgumentException e) {
throw new UnsupportedOperationException();
throw new IllegalStateException(e);
} catch (InvocationTargetException e) {
throw new UnsupportedOperationException();
throw new IllegalStateException(e);
}
}
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package teetime.stage.basic.distributor;
package teetime.stage.basic.distributor.strategy;
import teetime.framework.OutputPort;
import teetime.framework.Stage;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package teetime.stage.basic.distributor;
package teetime.stage.basic.distributor.strategy;
import teetime.framework.OutputPort;
import teetime.framework.OutputPortRemovedListener;
......
......@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package teetime.stage.basic.distributor;
package teetime.stage.basic.distributor.strategy;
import teetime.framework.OutputPort;
import teetime.framework.Stage;
import teetime.stage.basic.distributor.Distributor;
/**
* @author Nils Christian Ehmke
......
......@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package teetime.stage.basic.distributor;
package teetime.stage.basic.distributor.strategy;
import teetime.framework.OutputPort;
import teetime.framework.Stage;
import teetime.stage.basic.distributor.Distributor;
/**
* @author Christian Wulf
......
......@@ -25,6 +25,8 @@ import teetime.framework.DynamicInputPort;
import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.signal.ISignal;
import teetime.stage.basic.merger.strategy.IMergerStrategy;
import teetime.stage.basic.merger.strategy.RoundRobinStrategy;
/**
*
......
......@@ -3,8 +3,8 @@ package teetime.stage.basic.merger.dynamic;
import java.util.concurrent.BlockingQueue;
import teetime.framework.DynamicInputPort;
import teetime.stage.basic.merger.IMergerStrategy;
import teetime.stage.basic.merger.Merger;
import teetime.stage.basic.merger.strategy.IMergerStrategy;
import teetime.util.framework.port.PortAction;
import teetime.util.framework.port.PortActionHelper;
......
......@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package teetime.stage.basic.merger;
package teetime.stage.basic.merger.strategy;
import teetime.framework.InputPort;
import teetime.framework.Stage;
import teetime.stage.basic.merger.Merger;
/**
* @author Christian Wulf
......
......@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package teetime.stage.basic.merger;
package teetime.stage.basic.merger.strategy;
import teetime.framework.InputPortRemovedListener;
import teetime.stage.basic.merger.Merger;
/**
* @author Nils Christian Ehmke
......
......@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package teetime.stage.basic.merger;
package teetime.stage.basic.merger.strategy;
import teetime.framework.InputPort;
import teetime.framework.Stage;
import teetime.stage.basic.merger.Merger;
/**
* @author Nils Christian Ehmke
......
......@@ -24,8 +24,8 @@ import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.Stage;
import teetime.stage.EveryXthStage;
import teetime.stage.basic.distributor.CopyByReferenceStrategy;
import teetime.stage.basic.distributor.Distributor;
import teetime.stage.basic.distributor.strategy.CopyByReferenceStrategy;
public final class EveryXthPrinter<T> extends AbstractCompositeStage {
......
......@@ -29,7 +29,7 @@ import org.junit.Test;
import teetime.stage.CountingMapMerger;
import teetime.stage.InitialElementProducer;
import teetime.stage.basic.distributor.Distributor;
import teetime.stage.basic.distributor.RoundRobinStrategy2;
import teetime.stage.basic.distributor.strategy.RoundRobinStrategy2;
import teetime.stage.basic.merger.Merger;
import teetime.stage.io.File2SeqOfWords;
import teetime.stage.string.WordCounter;
......
......@@ -30,6 +30,11 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import teetime.stage.basic.distributor.strategy.CloneStrategy;
import teetime.stage.basic.distributor.strategy.CopyByReferenceStrategy;
import teetime.stage.basic.distributor.strategy.RoundRobinStrategy;
import teetime.stage.basic.distributor.strategy.RoundRobinStrategy2;
/**
* @author Nils Christian Ehmke
*
......@@ -136,19 +141,23 @@ public class DistributorTest {
final List<SimpleBean> results = new ArrayList<SimpleBean>();
final SimpleBean originalBean = new SimpleBean(42);
test(distributor).and().send(originalBean).to(distributor.getInputPort()).and().receive(results).from(distributor.getNewOutputPort()).start();
test(distributor).and()
.send(originalBean).to(distributor.getInputPort()).and()
.receive(results).from(distributor.getNewOutputPort()).start();
final SimpleBean clonedBean = results.get(0);
assertThat(originalBean, is(not(clonedBean)));
assertThat(originalBean.getValue(), is(clonedBean.getValue()));
}
private static class SimpleBean {
// set to "public" to instantiate it via reflection
public static class SimpleBean {
private int value;
@SuppressWarnings("unused")
public SimpleBean() {}
public SimpleBean() {
// necessary to instantiate it via reflection
}
public SimpleBean(final int value) {
this.setValue(value);
......
......@@ -25,6 +25,8 @@ import java.util.List;
import org.junit.Test;
import teetime.stage.basic.merger.strategy.RoundRobinStrategy;
/**
* @author Nils Christian Ehmke
*
......
......@@ -16,7 +16,7 @@ import teetime.framework.RunnableProducerStage;
import teetime.framework.exceptionHandling.TerminatingExceptionListenerFactory;
import teetime.stage.CollectorSink;
import teetime.stage.InitialElementProducer;
import teetime.stage.basic.merger.BusyWaitingRoundRobinStrategy;
import teetime.stage.basic.merger.strategy.BusyWaitingRoundRobinStrategy;
import teetime.util.framework.port.PortAction;
public class DynamicMergerTest {
......
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