Merge branch 'master' into bug1564

This commit is contained in:
Alexander Tatarinovich committed 2016-09-27 16:42:21 +03:00
commit 73e0eba758
429 files changed
+12586 -14778

No files matched your search

@@ -189,7 +189,7 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
* @throws SocketException
* thrown, e.g., in case there is already another listener on the port requested
*/
void startTrackingWind(Regatta regatta, RaceDefinition race, boolean correctByDeclination) throws Exception;
void startTrackingWind(Regatta regatta, RaceDefinition race, boolean correctByDeclination);
void stopTrackingWind(Regatta regatta, RaceDefinition race) throws SocketException, IOException;
@@ -123,8 +123,6 @@ public class RaceLogScoringReplicator implements RaceColumnListener {
* last {@link RaceLogFinishPositioningListChangedEvent} event with {@link CompetitorResults} is looked up and its
* results are used.
*
* TODO bug 3420: also extract the optional score / finishing time / comment and make good use of it
*
* @param timePoint
* the TimePoint at which the race committee confirmed their last rank list entered in the app.
*/
@@ -148,7 +146,7 @@ public class RaceLogScoringReplicator implements RaceColumnListener {
int rankByRaceCommittee = getRankInPositioningListByRaceCommittee(positionedCompetitor);
correctScoreInLeaderboard(leaderboard, raceColumn, timePoint, numberOfCompetitorsInRace,
competitor, rankByRaceCommittee, positionedCompetitor.getScore());
setMaxPointsReasonInLeaderboardIfNecessary(leaderboard, raceColumn, timePoint, positionedCompetitor, competitor);
setMaxPointsReasonInLeaderboardIfNecessary(leaderboard, raceColumn, timePoint, positionedCompetitor.getMaxPointsReason(), competitor);
}
// Since the metadata update is used by the Sailing suite to determine the final state of a race, it has to
// be triggered, even though no score correction may have been performed
@@ -157,10 +155,10 @@ public class RaceLogScoringReplicator implements RaceColumnListener {
}
private boolean setMaxPointsReasonInLeaderboardIfNecessary(Leaderboard leaderboard, RaceColumn raceColumn,
TimePoint timePoint, CompetitorResult positionedCompetitor, Competitor competitor) {
TimePoint timePoint, MaxPointsReason maxPointsReason, Competitor competitor) {
boolean scoreHasBeenCorrected = false;
MaxPointsReason oldMaxPointsReason = leaderboard.getMaxPointsReason(competitor, raceColumn, timePoint);
MaxPointsReason maxPointsReasonByRaceCommittee = positionedCompetitor.getMaxPointsReason();
MaxPointsReason maxPointsReasonByRaceCommittee = maxPointsReason;
if (!Util.equalsWithNull(maxPointsReasonByRaceCommittee, oldMaxPointsReason)) {
applyMaxPointsReasonOperation(leaderboard, raceColumn, competitor, maxPointsReasonByRaceCommittee, timePoint);
scoreHasBeenCorrected = true;
@@ -29,11 +29,8 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -247,7 +244,7 @@ import com.sap.sse.shared.media.VideoDescriptor;
import com.sap.sse.util.ClearStateTestSupport;
import com.sap.sse.util.HttpUrlConnectionHelper;
import com.sap.sse.util.JoinedClassLoader;
import com.sap.sse.util.impl.ThreadFactoryWithPriority;
import com.sap.sse.util.ThreadPoolUtil;
public class RacingEventServiceImpl implements RacingEventService, ClearStateTestSupport, RegattaListener,
LeaderboardRegistry, Replicator, EventFetcher {
@@ -257,7 +254,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
* A scheduler for the periodic checks of the paramURL documents for the advent of {@link ControlPoint}s with static
* position information otherwise not available through <code>MarkPassingReceiver</code>'s events.
*/
private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, new ThreadFactoryWithPriority(Thread.NORM_PRIORITY, /* daemon */ true));
private static final ScheduledExecutorService scheduler = ThreadPoolUtil.INSTANCE.getDefaultForegroundTaskThreadPoolExecutor();
private final com.sap.sailing.domain.base.DomainFactory baseDomainFactory;
@@ -608,12 +605,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
operationExecutionListeners = new ConcurrentHashMap<>();
courseListeners = new ConcurrentHashMap<>();
persistentRegattasForRaceIDs = new ConcurrentHashMap<>();
final int SIMULATION_THREAD_POOL_SIZE = Math.max(Runtime.getRuntime().availableProcessors()/3, 1);
Executor simulatorExecutor = new ThreadPoolExecutor(/* corePoolSize */SIMULATION_THREAD_POOL_SIZE,
/* maximumPoolSize */SIMULATION_THREAD_POOL_SIZE,
/* keepAliveTime */60, TimeUnit.SECONDS,
/* workQueue */new LinkedBlockingQueue<Runnable>(), new ThreadFactoryWithPriority(
Thread.NORM_PRIORITY, /* daemon */true));
Executor simulatorExecutor = ThreadPoolUtil.INSTANCE.getDefaultBackgroundTaskThreadPoolExecutor();
// TODO: initialize smart-future-cache for simulation-results and add to simulation-service
simulationService = SimulationServiceFactory.INSTANCE.getService(simulatorExecutor, this);
this.raceLogReplicator = new RaceLogReplicatorAndNotifier(this);
@@ -2300,9 +2292,13 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
}
@Override
public void startTrackingWind(Regatta regatta, RaceDefinition race, boolean correctByDeclination) throws Exception {
public void startTrackingWind(Regatta regatta, RaceDefinition race, boolean correctByDeclination) {
for (WindTrackerFactory windTrackerFactory : getWindTrackerFactories()) {
windTrackerFactory.createWindTracker(getOrCreateTrackedRegatta(regatta), race, correctByDeclination);
try {
windTrackerFactory.createWindTracker(getOrCreateTrackedRegatta(regatta), race, correctByDeclination);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error trying to track wind using wind tracker factory "+windTrackerFactory, e);
}
}
}
@@ -294,7 +294,6 @@ public class SailingNotificationServiceImpl implements SailingNotificationServic
public void notifyUserOnCompetitorPassesFinish(Competitor competitor, TrackedRace trackedRace,
Leaderboard leaderboard, RaceColumn raceColumn, Fleet fleet) {
doWithEvent(leaderboard, (event, leaderboardGroup) -> {
mailQueue.addNotification(new NotificationSetNotification<Competitor>(competitor, competitorResults) {
@Override
protected NotificationMailTemplate getMailTemplate(Competitor objectToNotifyAbout, Locale locale) {