59e9393ca5bb794ce1e184c36b7f2983e7f3e3c7
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverdetection/impl/ManeuverCurveWithUnstableCourseAndSpeedWithEstimationDataImpl.java
| ... | ... | @@ -9,7 +9,7 @@ import com.sap.sse.common.TimePoint; |
| 9 | 9 | |
| 10 | 10 | public class ManeuverCurveWithUnstableCourseAndSpeedWithEstimationDataImpl extends ManeuverCurveBoundariesImpl |
| 11 | 11 | implements ManeuverCurveWithUnstableCourseAndSpeedWithEstimationData { |
| 12 | - |
|
| 12 | + private static final long serialVersionUID = 1227678171850468360L; |
|
| 13 | 13 | private final SpeedWithBearing averageSpeedWithBearingBefore; |
| 14 | 14 | private final Duration durationFromPreviousManeuverEndToManeuverStart; |
| 15 | 15 | private final SpeedWithBearing averageSpeedWithBearingAfter; |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverdetection/impl/ManeuverMainCurveDetailsWithBearingSteps.java
| ... | ... | @@ -15,7 +15,7 @@ import com.sap.sse.common.TimePoint; |
| 15 | 15 | * |
| 16 | 16 | */ |
| 17 | 17 | public class ManeuverMainCurveDetailsWithBearingSteps extends ManeuverCurveBoundariesImpl { |
| 18 | - |
|
| 18 | + private static final long serialVersionUID = 5448900675868938268L; |
|
| 19 | 19 | private final TimePoint timePoint; |
| 20 | 20 | private final double maxTurningRateInDegreesPerSecond; |
| 21 | 21 | private final SpeedWithBearingStepsIterable speedWithBearingSteps; |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverdetection/impl/ManeuverMainCurveWithEstimationDataImpl.java
| ... | ... | @@ -14,7 +14,7 @@ import com.sap.sse.common.TimePoint; |
| 14 | 14 | */ |
| 15 | 15 | public class ManeuverMainCurveWithEstimationDataImpl extends ManeuverCurveBoundariesImpl |
| 16 | 16 | implements ManeuverMainCurveWithEstimationData { |
| 17 | - |
|
| 17 | + private static final long serialVersionUID = -4524731853320916173L; |
|
| 18 | 18 | private final TimePoint lowestSpeedTimePoint; |
| 19 | 19 | private final TimePoint highestSpeedTimePoint; |
| 20 | 20 | private final TimePoint timePointOfMaxTurningRate; |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverhash/ManeuverCache.java
| ... | ... | @@ -1,14 +1,16 @@ |
| 1 | 1 | package com.sap.sailing.domain.maneuverhash; |
| 2 | 2 | |
| 3 | -import com.sap.sse.util.SmartFutureCache.UpdateInterval; |
|
| 3 | +import java.util.List; |
|
| 4 | 4 | |
| 5 | -public interface ManeuverCache<K, V, U extends UpdateInterval<U>>{ |
|
| 5 | +import com.sap.sailing.domain.base.Competitor; |
|
| 6 | +import com.sap.sailing.domain.tracking.Maneuver; |
|
| 6 | 7 | |
| 8 | +public interface ManeuverCache { |
|
| 7 | 9 | void resume(); |
| 8 | 10 | |
| 9 | - V get(K key, boolean waitForLatest); |
|
| 11 | + List<Maneuver> get(Competitor key, boolean waitForLatest); |
|
| 10 | 12 | |
| 11 | 13 | void suspend(); |
| 12 | 14 | |
| 13 | - void triggerUpdate(K key, U updateInterval); |
|
| 15 | + void triggerUpdate(Competitor key); |
|
| 14 | 16 | } |
| ... | ... | \ No newline at end of file |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverhash/SerializableManeuverCache.java
| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | +package com.sap.sailing.domain.maneuverhash; |
|
| 2 | + |
|
| 3 | +import java.io.Serializable; |
|
| 4 | + |
|
| 5 | +public interface SerializableManeuverCache extends ManeuverCache, Serializable { |
|
| 6 | + |
|
| 7 | +} |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverhash/impl/ManeuverCacheDelegate.java
| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | 1 | package com.sap.sailing.domain.maneuverhash.impl; |
| 2 | 2 | |
| 3 | +import java.io.IOException; |
|
| 4 | +import java.io.ObjectInputStream; |
|
| 5 | +import java.io.ObjectOutputStream; |
|
| 3 | 6 | import java.util.HashMap; |
| 4 | 7 | import java.util.List; |
| 5 | 8 | import java.util.Map; |
| 6 | - |
|
| 7 | 9 | import java.util.logging.Logger; |
| 8 | 10 | |
| 9 | 11 | import com.sap.sailing.domain.base.Competitor; |
| ... | ... | @@ -11,16 +13,17 @@ import com.sap.sailing.domain.maneuverhash.ManeuverCache; |
| 11 | 13 | import com.sap.sailing.domain.maneuverhash.ManeuverRaceFingerprint; |
| 12 | 14 | import com.sap.sailing.domain.maneuverhash.ManeuverRaceFingerprintFactory; |
| 13 | 15 | import com.sap.sailing.domain.maneuverhash.ManeuverRaceFingerprintRegistry; |
| 16 | +import com.sap.sailing.domain.maneuverhash.SerializableManeuverCache; |
|
| 14 | 17 | import com.sap.sailing.domain.tracking.Maneuver; |
| 15 | 18 | import com.sap.sailing.domain.tracking.impl.DynamicTrackedRaceImpl; |
| 16 | 19 | import com.sap.sailing.domain.tracking.impl.TrackedRaceImpl; |
| 17 | -import com.sap.sse.util.SmartFutureCache.EmptyUpdateInterval; |
|
| 18 | 20 | |
| 19 | -public class ManeuverCacheDelegate implements ManeuverCache<Competitor, List<Maneuver>, EmptyUpdateInterval> { |
|
| 21 | +public class ManeuverCacheDelegate implements SerializableManeuverCache { |
|
| 22 | + private static final long serialVersionUID = 19872309587435L; |
|
| 20 | 23 | private final TrackedRaceImpl race; |
| 21 | 24 | private static final Logger logger = Logger.getLogger(ManeuverCacheDelegate.class.getName()); |
| 22 | 25 | private final ManeuverRaceFingerprintRegistry maneuverRaceFingerprintRegistry; |
| 23 | - private volatile ManeuverCache<Competitor, List<Maneuver>, EmptyUpdateInterval> cacheToUse; |
|
| 26 | + private volatile transient ManeuverCache cacheToUse; |
|
| 24 | 27 | |
| 25 | 28 | public ManeuverCacheDelegate(TrackedRaceImpl race, |
| 26 | 29 | ManeuverRaceFingerprintRegistry maneuverRaceFingerprintRegistry) { |
| ... | ... | @@ -30,6 +33,27 @@ public class ManeuverCacheDelegate implements ManeuverCache<Competitor, List<Man |
| 30 | 33 | this.cacheToUse = new ManeuversFromSmartFutureCache((DynamicTrackedRaceImpl) race); |
| 31 | 34 | } |
| 32 | 35 | |
| 36 | + private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { |
|
| 37 | + ois.defaultReadObject(); |
|
| 38 | + this.cacheToUse = (ManeuversFromDatabase) ois.readObject(); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + private void writeObject(ObjectOutputStream oos) throws IOException { |
|
| 42 | + oos.defaultWriteObject(); |
|
| 43 | + oos.writeObject(new ManeuversFromDatabase(getAllKnownManeuvers())); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + private Map<Competitor, List<Maneuver>> getAllKnownManeuvers() { |
|
| 47 | + final Map<Competitor, List<Maneuver>> result = new HashMap<>(); |
|
| 48 | + for (final Competitor competitor : race.getRace().getCompetitors()) { |
|
| 49 | + final List<Maneuver> maneuversForCompetitor = get(competitor, /* waitForLatest */ false); |
|
| 50 | + if (maneuversForCompetitor != null) { |
|
| 51 | + result.put(competitor, maneuversForCompetitor); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + return result; |
|
| 55 | + } |
|
| 56 | + |
|
| 33 | 57 | @Override |
| 34 | 58 | public void resume() { |
| 35 | 59 | final ManeuverRaceFingerprint fingerprint; |
| ... | ... | @@ -72,7 +96,7 @@ public class ManeuverCacheDelegate implements ManeuverCache<Competitor, List<Man |
| 72 | 96 | } |
| 73 | 97 | |
| 74 | 98 | @Override |
| 75 | - public void triggerUpdate(Competitor competitor, EmptyUpdateInterval updateInterval) { |
|
| 76 | - cacheToUse.triggerUpdate(competitor, updateInterval); |
|
| 99 | + public void triggerUpdate(Competitor competitor) { |
|
| 100 | + cacheToUse.triggerUpdate(competitor); |
|
| 77 | 101 | } |
| 78 | 102 | } |
| ... | ... | \ No newline at end of file |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverhash/impl/ManeuversFromDatabase.java
| ... | ... | @@ -6,10 +6,9 @@ import java.util.logging.Level; |
| 6 | 6 | import java.util.logging.Logger; |
| 7 | 7 | |
| 8 | 8 | import com.sap.sailing.domain.base.Competitor; |
| 9 | -import com.sap.sailing.domain.maneuverhash.ManeuverCache; |
|
| 9 | +import com.sap.sailing.domain.maneuverhash.SerializableManeuverCache; |
|
| 10 | 10 | import com.sap.sailing.domain.tracking.Maneuver; |
| 11 | 11 | import com.sap.sailing.domain.tracking.TrackedRace; |
| 12 | -import com.sap.sse.util.SmartFutureCache.EmptyUpdateInterval; |
|
| 13 | 12 | |
| 14 | 13 | /** |
| 15 | 14 | * Stores a {@link TrackedRace}'s {@link Maneuver}s after they were loaded successfully from the persistent store. |
| ... | ... | @@ -19,26 +18,23 @@ import com.sap.sse.util.SmartFutureCache.EmptyUpdateInterval; |
| 19 | 18 | * |
| 20 | 19 | * This class collaborates with {@link ManeuverCacheDelegate}. |
| 21 | 20 | */ |
| 22 | -public class ManeuversFromDatabase implements ManeuverCache<Competitor, List<Maneuver>, EmptyUpdateInterval> { |
|
| 23 | - boolean suspended; |
|
| 21 | +public class ManeuversFromDatabase implements SerializableManeuverCache { |
|
| 22 | + private static final long serialVersionUID = 1872340928634087L; |
|
| 24 | 23 | private static final Logger logger = Logger.getLogger(ManeuversFromDatabase.class.getName()); |
| 25 | 24 | private final Map<Competitor, List<Maneuver>> maneuvers; |
| 26 | 25 | |
| 27 | - public ManeuversFromDatabase( |
|
| 28 | - Map<Competitor, List<Maneuver>> maneuvers) { |
|
| 26 | + public ManeuversFromDatabase(Map<Competitor, List<Maneuver>> maneuvers) { |
|
| 29 | 27 | super(); |
| 30 | 28 | this.maneuvers = maneuvers; |
| 31 | 29 | } |
| 32 | - |
|
| 30 | + |
|
| 33 | 31 | public void resume() { |
| 34 | 32 | logger.log(Level.WARNING, "Method should never be called"); |
| 33 | + // TODO bug5959: another case where we should revert to a SmartFutureCache? |
|
| 35 | 34 | } |
| 36 | 35 | |
| 37 | 36 | public void suspend() { |
| 38 | - synchronized (this) { |
|
| 39 | - logger.finest("Suspended ManeuverFromDatabase"); |
|
| 40 | - suspended = true; |
|
| 41 | - } |
|
| 37 | + // nothing to suspend here |
|
| 42 | 38 | } |
| 43 | 39 | |
| 44 | 40 | public List<Maneuver> get(Competitor competitor, boolean waitForLatest) { |
| ... | ... | @@ -46,7 +42,7 @@ public class ManeuversFromDatabase implements ManeuverCache<Competitor, List<Man |
| 46 | 42 | } |
| 47 | 43 | |
| 48 | 44 | @Override |
| 49 | - public void triggerUpdate(Competitor key, EmptyUpdateInterval updateInterval) { |
|
| 45 | + public void triggerUpdate(Competitor key) { |
|
| 50 | 46 | logger.log(Level.WARNING, "If Fingerprint matches, no Update should be triggered"); |
| 51 | 47 | // TODO change to smartFutureCache in Delegate |
| 52 | 48 | } |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverhash/impl/ManeuversFromSmartFutureCache.java
| ... | ... | @@ -15,8 +15,7 @@ import com.sap.sse.util.SmartFutureCache; |
| 15 | 15 | import com.sap.sse.util.SmartFutureCache.AbstractCacheUpdater; |
| 16 | 16 | import com.sap.sse.util.SmartFutureCache.EmptyUpdateInterval; |
| 17 | 17 | |
| 18 | -public class ManeuversFromSmartFutureCache implements ManeuverCache<Competitor, List<Maneuver>, EmptyUpdateInterval> { |
|
| 19 | - |
|
| 18 | +public class ManeuversFromSmartFutureCache implements ManeuverCache { |
|
| 20 | 19 | private final SmartFutureCache<Competitor, List<Maneuver>, EmptyUpdateInterval> smartFutureCache; |
| 21 | 20 | |
| 22 | 21 | public ManeuversFromSmartFutureCache(DynamicTrackedRaceImpl race) { |
| ... | ... | @@ -62,7 +61,7 @@ public class ManeuversFromSmartFutureCache implements ManeuverCache<Competitor, |
| 62 | 61 | } |
| 63 | 62 | |
| 64 | 63 | @Override |
| 65 | - public void triggerUpdate(Competitor key, EmptyUpdateInterval updateInterval) { |
|
| 66 | - smartFutureCache.triggerUpdate(key, updateInterval); |
|
| 64 | + public void triggerUpdate(Competitor key) { |
|
| 65 | + smartFutureCache.triggerUpdate(key, /* updateInterval */ null); |
|
| 67 | 66 | } |
| 68 | 67 | } |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/ManeuverCurveBoundaries.java
| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | 1 | package com.sap.sailing.domain.tracking; |
| 2 | 2 | |
| 3 | +import java.io.Serializable; |
|
| 4 | + |
|
| 3 | 5 | import com.sap.sailing.domain.common.SpeedWithBearing; |
| 4 | 6 | import com.sap.sse.common.Bearing; |
| 5 | 7 | import com.sap.sse.common.Duration; |
| ... | ... | @@ -15,7 +17,7 @@ import com.sap.sse.common.impl.DegreeBearingImpl; |
| 15 | 17 | * @author Vladislav Chumak (D069712) |
| 16 | 18 | * |
| 17 | 19 | */ |
| 18 | -public interface ManeuverCurveBoundaries { |
|
| 20 | +public interface ManeuverCurveBoundaries extends Serializable { |
|
| 19 | 21 | |
| 20 | 22 | /** |
| 21 | 23 | * Gets the computed time point of curve start. |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/ManeuverCurveBoundariesImpl.java
| ... | ... | @@ -10,6 +10,7 @@ import com.sap.sse.common.TimePoint; |
| 10 | 10 | * |
| 11 | 11 | */ |
| 12 | 12 | public class ManeuverCurveBoundariesImpl implements ManeuverCurveBoundaries { |
| 13 | + private static final long serialVersionUID = 1097529837L; |
|
| 13 | 14 | private final TimePoint timePointBefore; |
| 14 | 15 | private final TimePoint timePointAfter; |
| 15 | 16 | private final SpeedWithBearing speedWithBearingBefore; |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java
| ... | ... | @@ -135,8 +135,8 @@ import com.sap.sailing.domain.maneuverdetection.IncrementalManeuverDetector; |
| 135 | 135 | import com.sap.sailing.domain.maneuverdetection.ManeuverDetector; |
| 136 | 136 | import com.sap.sailing.domain.maneuverdetection.ShortTimeAfterLastHitCache; |
| 137 | 137 | import com.sap.sailing.domain.maneuverdetection.impl.IncrementalManeuverDetectorImpl; |
| 138 | -import com.sap.sailing.domain.maneuverhash.ManeuverCache; |
|
| 139 | 138 | import com.sap.sailing.domain.maneuverhash.ManeuverRaceFingerprintRegistry; |
| 139 | +import com.sap.sailing.domain.maneuverhash.SerializableManeuverCache; |
|
| 140 | 140 | import com.sap.sailing.domain.maneuverhash.impl.ManeuverCacheDelegate; |
| 141 | 141 | import com.sap.sailing.domain.markpassingcalculation.MarkPassingCalculator; |
| 142 | 142 | import com.sap.sailing.domain.markpassinghash.MarkPassingRaceFingerprintRegistry; |
| ... | ... | @@ -196,7 +196,6 @@ import com.sap.sse.concurrent.NamedReentrantReadWriteLock; |
| 196 | 196 | import com.sap.sse.shared.util.impl.ApproximateTime; |
| 197 | 197 | import com.sap.sse.shared.util.impl.ArrayListNavigableSet; |
| 198 | 198 | import com.sap.sse.util.IdentityWrapper; |
| 199 | -import com.sap.sse.util.SmartFutureCache.EmptyUpdateInterval; |
|
| 200 | 199 | import com.sap.sse.util.impl.FutureTaskWithTracingGet; |
| 201 | 200 | |
| 202 | 201 | import difflib.DiffUtils; |
| ... | ... | @@ -344,7 +343,7 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl |
| 344 | 343 | * computed. Clients wanting to know maneuvers for the competitor outside of this time interval need to (re-)compute |
| 345 | 344 | * them. |
| 346 | 345 | */ |
| 347 | - public transient ManeuverCache<Competitor, List<Maneuver>, EmptyUpdateInterval> maneuverCache; |
|
| 346 | + private final SerializableManeuverCache maneuverCache; |
|
| 348 | 347 | |
| 349 | 348 | /** |
| 350 | 349 | * The values of this map are used by the {@link #approximate(Competitor, Distance, TimePoint, TimePoint)} method and |
| ... | ... | @@ -795,7 +794,6 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl |
| 795 | 794 | competitorRankingsLocks = createCompetitorRankingsLockMap(); |
| 796 | 795 | directionFromStartToNextMarkCache = new ConcurrentHashMap<>(); |
| 797 | 796 | maneuverDetectorPerCompetitorCache = createManeuverDetectorCache(); |
| 798 | - maneuverCache = createManeuverCache(/* maneuverRaceFingerprintRegistry==null will let this replica recompute the maneuvers */ null); |
|
| 799 | 797 | logger.info("Deserialized race " + getRace().getName()); |
| 800 | 798 | } |
| 801 | 799 | |
| ... | ... | @@ -2887,7 +2885,7 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl |
| 2887 | 2885 | if (cachesSuspended) { |
| 2888 | 2886 | triggerManeuverCacheInvalidationForAllCompetitors = true; |
| 2889 | 2887 | } else { |
| 2890 | - maneuverCache.triggerUpdate(competitor, /* updateInterval */null); |
|
| 2888 | + maneuverCache.triggerUpdate(competitor); |
|
| 2891 | 2889 | } |
| 2892 | 2890 | } |
| 2893 | 2891 |