5bb42d2d8c63201a63877125e528fae0912d8918
java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/MongoObjectFactoryImpl.java
| ... | ... | @@ -2107,7 +2107,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory { |
| 2107 | 2107 | final Document fingerprintDoc = Document.parse(fingerprintjson.toString()); |
| 2108 | 2108 | result.put(FieldNames.MANEUVER_FINGERPRINT.name(), fingerprintDoc); |
| 2109 | 2109 | storeRaceIdentifier(result, raceIdentifier); |
| 2110 | - final List<Document> maneuverDoc = storeManeuvers( maneuvers , raceIdentifier, course); |
|
| 2110 | + final List<Document> maneuverDoc = storeManeuvers(maneuvers , raceIdentifier, course); |
|
| 2111 | 2111 | result.put(FieldNames.MANEUVERS.name(), maneuverDoc); |
| 2112 | 2112 | maneuverCollection.replaceOne(query, result, new ReplaceOptions().upsert(true)); |
| 2113 | 2113 | } |
java/com.sap.sailing.domain.racelogtrackingadapter.test/src/com/sap/sailing/domain/racelogtracking/test/impl/GPSFixStoreListenerTest.java
| ... | ... | @@ -42,7 +42,7 @@ public class GPSFixStoreListenerTest extends AbstractGPSFixStoreTest { |
| 42 | 42 | barrier.await(100, TimeUnit.MILLISECONDS); |
| 43 | 43 | // During iteration in the main thread this causes a modification that makes the iterator throw a |
| 44 | 44 | // ConcurrentModificationException on next() |
| 45 | - store.addListener((DeviceIdentifier device, GPSFixMoving fix, boolean returnManeuverChanges, boolean returnLiveDelay) -> { |
|
| 45 | + store.addListener((DeviceIdentifier device, Iterable<GPSFixMoving> fixes, boolean returnManeuverChanges, boolean returnLiveDelay) -> { |
|
| 46 | 46 | return null; |
| 47 | 47 | }, device); |
| 48 | 48 | barrier.await(100, TimeUnit.MILLISECONDS); |
| ... | ... | @@ -71,7 +71,7 @@ public class GPSFixStoreListenerTest extends AbstractGPSFixStoreTest { |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | @Override |
| 74 | - public Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixReceived(DeviceIdentifier device, GPSFixMoving fix, boolean returnManeuverChanges, boolean returnLiveDelay) { |
|
| 74 | + public Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixesReceived(DeviceIdentifier device, Iterable<GPSFixMoving> fixes, boolean returnManeuverChanges, boolean returnLiveDelay) { |
|
| 75 | 75 | try { |
| 76 | 76 | barrier.await(100, TimeUnit.MILLISECONDS); |
| 77 | 77 | } catch (TimeoutException e) { |
java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/fixtracker/FixLoaderAndTracker.java
| ... | ... | @@ -206,10 +206,11 @@ public class FixLoaderAndTracker implements TrackingDataLoader { |
| 206 | 206 | |
| 207 | 207 | private final FixReceivedListener<Timed> listener = new FixReceivedListener<Timed>() { |
| 208 | 208 | @Override |
| 209 | - public Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixReceived(DeviceIdentifier device, |
|
| 210 | - Timed fix, boolean returnManeuverChanges, boolean returnLiveDelay) { |
|
| 209 | + public Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixesReceived(DeviceIdentifier device, |
|
| 210 | + Iterable<Timed> fixes, boolean returnManeuverChanges, boolean returnLiveDelay) { |
|
| 211 | 211 | final Set<RegattaAndRaceIdentifier> maneuverChanged = new HashSet<>(); |
| 212 | 212 | final Map<RegattaAndRaceIdentifier, Duration> delayToLive = new HashMap<>(); |
| 213 | + // TODO bug6236: how to improve performance of device mappings look-up when we have received multiple fixes from the same device? |
|
| 213 | 214 | if (!preemptiveStopRequested.get() && trackedRace.getStartOfTracking() != null) { |
| 214 | 215 | final TimePoint timePoint = fix.getTimePoint(); |
| 215 | 216 | deviceMappings.forEachMappingOfDeviceIncludingTimePoint(device, fix.getTimePoint(), |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/racelog/tracking/FixReceivedListener.java
| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | 1 | package com.sap.sailing.domain.racelog.tracking; |
| 2 | 2 | |
| 3 | +import java.util.Collections; |
|
| 4 | + |
|
| 3 | 5 | import com.sap.sailing.domain.common.DeviceIdentifier; |
| 4 | 6 | import com.sap.sailing.domain.common.RegattaAndRaceIdentifier; |
| 5 | 7 | import com.sap.sse.common.Duration; |
| ... | ... | @@ -12,6 +14,7 @@ import com.sap.sse.common.Util.Triple; |
| 12 | 14 | * @param <FixT> |
| 13 | 15 | * the type of fixes this listener can consume. |
| 14 | 16 | */ |
| 17 | +@FunctionalInterface |
|
| 15 | 18 | public interface FixReceivedListener<FixT extends Timed> { |
| 16 | 19 | /** |
| 17 | 20 | * |
| ... | ... | @@ -34,6 +37,32 @@ public interface FixReceivedListener<FixT extends Timed> { |
| 34 | 37 | * returned can be empty but is never {@code null}. It can also contain multiple identifiers if the device |
| 35 | 38 | * mapping is currently ambiguous. |
| 36 | 39 | */ |
| 37 | - Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixReceived(DeviceIdentifier device, FixT fix, |
|
| 40 | + default Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixReceived(DeviceIdentifier device, FixT fix, |
|
| 41 | + boolean returnManeuverChanges, boolean returnLiveDelay) { |
|
| 42 | + return fixesReceived(device, Collections.singleton(fix), returnManeuverChanges, returnLiveDelay); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * |
|
| 47 | + * @param device |
|
| 48 | + * the device that recorded the fix. Cannot be <code>null</code>. |
|
| 49 | + * @param fixes |
|
| 50 | + * The fixes that were stored. Must not be <code>null</code> but may be empty |
|
| 51 | + * @param returnLiveDelay |
|
| 52 | + * if {@code true} then all listeners to which the fixes are forwarded shall check to which races the fix |
|
| 53 | + * maps and report the live delay for the newest of those {@code fixes} for all those races as the third |
|
| 54 | + * component of the resulting {@link Triple}s. |
|
| 55 | + * @param returnManeuverUpdate |
|
| 56 | + * if {@code true}, all listeners to which this fixes are forwarded shall check whether the fixes feed |
|
| 57 | + * into a competitor's track in the scope of a race where for that competitor the maneuver list has |
|
| 58 | + * changed since the last call of this type; if so, the race identifier will be part of the result, with |
|
| 59 | + * the {@link Boolean} component being {@code true} for that race. Otherwise, the {@link Boolean} |
|
| 60 | + * component is {@code false} or the race is not listed in the result. |
|
| 61 | + * @return An {@link Iterable} with {@link RegattaAndRaceIdentifier}s is returned that will contain races with new |
|
| 62 | + * maneuvers which were not available at the last time the given device stored a fix. The {@link Iterable} |
|
| 63 | + * returned can be empty but is never {@code null}. It can also contain multiple identifiers if the device |
|
| 64 | + * mapping is currently ambiguous. |
|
| 65 | + */ |
|
| 66 | + Iterable<Triple<RegattaAndRaceIdentifier, Boolean, Duration>> fixesReceived(DeviceIdentifier device, Iterable<FixT> fixes, |
|
| 38 | 67 | boolean returnManeuverChanges, boolean returnLiveDelay); |
| 39 | 68 | } |