constraining number of wind fix DTOs computed on the server in one call to 10000

This commit is contained in:
Axel Uhl committed 2015-07-18 23:18:15 +02:00
1 parent 771d22f2f4
commit fa240f2393
1 file changed
+4 -1
@@ -460,6 +460,8 @@ import com.sapsailing.xrr.structureimport.eventimport.RegattaJSON;
* The server side implementation of the RPC service.
*/
public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements SailingService, RaceFetcher, RegattaFetcher {
private static final int MAX_NUMBER_OF_WIND_FIXES_TO_DELIVER_IN_ONE_CALL = 10000;
private static final Logger logger = Logger.getLogger(SailingServiceImpl.class.getName());
private static final long serialVersionUID = 9031688830194537489L;
@@ -1416,7 +1418,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
TimePoint toTimePoint = to == null ? trackedRace.getEndOfRace() == null ?
MillisecondsTimePoint.now().minus(trackedRace.getDelayToLiveInMillis()) : trackedRace.getEndOfRace() : new MillisecondsTimePoint(to);
if (fromTimePoint != null && toTimePoint != null) {
int numberOfFixes = (int) ((toTimePoint.asMillis() - fromTimePoint.asMillis())/resolutionInMilliseconds);
int numberOfFixes = Math.min(MAX_NUMBER_OF_WIND_FIXES_TO_DELIVER_IN_ONE_CALL,
(int) ((toTimePoint.asMillis() - fromTimePoint.asMillis())/resolutionInMilliseconds));
result = getAveragedWindInfo(fromTimePoint, resolutionInMilliseconds, numberOfFixes,
windSourceTypeNames, trackedRace, onlyUpToNewestEvent, /* includeCombinedWindForAllLegMiddles */ false);
}