Commit ba5d1ecc authored by Christian Wulf's avatar Christian Wulf

added TaskFarmSchedulerImpl

parent 6d605218
package teetime.stage.taskfarm;
import teetime.framework.AbstractStage;
import teetime.framework.TeeTimeService;
public class TaskFarmSchedulerImpl implements TaskFarmScheduler {
private final TeeTimeService scheduler;
/** makes changes to the unsynchronized variable {@link AbstractStage#isActive} visible to other threads */
private volatile boolean memoryBarrier;
public TaskFarmSchedulerImpl(final TeeTimeService scheduler) {
this.scheduler = scheduler;
}
@Override
public void declareActive(final AbstractStage stage) {
stage.declareActive();
memoryBarrier = true;
}
@Override
public void declarePassive(final AbstractStage stage) {
stage.declarePassive();
memoryBarrier = true;
}
@Override
public boolean isActive(final AbstractStage stage) {
memoryBarrier = stage.isActive();
return memoryBarrier;
}
}
......@@ -23,6 +23,8 @@ import org.junit.Test;
import teetime.framework.Configuration;
import teetime.framework.Execution;
import teetime.framework.TeeTimeService;
import teetime.framework.scheduling.pushpullmodel.PushPullScheduling;
import teetime.stage.CollectorSink;
import teetime.stage.Counter;
......@@ -38,8 +40,6 @@ public class DynamicTaskFarmStageTest {
new Counter<Integer>(), 1);
final CollectorSink<Integer> collectorSink = new CollectorSink<Integer>();
dynamicTaskFarmStage.getConfiguration().setScheduler(scheduler);
Configuration configuration = new Configuration() {
{
connectPorts(producer.getOutputPort(), dynamicTaskFarmStage.getInputPort());
......@@ -47,7 +47,10 @@ public class DynamicTaskFarmStageTest {
}
};
Execution<Configuration> execution = new Execution<Configuration>(configuration);
TeeTimeService scheduler = new PushPullScheduling(configuration);
dynamicTaskFarmStage.getConfiguration().setScheduler(new TaskFarmSchedulerImpl(scheduler));
Execution<Configuration> execution = new Execution<Configuration>(configuration, true, scheduler);
execution.executeNonBlocking();
producer.trigger();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment