added "boolean preemptive" parameter to Tracker.stop() method, passing it through for TracTracRaceTrackerImpl;

using it to stop trackers immediately when clearing RacingEventService for initial load, as well as when the
timeout expires or when the regatta is untracked.
This commit is contained in:
Axel Uhl committed 2014-12-13 22:17:12 +01:00
1 parent c912ccb857
commit 066b6daca4
12 files changed
+24 -29

No files matched your search

@@ -147,7 +147,7 @@ public class CreateAndTrackWithRaceLogTest {
testSize(race.getTrack(comp1), 5);
//stop tracking, then no more fixes arrive at race
service.getRaceTrackerById(raceLog.getId()).stop();
service.getRaceTrackerById(raceLog.getId()).stop(/* preemptive */ false);
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), new MillisecondsTimePoint(8), new KnotSpeedWithBearingImpl(10, new DegreeBearingImpl(5))));
testSize(race.getTrack(comp1), 5);
}
@@ -115,7 +115,7 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
}
@Override
public void stop() {
public void stop(boolean preemptive) {
// mark passing calculator is automatically stopped, when the race status is set to {@link TrackedRaceStatusEnum#FINISHED}
trackedRace.setStatus(new TrackedRaceStatusImpl(TrackedRaceStatusEnum.FINISHED, 100));
@@ -147,7 +147,7 @@ public class SwissTimingRaceTrackerImpl extends AbstractRaceTrackerImpl implemen
}
@Override
public void stop() throws MalformedURLException, IOException, InterruptedException {
public void stop(boolean preemptive) throws MalformedURLException, IOException, InterruptedException {
if (isTrackedRaceStillReachable()) {
TrackedRaceStatus newStatus = new TrackedRaceStatusImpl(TrackedRaceStatusEnum.FINISHED, 1.0);
trackedRace.setStatus(newStatus);
@@ -87,9 +87,9 @@ public class MultipleClassesInRegattaTest {
@After
public void tearDown() throws MalformedURLException, IOException, InterruptedException {
kiwotest1.stop();
kiwotest2.stop();
kiwotest3.stop();
weym470may112014_2.stop();
kiwotest1.stop(/* preemptive */ false);
kiwotest2.stop(/* preemptive */ false);
kiwotest3.stop(/* preemptive */ false);
weym470may112014_2.stop(/* preemptive */ false);
}
}
@@ -69,7 +69,7 @@ public class UnicodeCharactersInCompetitorNamesTest {
for (Competitor competitor : competitors) {
System.out.println(competitor.getName());
}
fourtyninerYellow_2.stop();
fourtyninerYellow_2.stop(/* preemptive */ false);
}
@Test
@@ -105,7 +105,7 @@ public interface DomainFactory {
/**
* Creates a race tracked for the specified URL/URIs and starts receiving all available existing and future push
* data from there. Receiving continues until {@link TracTracRaceTracker#stop()} is called.
* data from there. Receiving continues until {@link TracTracRaceTracker#stop(boolean)} is called.
* <p>
*
* A race tracker uses the <code>paramURL</code> for the TracTrac Java client to register for push data about one
@@ -215,7 +215,7 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
/**
* Creates a race tracked for the specified URL/URIs and starts receiving all available existing and future push
* data from there. Receiving continues until {@link #stop()} is called.
* data from there. Receiving continues until {@link #stop(boolean)} is called.
* <p>
*
* A race tracker uses the <code>paramURL</code> for the TracTrac Java client to register for push data about one
@@ -484,13 +484,7 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
}
@Override
public void stop() throws InterruptedException {
if (!stopped) {
stop(/* stop receivers preemtively */false);
}
}
private void stop(boolean stopReceiversPreemtively) throws InterruptedException {
public void stop(boolean stopReceiversPreemtively) throws InterruptedException {
if (!stopped) {
stopped = true;
raceSubscriber.stop();
@@ -22,10 +22,10 @@ import com.sap.sailing.domain.racelog.tracking.GPSFixStore;
* The data received by the tracker is usually fed into {@link TrackedRace} objects that {@link TrackedRace#getRace()
* correspond} to the {@link RaceDefinition} objects for whose tracking this tracker is responsible. When the
* {@link TrackedRace} isn't connected to its {@link TrackedRegatta#getTrackedRaces() owning} {@link TrackedRegatta}, a
* tracker is assumed to no longer update the {@link TrackedRace} object, even if it hasn't been {@link #stop() stopped}.
* tracker is assumed to no longer update the {@link TrackedRace} object, even if it hasn't been {@link #stop(boolean) stopped}.
* <p>
*
* A tracker may be {@link #stop() stopped}. In this case, it will no longer receive any data at all. Stopping a tracker
* A tracker may be {@link #stop(boolean) stopped}. In this case, it will no longer receive any data at all. Stopping a tracker
* will not modify the {@link Regatta} and the {@link TrackedRegatta} with regards to their ownership of their
* {@link RaceDefiniion} and {@link TrackedRace}, respectively.
*
@@ -42,8 +42,9 @@ public interface RaceTracker {
/**
* Stops tracking the races.
* @param preemptive TODO
*/
void stop() throws MalformedURLException, IOException, InterruptedException;
void stop(boolean preemptive) throws MalformedURLException, IOException, InterruptedException;
com.sap.sailing.domain.base.Regatta getRegatta();
@@ -194,7 +194,7 @@ public class TrackRaceReplicationTest extends AbstractServerReplicationTest {
@Override
public void tearDown() throws Exception {
if (racesHandle != null) {
racesHandle.getRaceTracker().stop();
racesHandle.getRaceTracker().stop(/* preemptive */ false);
}
super.tearDown();
}
@@ -47,7 +47,7 @@ public class RaceTrackerMock implements RaceTracker{
}
@Override
public void stop() throws MalformedURLException, IOException, InterruptedException {
public void stop(boolean preemptive) throws MalformedURLException, IOException, InterruptedException {
isTracking = false;
}
@@ -139,7 +139,7 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
* <p>
*
* Any {@link RaceTracker} for which <code>race</race> is the last race tracked that is still reachable
* from {@link #getAllRegattas()} will be {@link RaceTracker#stop() stopped}.
* from {@link #getAllRegattas()} will be {@link RaceTracker#stop(boolean) stopped}.
*
* The <code>race</code> will be also removed from all leaderboards containing a column that has <code>race</code>'s
* {@link #getTrackedRace(Regatta, RaceDefinition) corresponding} {@link TrackedRace} as its
@@ -1559,7 +1559,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
stopTrackingWind(regatta, race);
}
}
raceTracker.stop();
raceTracker.stop(/* preemptive */ false);
final Object trackerId = raceTracker.getID();
final NamedReentrantReadWriteLock lock = lockRaceTrackersById(trackerId);
try {
@@ -1613,7 +1613,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
* The tracker will initially try to connect to the tracking infrastructure to obtain basic race master data. If
* this fails after some timeout, to avoid garbage and lingering threads, the task scheduled by this method will
* check after the timeout expires if race master data was successfully received. If so, the tracker continues
* normally. Otherwise, the tracker is shut down orderly by calling {@link RaceTracker#stop() stopping}.
* normally. Otherwise, the tracker is shut down orderly by calling {@link RaceTracker#stop(boolean) stopping}.
*
* @return the scheduled task, in case the caller wants to {@link ScheduledFuture#cancel(boolean) cancel} it, e.g.,
* when the tracker is stopped or has successfully received the race
@@ -1633,7 +1633,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
if (trackersForRegatta != null) {
trackersForRegatta.remove(tracker);
}
tracker.stop();
tracker.stop(/* preemptive */ true);
final Object trackerId = tracker.getID();
final NamedReentrantReadWriteLock lock = lockRaceTrackersById(trackerId);
try {
@@ -1665,7 +1665,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
RaceTracker raceTracker = trackerIter.next();
if (raceTracker.getRaces() != null && raceTracker.getRaces().contains(race)) {
logger.info("Found tracker to stop for races " + raceTracker.getRaces());
raceTracker.stop();
raceTracker.stop(/* preemptive */ false);
trackerIter.remove();
final Object trackerId = raceTracker.getID();
final NamedReentrantReadWriteLock lock = lockRaceTrackersById(trackerId);
@@ -1844,7 +1844,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
}
if (!foundReachableRace) {
// firstly stop the tracker
raceTracker.stop();
raceTracker.stop(/* preemptive */ true);
// remove it from the raceTrackers by Regatta
trackerIter.remove();
final Object trackerId = raceTracker.getID();
@@ -2385,7 +2385,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
final Set<RaceTracker> trackers = raceTrackersByRegatta.get(regatta.getRegatta());
if (trackers != null) {
for (RaceTracker tracker : trackers) {
tracker.stop();
tracker.stop(/* preemptive */ true);
}
}
}