mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-24 21:13:50 +00:00
started to work on bug 3022, cleaning up the DistanceCache leaking mess
This commit is contained in:
1 parent
f59c519e9a
commit
ec097a63e7
4 files changed
+52
-1
No files matched your search
@@ -53,6 +53,7 @@ import com.sap.sailing.domain.tracking.impl.DynamicGPSFixMovingTrackImpl;
|
||||
import com.sap.sailing.domain.tracking.impl.DynamicGPSFixTrackImpl;
|
||||
import com.sap.sailing.domain.tracking.impl.MaxSpeedCache;
|
||||
import com.sap.sailing.domain.tracking.impl.TrackImpl;
|
||||
import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.TimeRange;
|
||||
import com.sap.sse.common.Timed;
|
||||
@@ -894,6 +895,48 @@ public class TrackTest {
|
||||
assertEquals(toReachInOneThirdOfTimeBetweenFixesInMillis.getMeters(), distance3_new.getMeters()-distance2_new.getMeters(), 0.01);
|
||||
assertEquals(toReachInOneThirdOfTimeBetweenFixesInMillis.getMeters(), distance4_new.getMeters()-distance3_new.getMeters(), 0.01);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug 3022 describes a {@link StackOverflowError} that occurs during distance calculations on a {@link GPSFixTrackImpl}.
|
||||
* This test tries to reproduce this behavior, as a starting point for a fix. The recursion happened while a long-distance
|
||||
* race was running. Can there be a certain fix insertion pattern that, combined with a certain request pattern,
|
||||
* produces degenerated cache contents? The race had a live delay of 660s. The trackers were configured to sample every
|
||||
* 120s and to send every 600s. This could mean that for some 60s the live requests were "ahead" of the trackers.
|
||||
*/
|
||||
@Test
|
||||
public void testDistanceCacheIncrementalFillUpAndRecursion() {
|
||||
TimePoint start = MillisecondsTimePoint.now();
|
||||
TimePoint fixTime = start;
|
||||
TimePoint queryTime = fixTime;
|
||||
Position p = new DegreePosition(0, 0);
|
||||
Bearing cog = new DegreeBearingImpl(123);
|
||||
final Duration queryInterval = Duration.ONE_SECOND;
|
||||
final Duration readAhead = Duration.ONE_MINUTE;
|
||||
final Duration samplingInterval = Duration.ONE_SECOND.times(120);
|
||||
final Duration transmissionInterval = Duration.ONE_MINUTE.times(10);
|
||||
final Duration raceDuration = Duration.ONE_HOUR.times(48);
|
||||
final Speed speed = new KnotSpeedImpl(12);
|
||||
final Distance distancePerSample = speed.travel(fixTime, fixTime.plus(samplingInterval));
|
||||
DynamicGPSFixTrack<Object, GPSFix> track = new DynamicGPSFixTrackImpl<Object>(new Object(), /* millisecondsOverWhichToAverage */ 30000l);
|
||||
while (fixTime.before(start.plus(raceDuration))) {
|
||||
for (int i=0; i<transmissionInterval.divide(samplingInterval); i++) {
|
||||
// produce a bulk of fixes
|
||||
GPSFix fix = new GPSFixImpl(p, fixTime);
|
||||
track.add(fix);
|
||||
fixTime = fixTime.plus(samplingInterval);
|
||||
p = p.translateGreatCircle(cog, distancePerSample);
|
||||
}
|
||||
Distance lastDistance = Distance.NULL;
|
||||
// now query the distance with constant "from" and increasing "to" where "to" moves until 60s after tp
|
||||
while (queryTime.before(fixTime.plus(readAhead))) {
|
||||
final Distance d = track.getDistanceTraveled(start, queryTime);
|
||||
assertTrue(d.compareTo(lastDistance) >= 0);
|
||||
lastDistance = d;
|
||||
queryTime = queryTime.plus(queryInterval);
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDistanceCacheAccessForPartialStrip() {
|
||||
|
||||
Reference in new issue
Block a user