use of teetime.stage.basic.distributor.strategy.BlockingBusyWaitingRoundRobinDistributorStrategy in project TeeTime by teetime-framework.
the class StaticTaskFarmStageTest method testOrderedStaticTaskFarmStageWithMultipleStage.
@Test
public void testOrderedStaticTaskFarmStageWithMultipleStage() throws Exception {
ArrayCreator creator = new ArrayCreator(SEED);
List<Integer> randomNumbers = creator.createFilledList(1024);
TestTuple[] testInputTuples = { // expect in correct order
TestTuple.use(2, randomNumbers).expect(randomNumbers), // expect in correct order
TestTuple.use(3, randomNumbers).expect(randomNumbers) };
for (TestTuple testTuple : testInputTuples) {
StaticTaskFarmStage<Integer, Integer, Counter<Integer>> taskFarmStage = createTaskFarm(testTuple.numWorkerStages);
// ordered element passing
taskFarmStage.getDistributor().setStrategy(new BlockingBusyWaitingRoundRobinDistributorStrategy());
taskFarmStage.getMerger().setStrategy(new BlockingBusyWaitingRoundRobinMergerStrategy());
List<Integer> outputElements = new ArrayList<Integer>();
test(taskFarmStage).and().send(testTuple.inputElements).to(taskFarmStage.getInputPort()).and().receive(outputElements).from(taskFarmStage.getOutputPort()).start();
assertThat(outputElements, contains(testTuple.expectedOutputElements));
}
}
use of teetime.stage.basic.distributor.strategy.BlockingBusyWaitingRoundRobinDistributorStrategy in project TeeTime by teetime-framework.
the class DistributorTest method roundRobinShouldWork.
@Test
public void roundRobinShouldWork() {
distributor.setStrategy(new BlockingBusyWaitingRoundRobinDistributorStrategy());
test(distributor).and().send(1, 2, 3, 4, 5).to(distributor.getInputPort()).and().receive(firstIntegers).from(distributor.getNewOutputPort()).and().receive(secondIntegers).from(distributor.getNewOutputPort()).start();
assertThat(this.firstIntegers, contains(1, 3, 5));
assertThat(this.secondIntegers, contains(2, 4));
}
use of teetime.stage.basic.distributor.strategy.BlockingBusyWaitingRoundRobinDistributorStrategy in project TeeTime by teetime-framework.
the class DistributorTest method singleElementRoundRobinShouldWork.
@Test
public void singleElementRoundRobinShouldWork() {
distributor.setStrategy(new BlockingBusyWaitingRoundRobinDistributorStrategy());
test(distributor).and().send(1).to(distributor.getInputPort()).and().receive(firstIntegers).from(distributor.getNewOutputPort()).and().receive(secondIntegers).from(distributor.getNewOutputPort()).start();
assertThat(this.firstIntegers, contains(1));
assertThat(this.secondIntegers, is(empty()));
}
Aggregations