fixing bug 1517 by not automatically stopping the tracker upon storedDataEnd/stopped callbacks

This commit is contained in:
Axel Uhl committed 2013-09-18 15:38:32 +02:00
1 parent 024f43f1b0
commit 4484473961
1 file changed
+4 -24
@@ -100,8 +100,6 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
*/ */
private final boolean isLiveTracking; private final boolean isLiveTracking;
private final TrackedRegattaRegistry trackedRegattaRegistry;
/** /**
* Creates a race tracked for the specified URL/URIs and starts receiving all available existing and future push * 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()} is called.
@@ -183,7 +181,6 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
WindStore windStore, String tracTracUsername, String tracTracPassword, TrackedRegattaRegistry trackedRegattaRegistry) WindStore windStore, String tracTracUsername, String tracTracPassword, TrackedRegattaRegistry trackedRegattaRegistry)
throws URISyntaxException, MalformedURLException, FileNotFoundException { throws URISyntaxException, MalformedURLException, FileNotFoundException {
super(); super();
this.trackedRegattaRegistry = trackedRegattaRegistry;
this.tractracEvent = tractracEvent; this.tractracEvent = tractracEvent;
urls = createID(paramURL, liveURI, storedURI); urls = createID(paramURL, liveURI, storedURI);
isLiveTracking = liveURI != null; isLiveTracking = liveURI != null;
@@ -548,27 +545,10 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
@Override @Override
public void stopped() { public void stopped() {
logger.info("stopped TracTrac tracking for "+getRaces()); logger.info("stopped TracTrac tracking for "+getRaces());
lastStatus = new TrackedRaceStatusImpl(TrackedRaceStatusEnum.FINISHED, 1.0); lastStatus = new TrackedRaceStatusImpl(TrackedRaceStatusEnum.TRACKING, 1.0);
updateStatusOfTrackedRaces(); updateStatusOfTrackedRaces();
for (final RaceDefinition race : getRaces()) { // don't stop the tracker (see bug 1517) as it seems that the storedData... callbacks are unreliable, and
// Ask RacingEventService to cleanly stop and unregister this tracker // we have seen many more fixes been transmitted after having received stopped()
// if the race has all data loaded. Doing this asynchronously because
// stopping can take longer and if you're loading many races in parallel
// this can slow down loading extremely because this call-back seems to be
// called by TTCM synchronously.
Thread raceStopper = new Thread(new Runnable() {
@Override
public void run() {
try {
trackedRegattaRegistry.stopTracking(regatta, race);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error trying to stop tracker for race " + race.getName()
+ " in regatta " + getRegatta().getName(), e);
}
}
});
raceStopper.start();
}
} }
private void updateStatusOfTrackedRaces() { private void updateStatusOfTrackedRaces() {
@@ -606,7 +586,7 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
@Override @Override
public void storedDataProgress(float progress) { public void storedDataProgress(float progress) {
logger.info("Stored data progress for race(s) "+getRaces()+": "+progress); logger.info("Stored data progress for race(s) "+getRaces()+": "+progress);
lastStatus = new TrackedRaceStatusImpl(TrackedRaceStatusEnum.LOADING, progress); lastStatus = new TrackedRaceStatusImpl(progress==1.0 ? TrackedRaceStatusEnum.TRACKING : TrackedRaceStatusEnum.LOADING, progress);
updateStatusOfTrackedRaces(); updateStatusOfTrackedRaces();
} }