5956e91d667f9f78e9c608a7d959c171de811ddb
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverhash/SerializableManeuverCache.java
| ... | ... | @@ -9,4 +9,6 @@ public interface SerializableManeuverCache extends ManeuverCache, Serializable { |
| 9 | 9 | * been wired correctly and have access to the {@link ManeuverRaceFingerprintRegistry}. |
| 10 | 10 | */ |
| 11 | 11 | void setManeuverRaceFingerprintRegistry(ManeuverRaceFingerprintRegistry maneuverRaceFingerprintRegistry); |
| 12 | + |
|
| 13 | + void ensureFilled(); |
|
| 12 | 14 | } |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverhash/impl/ManeuverCacheDelegate.java
| ... | ... | @@ -44,6 +44,15 @@ public class ManeuverCacheDelegate implements SerializableManeuverCache { |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | @Override |
| 47 | + public void ensureFilled() { |
|
| 48 | + if (cacheToUse.canBeUpdated()) { |
|
| 49 | + for (final Competitor competitor : race.getShuffledCompetitors()) { |
|
| 50 | + cacheToUse.triggerUpdate(competitor); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + @Override |
|
| 47 | 56 | public void setManeuverRaceFingerprintRegistry(ManeuverRaceFingerprintRegistry maneuverRaceFingerprintRegistry) { |
| 48 | 57 | this.maneuverRaceFingerprintRegistry = maneuverRaceFingerprintRegistry; |
| 49 | 58 | } |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/maneuverhash/impl/ManeuversFromDatabase.java
| ... | ... | @@ -57,4 +57,9 @@ public class ManeuversFromDatabase implements SerializableManeuverCache { |
| 57 | 57 | public void setManeuverRaceFingerprintRegistry(ManeuverRaceFingerprintRegistry maneuverRaceFingerprintRegistry) { |
| 58 | 58 | // no-op; nothing to set here |
| 59 | 59 | } |
| 60 | + |
|
| 61 | + @Override |
|
| 62 | + public void ensureFilled() { |
|
| 63 | + // no-op; a read-only cache of this type is always filled as good as it can |
|
| 64 | + } |
|
| 60 | 65 | } |
| ... | ... | \ No newline at end of file |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java
| ... | ... | @@ -809,7 +809,7 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl |
| 809 | 809 | } catch (PatchFailedException e) { |
| 810 | 810 | throw new RuntimeException(e); |
| 811 | 811 | } // a bit unclean: this also tries to work on the DynamicTrackedRaceImpl which isn't fully initialized yet; see also bug6039 |
| 812 | - triggerManeuverCacheRecalculationForAllCompetitors(); // a bit unclean: this also tries to work on the DynamicTrackedRaceImpl which isn't fully initialized yet; see also bug6039 |
|
| 812 | + ensureManeuverCacheIsFilledForAllCompetitors(); // a bit unclean: this also tries to work on the DynamicTrackedRaceImpl which isn't fully initialized yet; see also bug6039 |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
| ... | ... | @@ -2865,22 +2865,29 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl |
| 2865 | 2865 | public Iterable<GPSFixMoving> approximate(Competitor competitor, Distance maxDistance, TimePoint from, TimePoint to) { |
| 2866 | 2866 | return maneuverApproximators.get(competitor).approximate(from, to); |
| 2867 | 2867 | } |
| 2868 | + |
|
| 2869 | + private void ensureManeuverCacheIsFilledForAllCompetitors() { |
|
| 2870 | + maneuverCache.ensureFilled(); |
|
| 2871 | + } |
|
| 2868 | 2872 | |
| 2869 | 2873 | protected void triggerManeuverCacheRecalculationForAllCompetitors() { |
| 2870 | 2874 | if (cachesSuspended) { |
| 2871 | 2875 | triggerManeuverCacheInvalidationForAllCompetitors = true; |
| 2872 | 2876 | } else { |
| 2873 | - final List<Competitor> shuffledCompetitors = new ArrayList<>(); |
|
| 2874 | - for (Competitor competitor : (getRace().getCompetitors())) { |
|
| 2875 | - shuffledCompetitors.add(competitor); |
|
| 2876 | - } |
|
| 2877 | - Collections.shuffle(shuffledCompetitors); |
|
| 2878 | - for (Competitor competitor : shuffledCompetitors) { |
|
| 2877 | + for (Competitor competitor : getShuffledCompetitors()) { |
|
| 2879 | 2878 | triggerManeuverCacheRecalculation(competitor); |
| 2880 | 2879 | } |
| 2881 | 2880 | } |
| 2882 | 2881 | } |
| 2883 | 2882 | |
| 2883 | + public List<Competitor> getShuffledCompetitors() { |
|
| 2884 | + final List<Competitor> shuffledCompetitors = new ArrayList<>(); |
|
| 2885 | + for (Competitor competitor : (getRace().getCompetitors())) { |
|
| 2886 | + shuffledCompetitors.add(competitor); |
|
| 2887 | + } |
|
| 2888 | + return shuffledCompetitors; |
|
| 2889 | + } |
|
| 2890 | + |
|
| 2884 | 2891 | public void triggerManeuverCacheRecalculation(final Competitor competitor) { |
| 2885 | 2892 | if (cachesSuspended) { |
| 2886 | 2893 | triggerManeuverCacheInvalidationForAllCompetitors = true; |
| ... | ... | @@ -4083,8 +4090,8 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl |
| 4083 | 4090 | |
| 4084 | 4091 | @Override |
| 4085 | 4092 | public void setWindEstimation(IncrementalWindEstimation windEstimation) { |
| 4086 | - IncrementalWindEstimation previousWindEstimation = this.windEstimation; |
|
| 4087 | - if (previousWindEstimation != windEstimation) { |
|
| 4093 | + final IncrementalWindEstimation previousWindEstimation = this.windEstimation; |
|
| 4094 | + if (previousWindEstimation != windEstimation) { // bug5959 comment #15: if maneuvers were sent during initial load of RacingEventService and they were based on the IncrementalWindEstimation just received through initial load of WindEstimationFactoryService, don't re-compute those maneuvers! |
|
| 4088 | 4095 | updateManeuversAndWindWithNewWindEstimation(windEstimation, previousWindEstimation); |
| 4089 | 4096 | } |
| 4090 | 4097 | } |
| ... | ... | @@ -4102,6 +4109,7 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl |
| 4102 | 4109 | // complete maneuver curves can be fed directly into the windEstimation. |
| 4103 | 4110 | maneuverDetectorPerCompetitorCache.clearCache(); |
| 4104 | 4111 | shortTimeWindCache.clearCache(); |
| 4112 | + // TODO bug5959: trigger a recalculation only if the wind track being replaced is changing content |
|
| 4105 | 4113 | triggerManeuverCacheRecalculationForAllCompetitors(); |
| 4106 | 4114 | } |
| 4107 | 4115 |