Skip to content

Commit

Permalink
Add offset to Dummy knowledge publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
vladamatena committed Mar 13, 2015
1 parent 5e51ac5 commit 207624d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;

import cz.cuni.mff.d3s.deeco.DeecoProperties;
import cz.cuni.mff.d3s.deeco.knowledge.KnowledgeManager;
Expand Down Expand Up @@ -44,6 +45,9 @@ public class DummyKnowledgePublisher implements DEECoPlugin, TimerTaskListener {
private CurrentTimeProvider timeProvider;
private DEECoContainer container;
private List<IPAddress> infrastructurePeers;

private final static long PUBLISH_PERIOD = Integer.getInteger(DeecoProperties.PUBLISHING_PERIOD,
PublisherTask.DEFAULT_PUBLISHING_PERIOD);

@Override
public List<Class<? extends DEECoPlugin>> getDependencies() {
Expand Down Expand Up @@ -135,8 +139,7 @@ public void at(long time, Object triger) {
}

Scheduler scheduler = container.getRuntimeFramework().getScheduler();
scheduler.addTask(new CustomStepTask(scheduler, this, Integer.getInteger(DeecoProperties.PUBLISHING_PERIOD,
PublisherTask.DEFAULT_PUBLISHING_PERIOD)));
scheduler.addTask(new CustomStepTask(scheduler, this, PUBLISH_PERIOD));
}

@Override
Expand All @@ -163,6 +166,7 @@ public void init(DEECoContainer container) {

// Start publishing task
Scheduler scheduler = container.getRuntimeFramework().getScheduler();
scheduler.addTask(new CustomStepTask(scheduler, this));
long offset = new Random(container.getId()).nextInt((int) PUBLISH_PERIOD);
scheduler.addTask(new CustomStepTask(scheduler, this, offset));
}
}

0 comments on commit 207624d

Please sign in to comment.