mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-15 06:49:56 +00:00
launch MarkPassingCalculator initialization synchronously during test execution
Change-Id: I1b336553fc8b9cf86a935944cf889211e81d7169
This commit is contained in:
1 parent
5d3314d033
commit
e2d41eeb9c
4 files changed
+16
-7
No files matched your search
+1
-1
@@ -123,7 +123,7 @@ public abstract class AbstractMarkPassingTest extends OnlineTracTracBasedTest {
|
||||
Map<Competitor, Map<Waypoint, MarkPassing>> computedPasses = new HashMap<>();
|
||||
// Get calculatedMarkPasses
|
||||
long time = System.currentTimeMillis();
|
||||
new MarkPassingCalculator(getTrackedRace(), false);
|
||||
new MarkPassingCalculator(getTrackedRace(), false, /* waitForInitialMarkPassingCalculation */ true);
|
||||
time = System.currentTimeMillis() - time;
|
||||
|
||||
for (Competitor c : getRace().getCompetitors()) {
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class StarIDM2013MarkPassingTest extends AbstractMarkPassingTest {
|
||||
}
|
||||
|
||||
private void testWholeRace5() throws InvalidDateException {
|
||||
new MarkPassingCalculator(getTrackedRace(), false); // do our calculation, injecting into TrackedRace
|
||||
new MarkPassingCalculator(getTrackedRace(), false, /* waitForInitialMarkPassingCalculation */ true); // do our calculation, injecting into TrackedRace
|
||||
final Competitor GER7897 = getCompetitorByName("Tusch, Frank,Winkelmann, Sven");
|
||||
assertMarkPassing(GER7897, Util.get(getWaypoints(), 0), DateParser.parse("2013-05-04T14:50:10+0200"));
|
||||
assertMarkPassing(GER7897, Util.get(getWaypoints(), 1), DateParser.parse("2013-05-04T14:57:12+0200"));
|
||||
|
||||
+9
-4
@@ -34,7 +34,7 @@ import com.sap.sse.util.impl.ThreadFactoryWithPriority;
|
||||
* Calculates the {@link MarkPassing}s for a {@link DynamicTrackedRace} using an {@link CandidateFinder} and an
|
||||
* {@link CandidateChooser}. The finder evaluates the fixes and finds possible MarkPassings as {@link Candidate}s . The
|
||||
* chooser than finds the most likely sequence of {@link Candidate}s and updates the race with new {@link MarkPassing}s
|
||||
* for this sequence. Upon calling the constructor {@link #MarkPassingCalculator(DynamicTrackedRace, boolean)} this
|
||||
* for this sequence. Upon calling the constructor {@link #MarkPassingCalculator(DynamicTrackedRace, boolean, boolean)} this
|
||||
* happens for the current state of the race. In addition, for live races, the <code>listen</code> parameter of the
|
||||
* constructor should be true. Then a {@link MarkPassingUpdateListener} is initialized which puts new fixes into a queue
|
||||
* as {@link StorePositionUpdateStrategy}. A new thread will also be started to evaluate the new fixes (See
|
||||
@@ -58,7 +58,7 @@ public class MarkPassingCalculator {
|
||||
|
||||
private boolean suspended = false;
|
||||
|
||||
public MarkPassingCalculator(DynamicTrackedRace race, boolean listen) {
|
||||
public MarkPassingCalculator(DynamicTrackedRace race, boolean listen, boolean waitForInitialMarkPassingCalculation) {
|
||||
if (listen) {
|
||||
listener = new MarkPassingUpdateListener(race);
|
||||
} else {
|
||||
@@ -67,7 +67,7 @@ public class MarkPassingCalculator {
|
||||
this.race = race;
|
||||
finder = new CandidateFinderImpl(race);
|
||||
chooser = new CandidateChooserImpl(race);
|
||||
new Thread(() -> {
|
||||
Thread t = new Thread(() -> {
|
||||
for (Competitor c : race.getRace().getCompetitors()) {
|
||||
Util.Pair<Iterable<Candidate>, Iterable<Candidate>> allCandidates = finder.getAllCandidates(c);
|
||||
chooser.calculateMarkPassDeltas(c, allCandidates.getA(), allCandidates.getB());
|
||||
@@ -77,7 +77,12 @@ public class MarkPassingCalculator {
|
||||
listenerThread.setDaemon(true);
|
||||
listenerThread.start();
|
||||
}
|
||||
}, "MarkPassingCalculator for race "+race.getRace().getName()+" initialization").start();
|
||||
}, "MarkPassingCalculator for race "+race.getRace().getName()+" initialization");
|
||||
if (waitForInitialMarkPassingCalculation) {
|
||||
t.run();
|
||||
} else {
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+5
-1
@@ -1016,7 +1016,11 @@ DynamicTrackedRace, GPSTrackListener<Competitor, GPSFixMoving> {
|
||||
|
||||
@Override
|
||||
protected MarkPassingCalculator createMarkPassingCalculator() {
|
||||
return new MarkPassingCalculator(this, true);
|
||||
// not waiting for initial mark passing creation is essential for not holding up, e.g.,
|
||||
// an initial load during replication where it is perfectly fine to obtain the results from
|
||||
// mark passing analysis as they become available; for test cases, however, "true" would
|
||||
// be a more appropriate choice
|
||||
return new MarkPassingCalculator(this, true, /* waitForInitialMarkPassingCalculation */ false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user