|
2 | 2 |
|
3 | 3 | import byzzbench.simulator.Scenario;
|
4 | 4 | import byzzbench.simulator.config.ByzzBenchConfig;
|
| 5 | +import byzzbench.simulator.scheduler.EventDecision; |
5 | 6 | import byzzbench.simulator.state.ErroredPredicate;
|
6 | 7 | import byzzbench.simulator.transport.Event;
|
7 | 8 | import byzzbench.simulator.transport.messages.MessageWithRound;
|
|
19 | 20 | import java.nio.file.Files;
|
20 | 21 | import java.nio.file.Path;
|
21 | 22 | import java.time.Instant;
|
| 23 | +import java.util.Optional; |
22 | 24 | import java.util.OptionalLong;
|
23 | 25 | import java.util.Set;
|
24 | 26 | import java.util.concurrent.ExecutorService;
|
@@ -128,7 +130,30 @@ public void start() {
|
128 | 130 |
|
129 | 131 | try {
|
130 | 132 | while (true) {
|
131 |
| - this.scenario.getScheduler().scheduleNext(this.scenario); |
| 133 | + Optional<EventDecision> decision = this.scenario.getScheduler().scheduleNext(this.scenario); |
| 134 | + System.out.println("Decision: " + decision); |
| 135 | + |
| 136 | + // if the scheduler did not make a decision, and we're before GST, set GST! |
| 137 | + if (decision.isEmpty() && !this.scenario.getTransport().isGlobalStabilizationTime()) { |
| 138 | + this.scenario.getTransport().globalStabilizationTime(); |
| 139 | + continue; |
| 140 | + } |
| 141 | + |
| 142 | + if (decision.isEmpty()) { |
| 143 | + System.out.println("We're after GST and still no events!!"); |
| 144 | + // print num of events in the scenario |
| 145 | + System.out.println("Number of events in the scenario: " + this.scenario.getSchedule().getEvents().size()); |
| 146 | + // print number of delivered events |
| 147 | + System.out.println("Number of delivered events: " + this.scenario.getTransport().getEventsInState(Event.Status.DELIVERED).size()); |
| 148 | + // print ALL events in the scenario, independent of their status |
| 149 | + System.out.println("All events in the scenario:"); |
| 150 | + this.scenario.getTransport().getEvents().values().forEach(System.out::println); |
| 151 | + // print the event IDs in the schedule |
| 152 | + System.out.println("Event IDs in the schedule:"); |
| 153 | + this.scenario.getSchedule().getEvents().forEach(e -> System.out.println(e.getEventId())); |
| 154 | + this.shouldStop = true; |
| 155 | + break; |
| 156 | + } |
132 | 157 |
|
133 | 158 | long numEvents = this.scenario.getSchedule().getEvents().size();
|
134 | 159 | long terminationSamplingFreq = this.byzzBenchConfig.getScenario().getTermination().getSamplingFrequency();
|
|
0 commit comments