mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 09:26:44 +00:00
pass on waitFor... parameters properly
This commit is contained in:
+2
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.persistence.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@@ -80,6 +81,7 @@ public class SwissTimingAdapterPersistenceImpl implements SwissTimingAdapterPers
|
||||
SwissTimingConfiguration stConfig = loadSwissTimingConfiguration(o);
|
||||
result.add(stConfig);
|
||||
}
|
||||
Collections.reverse(result);
|
||||
} catch (Throwable t) {
|
||||
// something went wrong during DB access; report, then use empty new wind track
|
||||
logger.log(Level.SEVERE,
|
||||
|
||||
+8
-1
@@ -395,7 +395,7 @@ public class MockedTrackedRaceWithStartTimeAndRanks implements TrackedRace {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getAverageCrossTrackError(Competitor competitor, TimePoint timePoint) throws NoWindException {
|
||||
public Distance getAverageCrossTrackError(Competitor competitor, TimePoint timePoint, boolean waitForLatestAnalysis) throws NoWindException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@@ -417,4 +417,11 @@ public class MockedTrackedRaceWithStartTimeAndRanks implements TrackedRace {
|
||||
return competitorsFromBestToWorst;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getAverageCrossTrackError(Competitor competitor, TimePoint from, TimePoint to, boolean upwindOnly, boolean waitForLatestAnalyses)
|
||||
throws NoWindException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-1
@@ -588,7 +588,7 @@ public class MockedTrackedRace implements DynamicTrackedRace {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getAverageCrossTrackError(Competitor competitor, TimePoint timePoint) throws NoWindException {
|
||||
public Distance getAverageCrossTrackError(Competitor competitor, TimePoint timePoint, boolean waitForLatestAnalysis) throws NoWindException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@@ -651,4 +651,11 @@ public class MockedTrackedRace implements DynamicTrackedRace {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getAverageCrossTrackError(Competitor competitor, TimePoint from, TimePoint to, boolean upwindOnly, boolean waitForLatestAnalyses)
|
||||
throws NoWindException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.domain.tractracadapter.persistence.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -31,6 +32,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
TracTracConfiguration ttConfig = loadTracTracConfiguration(o);
|
||||
result.add(ttConfig);
|
||||
}
|
||||
Collections.reverse(result);
|
||||
} catch (Throwable t) {
|
||||
// something went wrong during DB access; report, then use empty new wind track
|
||||
logger.log(Level.SEVERE, "Error connecting to MongoDB, unable to load recorded TracTrac configurations. Check MongoDB settings.");
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ public interface TrackedLegOfCompetitor extends Serializable {
|
||||
*/
|
||||
Distance getWindwardDistanceToOverallLeader(TimePoint timePoint) throws NoWindException;
|
||||
|
||||
Distance getAverageCrossTrackError(TimePoint timePoint) throws NoWindException;
|
||||
Distance getAverageCrossTrackError(TimePoint timePoint, boolean waitForLatestAnalysis) throws NoWindException;
|
||||
|
||||
Distance getWindwardDistance(Position pos1, Position pos2, TimePoint at) throws NoWindException;
|
||||
|
||||
|
||||
@@ -397,8 +397,12 @@ public interface TrackedRace extends Serializable {
|
||||
|
||||
/**
|
||||
* Computes the average cross-track error for the legs with type {@link LegType#UPWIND}.
|
||||
*
|
||||
* @param waitForLatestAnalysis
|
||||
* if <code>true</code> and any cache update is currently going on, wait for the update to complete and
|
||||
* then fetch the updated value; otherwise, serve this requests from whatever is currently in the cache
|
||||
*/
|
||||
Distance getAverageCrossTrackError(Competitor competitor, TimePoint timePoint) throws NoWindException;
|
||||
Distance getAverageCrossTrackError(Competitor competitor, TimePoint timePoint, boolean waitForLatestAnalysis) throws NoWindException;
|
||||
|
||||
WindStore getWindStore();
|
||||
|
||||
@@ -410,5 +414,5 @@ public interface TrackedRace extends Serializable {
|
||||
*/
|
||||
List<Competitor> getCompetitorsFromBestToWorst(TimePoint timePoint);
|
||||
|
||||
Distance getAverageCrossTrackError(Competitor competitor, TimePoint from, TimePoint to) throws NoWindException;
|
||||
Distance getAverageCrossTrackError(Competitor competitor, TimePoint from, TimePoint to, boolean upwindOnly, boolean waitForLatestAnalyses) throws NoWindException;
|
||||
}
|
||||
|
||||
+2
-2
@@ -375,7 +375,7 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getAverageCrossTrackError(TimePoint timePoint) throws NoWindException {
|
||||
public Distance getAverageCrossTrackError(TimePoint timePoint, boolean waitForLatestAnalysis) throws NoWindException {
|
||||
Distance result = null;
|
||||
final MarkPassing legStartMarkPassing = getTrackedRace().getMarkPassing(competitor, getLeg().getFrom());
|
||||
if (legStartMarkPassing != null) {
|
||||
@@ -387,7 +387,7 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
|
||||
} else {
|
||||
to = legEndMarkPassing.getTimePoint();
|
||||
}
|
||||
result = getTrackedRace().getAverageCrossTrackError(competitor, legStart, to);
|
||||
result = getTrackedRace().getAverageCrossTrackError(competitor, legStart, to, /* upwindOnly */ false, waitForLatestAnalysis);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+4
-4
@@ -753,7 +753,7 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getAverageCrossTrackError(Competitor competitor, TimePoint timePoint) throws NoWindException {
|
||||
public Distance getAverageCrossTrackError(Competitor competitor, TimePoint timePoint, boolean waitForLatestAnalysis) throws NoWindException {
|
||||
NavigableSet<MarkPassing> markPassings = getMarkPassings(competitor);
|
||||
TimePoint from = null;
|
||||
synchronized (markPassings) {
|
||||
@@ -763,7 +763,7 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
}
|
||||
Distance result;
|
||||
if (from != null) {
|
||||
result = getAverageCrossTrackError(competitor, from, timePoint);
|
||||
result = getAverageCrossTrackError(competitor, from, timePoint, /* upwindOnly */ true, waitForLatestAnalysis);
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
@@ -771,10 +771,10 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getAverageCrossTrackError(Competitor competitor, TimePoint from, TimePoint to)
|
||||
public Distance getAverageCrossTrackError(Competitor competitor, TimePoint from, TimePoint to, boolean upwindOnly, boolean waitForLatestAnalysis)
|
||||
throws NoWindException {
|
||||
Distance result;
|
||||
result = crossTrackErrorCache.getAverageCrossTrackError(competitor, from, to, /* upwindOnly */ true, /* waitForLatest */ true);
|
||||
result = crossTrackErrorCache.getAverageCrossTrackError(competitor, from, to, upwindOnly, waitForLatestAnalysis);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public interface SailingService extends RemoteService {
|
||||
public List<String> getLeaderboardNames() throws Exception;
|
||||
|
||||
LeaderboardDTO getLeaderboardByName(String leaderboardName, Date date,
|
||||
Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails, boolean waitForLatestManeuverAnalysis)
|
||||
Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails, boolean waitForLatestAnalyses)
|
||||
throws NoWindException;
|
||||
|
||||
List<StrippedLeaderboardDTO> getLeaderboards();
|
||||
|
||||
+6
-5
@@ -170,14 +170,15 @@ public interface SailingServiceAsync {
|
||||
* list will contain one entry per leg of the race {@link Course} for those race columns whose
|
||||
* {@link RaceColumn#getType() name} is contained in <code>namesOfRacesForWhichToLoadLegDetails</code>.
|
||||
* For all other columns, {@link LeaderboardEntryDTO#legDetails} is <code>null</code>.
|
||||
* @param waitForLatestManeuverAnalysis
|
||||
* if <code>false</code>, this method is allowed to read the maneuver analysis results from a cache that
|
||||
* may not reflect all data already received; otherwise, the method will always block for the latest
|
||||
* cache updates to have happened before returning.
|
||||
* @param waitForLatestAnalyses
|
||||
* if <code>false</code>, this method is allowed to read the maneuver analysis and other expensive
|
||||
* analysis results such as the cross track error from a cache that may not reflect all data already
|
||||
* received; otherwise, the method will always block for the latest cache updates to have happened before
|
||||
* returning.
|
||||
*/
|
||||
void getLeaderboardByName(String leaderboardName, Date date,
|
||||
Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails,
|
||||
boolean waitForLatestManeuverAnalysis, AsyncCallback<LeaderboardDTO> callback);
|
||||
boolean waitForLatestAnalyses, AsyncCallback<LeaderboardDTO> callback);
|
||||
|
||||
void getLeaderboardNames(AsyncCallback<List<String>> callback);
|
||||
|
||||
|
||||
+3
-2
@@ -574,7 +574,8 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
callWhenExpansionDataIsLoaded.run();
|
||||
} else {
|
||||
getSailingService().getLeaderboardByName(getLeaderboardName(), getLeaderboardDisplayDate(),
|
||||
/* namesOfRacesForWhichToLoadLegDetails */getNamesOfExpandedRaces(), /* waitForLatestManeuverAnalysis */ true,
|
||||
/* namesOfRacesForWhichToLoadLegDetails */getNamesOfExpandedRaces(),
|
||||
/* waitForLatestAnalyses */ timer.getPlayMode() != PlayModes.Live,
|
||||
new AsyncCallback<LeaderboardDTO>() {
|
||||
@Override
|
||||
public void onSuccess(LeaderboardDTO result) {
|
||||
@@ -1222,7 +1223,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
if (needsDataLoading()) {
|
||||
GetLeaderboardByNameAction getLeaderboardByNameAction = new GetLeaderboardByNameAction(sailingService, getLeaderboardName(), date,
|
||||
/* namesOfRacesForWhichToLoadLegDetails */getNamesOfExpandedRaces(),
|
||||
/* waitForLatestManeuverAnalysis */ /* TODO uncomment after profiling run: timer.getPlayMode() != PlayModes.Live */ true,
|
||||
/* waitForLatestAnalyses */ timer.getPlayMode() != PlayModes.Live,
|
||||
new AsyncCallback<LeaderboardDTO>() {
|
||||
@Override
|
||||
public void onSuccess(LeaderboardDTO result) {
|
||||
|
||||
Regular → Executable
+14
-14
@@ -346,7 +346,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
|
||||
@Override
|
||||
public LeaderboardDTO getLeaderboardByName(String leaderboardName, Date date,
|
||||
final Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails, final boolean waitForLatestManeuverAnalysis)
|
||||
final Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails, final boolean waitForLatestAnalyses)
|
||||
throws NoWindException {
|
||||
long startOfRequestHandling = System.currentTimeMillis();
|
||||
LeaderboardDTO result = null;
|
||||
@@ -391,7 +391,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
return getLeaderboardEntryDTO(entry, raceColumn.getTrackedRace(competitor), competitor, timePoint,
|
||||
namesOfRaceColumnsForWhichToLoadLegDetails != null
|
||||
&& namesOfRaceColumnsForWhichToLoadLegDetails.contains(raceColumn.getName()),
|
||||
waitForLatestManeuverAnalysis);
|
||||
waitForLatestAnalyses);
|
||||
} catch (NoWindException e) {
|
||||
throw new NoWindError(e);
|
||||
}
|
||||
@@ -430,13 +430,13 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
}
|
||||
|
||||
/**
|
||||
* @param waitForLatestManeuverAnalysis
|
||||
* @param waitForLatestAnalyses
|
||||
* if <code>false</code>, this method is allowed to read the maneuver analysis results from a cache that
|
||||
* may not reflect all data already received; otherwise, the method will always block for the latest
|
||||
* cache updates to have happened before returning.
|
||||
*/
|
||||
private LeaderboardEntryDTO getLeaderboardEntryDTO(Entry entry, TrackedRace trackedRace, Competitor competitor,
|
||||
TimePoint timePoint, boolean addLegDetails, boolean waitForLatestManeuverAnalysis) throws NoWindException {
|
||||
TimePoint timePoint, boolean addLegDetails, boolean waitForLatestAnalyses) throws NoWindException {
|
||||
LeaderboardEntryDTO entryDTO = new LeaderboardEntryDTO();
|
||||
entryDTO.race = trackedRace == null ? null : trackedRace.getRaceIdentifier();
|
||||
entryDTO.netPoints = entry.getNetPoints();
|
||||
@@ -446,7 +446,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
entryDTO.discarded = entry.isDiscarded();
|
||||
if (addLegDetails && trackedRace != null) {
|
||||
try {
|
||||
RaceDetails raceDetails = getRaceDetails(trackedRace, competitor, timePoint, waitForLatestManeuverAnalysis);
|
||||
RaceDetails raceDetails = getRaceDetails(trackedRace, competitor, timePoint, waitForLatestAnalyses);
|
||||
entryDTO.legDetails = raceDetails.getLegDetails();
|
||||
entryDTO.windwardDistanceToOverallLeaderInMeters = raceDetails.getWindwardDistanceToOverallLeader() == null ? null
|
||||
: raceDetails.getWindwardDistanceToOverallLeader().getMeters();
|
||||
@@ -492,18 +492,18 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
* they will be stored to the cache after calculating them. A cache invalidation {@link RaceChangeListener listener}
|
||||
* will be registered with the race which will be triggered for any event received by the race.
|
||||
*
|
||||
* @param waitForLatestManeuverAnalysis
|
||||
* @param waitForLatestAnalyses
|
||||
* if <code>false</code>, this method is allowed to read the maneuver analysis results from a cache that
|
||||
* may not reflect all data already received; otherwise, the method will always block for the latest
|
||||
* cache updates to have happened before returning.
|
||||
*/
|
||||
private RaceDetails getRaceDetails(TrackedRace trackedRace, Competitor competitor, TimePoint timePoint,
|
||||
boolean waitForLatestManeuverAnalysis) throws NoWindException, InterruptedException, ExecutionException {
|
||||
boolean waitForLatestAnalyses) throws NoWindException, InterruptedException, ExecutionException {
|
||||
RaceDetails raceDetails;
|
||||
if (trackedRace.getEndOfTracking() != null && trackedRace.getEndOfTracking().compareTo(timePoint) < 0) {
|
||||
raceDetails = getRaceDetailsForEndOfTrackingFromCacheOrCalculateAndCache(trackedRace, competitor);
|
||||
} else {
|
||||
raceDetails = calculateRaceDetails(trackedRace, competitor, timePoint, waitForLatestManeuverAnalysis);
|
||||
raceDetails = calculateRaceDetails(trackedRace, competitor, timePoint, waitForLatestAnalyses);
|
||||
}
|
||||
return raceDetails;
|
||||
}
|
||||
@@ -613,7 +613,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
}
|
||||
|
||||
private RaceDetails calculateRaceDetails(TrackedRace trackedRace, Competitor competitor, TimePoint timePoint,
|
||||
boolean waitForLatestManeuverAnalysis) throws NoWindException {
|
||||
boolean waitForLatestAnalyses) throws NoWindException {
|
||||
List<LegEntryDTO> legDetails;
|
||||
legDetails = new ArrayList<LegEntryDTO>();
|
||||
final Course course = trackedRace.getRace().getCourse();
|
||||
@@ -626,7 +626,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
// immediately. Make sure we're tolerant against disappearing legs! See bug 794.
|
||||
TrackedLegOfCompetitor trackedLeg = trackedRace.getTrackedLeg(competitor, leg);
|
||||
if (trackedLeg != null && trackedLeg.hasStartedLeg(timePoint)) {
|
||||
legEntry = createLegEntry(trackedLeg, timePoint, waitForLatestManeuverAnalysis);
|
||||
legEntry = createLegEntry(trackedLeg, timePoint, waitForLatestAnalyses);
|
||||
} else {
|
||||
legEntry = null;
|
||||
}
|
||||
@@ -635,7 +635,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
final Distance windwardDistanceToOverallLeader = trackedRace == null ? null : trackedRace
|
||||
.getWindwardDistanceToOverallLeader(competitor, timePoint);
|
||||
final Distance averageCrossTrackError = trackedRace == null ? null : trackedRace.getAverageCrossTrackError(
|
||||
competitor, timePoint);
|
||||
competitor, timePoint, waitForLatestAnalyses);
|
||||
return new RaceDetails(legDetails, windwardDistanceToOverallLeader, averageCrossTrackError);
|
||||
} finally {
|
||||
course.unlockAfterRead();
|
||||
@@ -643,7 +643,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
}
|
||||
|
||||
private LegEntryDTO createLegEntry(TrackedLegOfCompetitor trackedLeg, TimePoint timePoint,
|
||||
boolean waitForLatestManeuverAnalysis) throws NoWindException {
|
||||
boolean waitForLatestAnalyses) throws NoWindException {
|
||||
LegEntryDTO result;
|
||||
if (trackedLeg == null) {
|
||||
result = null;
|
||||
@@ -651,7 +651,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
result = new LegEntryDTO();
|
||||
final Speed averageSpeedOverGround = trackedLeg.getAverageSpeedOverGround(timePoint);
|
||||
result.averageSpeedOverGroundInKnots = averageSpeedOverGround == null ? null : averageSpeedOverGround.getKnots();
|
||||
final Distance averageCrossTrackError = trackedLeg.getAverageCrossTrackError(timePoint);
|
||||
final Distance averageCrossTrackError = trackedLeg.getAverageCrossTrackError(timePoint, waitForLatestAnalyses);
|
||||
result.averageCrossTrackErrorInMeters = averageCrossTrackError == null ? null : averageCrossTrackError.getMeters();
|
||||
Double speedOverGroundInKnots;
|
||||
if (trackedLeg.hasFinishedLeg(timePoint)) {
|
||||
@@ -679,7 +679,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
Distance windwardDistanceToGo = trackedLeg.getWindwardDistanceToGo(timePoint);
|
||||
result.windwardDistanceToGoInMeters = windwardDistanceToGo == null ? null : windwardDistanceToGo
|
||||
.getMeters();
|
||||
List<Maneuver> maneuvers = trackedLeg.getManeuvers(timePoint, waitForLatestManeuverAnalysis);
|
||||
List<Maneuver> maneuvers = trackedLeg.getManeuvers(timePoint, waitForLatestAnalyses);
|
||||
if (maneuvers != null) {
|
||||
result.numberOfTacks = 0;
|
||||
result.numberOfJibes = 0;
|
||||
|
||||
Reference in New Issue
Block a user