bug6236: (WIP) moving towards notifying multiple fixes at once

This commit is contained in:
Axel Uhl committed 2026-04-14 11:20:22 +02:00
1 parent 486efe3bbe
commit 5bb42d2d8c
4 files changed
+36 -6

No files matched your search

@@ -2107,7 +2107,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
final Document fingerprintDoc = Document.parse(fingerprintjson.toString());
result.put(FieldNames.MANEUVER_FINGERPRINT.name(), fingerprintDoc);
storeRaceIdentifier(result, raceIdentifier);
final List<Document> maneuverDoc = storeManeuvers( maneuvers , raceIdentifier, course);
final List<Document> maneuverDoc = storeManeuvers(maneuvers , raceIdentifier, course);
result.put(FieldNames.MANEUVERS.name(), maneuverDoc);
maneuverCollection.replaceOne(query, result, new ReplaceOptions().upsert(true));
}
@@ -42,7 +42,7 @@ public class GPSFixStoreListenerTest extends AbstractGPSFixStoreTest {
barrier.await(100, TimeUnit.MILLISECONDS);
// During iteration in the main thread this causes a modification that makes the iterator throw a
// ConcurrentModificationException on next()
store.addListener((DeviceIdentifier device, GPSFixMoving fix, boolean returnManeuverChanges, boolean returnLiveDelay) -> {
store.addListener((DeviceIdentifier device, Iterable<GPSFixMoving> fixes, boolean returnManeuverChanges, boolean returnLiveDelay) -> {
return null;
}, device);
barrier.await(100, TimeUnit.MILLISECONDS);
@@ -71,7 +71,7 @@ public class GPSFixStoreListenerTest extends AbstractGPSFixStoreTest {
}
@Override
public Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixReceived(DeviceIdentifier device, GPSFixMoving fix, boolean returnManeuverChanges, boolean returnLiveDelay) {
public Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixesReceived(DeviceIdentifier device, Iterable<GPSFixMoving> fixes, boolean returnManeuverChanges, boolean returnLiveDelay) {
try {
barrier.await(100, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
@@ -206,10 +206,11 @@ public class FixLoaderAndTracker implements TrackingDataLoader {
private final FixReceivedListener<Timed> listener = new FixReceivedListener<Timed>() {
@Override
public Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixReceived(DeviceIdentifier device,
Timed fix, boolean returnManeuverChanges, boolean returnLiveDelay) {
public Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixesReceived(DeviceIdentifier device,
Iterable<Timed> fixes, boolean returnManeuverChanges, boolean returnLiveDelay) {
final Set<RegattaAndRaceIdentifier> maneuverChanged = new HashSet<>();
final Map<RegattaAndRaceIdentifier, Duration> delayToLive = new HashMap<>();
// TODO bug6236: how to improve performance of device mappings look-up when we have received multiple fixes from the same device?
if (!preemptiveStopRequested.get() && trackedRace.getStartOfTracking() != null) {
final TimePoint timePoint = fix.getTimePoint();
deviceMappings.forEachMappingOfDeviceIncludingTimePoint(device, fix.getTimePoint(),
@@ -1,5 +1,7 @@
package com.sap.sailing.domain.racelog.tracking;
import java.util.Collections;
import com.sap.sailing.domain.common.DeviceIdentifier;
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
import com.sap.sse.common.Duration;
@@ -12,6 +14,7 @@ import com.sap.sse.common.Util.Triple;
* @param <FixT>
* the type of fixes this listener can consume.
*/
@FunctionalInterface
public interface FixReceivedListener<FixT extends Timed> {
/**
*
@@ -34,6 +37,32 @@ public interface FixReceivedListener<FixT extends Timed> {
* returned can be empty but is never {@code null}. It can also contain multiple identifiers if the device
* mapping is currently ambiguous.
*/
Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixReceived(DeviceIdentifier device, FixT fix,
default Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixReceived(DeviceIdentifier device, FixT fix,
boolean returnManeuverChanges, boolean returnLiveDelay) {
return fixesReceived(device, Collections.singleton(fix), returnManeuverChanges, returnLiveDelay);
}
/**
*
* @param device
* the device that recorded the fix. Cannot be <code>null</code>.
* @param fixes
* The fixes that were stored. Must not be <code>null</code> but may be empty
* @param returnLiveDelay
* if {@code true} then all listeners to which the fixes are forwarded shall check to which races the fix
* maps and report the live delay for the newest of those {@code fixes} for all those races as the third
* component of the resulting {@link Triple}s.
* @param returnManeuverUpdate
* if {@code true}, all listeners to which this fixes are forwarded shall check whether the fixes feed
* into a competitor's track in the scope of a race where for that competitor the maneuver list has
* changed since the last call of this type; if so, the race identifier will be part of the result, with
* the {@link Boolean} component being {@code true} for that race. Otherwise, the {@link Boolean}
* component is {@code false} or the race is not listed in the result.
* @return An {@link Iterable} with {@link RegattaAndRaceIdentifier}s is returned that will contain races with new
* maneuvers which were not available at the last time the given device stored a fix. The {@link Iterable}
* returned can be empty but is never {@code null}. It can also contain multiple identifiers if the device
* mapping is currently ambiguous.
*/
Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixesReceived(DeviceIdentifier device, Iterable<FixT> fixes,
boolean returnManeuverChanges, boolean returnLiveDelay);
}