terminate a TracTracRaceTrackerImpl properly when it has no live-uri and has loaded all stored data;

this frees up the resources consumed by the clientParamsPHP poller automatically, relieving the admin
This commit is contained in:
Axel Uhl committed 2013-08-13 10:51:58 +02:00
1 parent fa1f230bb3
commit d7496df0b1
5 files changed
+39 -23

No files matched your search

@@ -94,6 +94,14 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
private final Triple<URL, URI, URI> urls;
private final ScheduledFuture<?> controlPointPositionPoller;
/**
* Tells if this tracker was created with a valid live URI. If not, the tracker will stop and unregister itself
* from the {@link RacingEventService} after having received all stored data.
*/
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
* data from there. Receiving continues until {@link #stop()} is called.
@@ -175,8 +183,10 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
WindStore windStore, String tracTracUsername, String tracTracPassword, TrackedRegattaRegistry trackedRegattaRegistry)
throws URISyntaxException, MalformedURLException, FileNotFoundException {
super();
this.trackedRegattaRegistry = trackedRegattaRegistry;
this.tractracEvent = tractracEvent;
urls = createID(paramURL, liveURI, storedURI);
isLiveTracking = liveURI != null;
this.races = new HashSet<RaceDefinition>();
this.windStore = windStore;
this.domainFactory = domainFactory;
@@ -540,11 +550,6 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
logger.info("stopped TracTrac tracking for "+getRaces());
lastStatus = new TrackedRaceStatusImpl(TrackedRaceStatusEnum.FINISHED, 1.0);
updateStatusOfTrackedRaces();
try {
stop(/* stop receivers preemptively */ false);
} catch (InterruptedException e) {
logger.log(Level.SEVERE, "Exception trying to stop tracker for "+getRaces(), e);
}
}
private void updateStatusOfTrackedRaces() {
@@ -572,8 +577,20 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
@Override
public void storedDataEnd() {
logger.info("Stored data end for race(s) "+getRaces());
lastStatus = new TrackedRaceStatusImpl(TrackedRaceStatusEnum.TRACKING, 1);
updateStatusOfTrackedRaces();
if (isLiveTracking) {
lastStatus = new TrackedRaceStatusImpl(TrackedRaceStatusEnum.TRACKING, 1);
updateStatusOfTrackedRaces();
} else {
// ask RacingEventService to cleanly stop and unregister this tracker
for (RaceDefinition race : getRaces()) {
try {
trackedRegattaRegistry.stopTracking(getRegatta(), race);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error trying to stop tracker for race "+race.getName()+
" in regatta "+getRegatta().getName(), e);
}
}
}
}
@Override
@@ -1,6 +1,8 @@
package com.sap.sailing.domain.tracking;
import java.io.IOException;
import java.io.Serializable;
import java.net.MalformedURLException;
import com.sap.sailing.domain.base.RaceDefinition;
import com.sap.sailing.domain.base.Regatta;
@@ -44,4 +46,14 @@ public interface TrackedRegattaRegistry {
boolean isRaceBeingTracked(RaceDefinition r);
/**
* Stops all {@link RaceTracker}s currently tracking <code>race</code>. Note that if the same tracker also may have
* been tracking other races. Other races of the same event that are currently tracked will continue to be tracked.
* If wind tracking for the race is currently running, it will be stopped (see also
* {@link #stopTrackingWind(Regatta, RaceDefinition)}). The <code>race</code> (and the other races tracked by the
* same tracker) as well as the corresponding {@link TrackedRace}s will continue to exist, e.g., when asking
* {@link #getTrackedRace(Regatta, RaceDefinition)}.
*/
void stopTracking(Regatta regatta, RaceDefinition race) throws MalformedURLException, IOException, InterruptedException;
}
@@ -4,7 +4,6 @@
<stringAttribute key="com.google.gdt.eclipse.suiteMainTypeProcessor.PREVIOUSLY_SET_MAIN_TYPE_NAME" value="com.google.gwt.dev.GWTShell"/>
<booleanAttribute key="com.google.gdt.eclipse.suiteWarArgumentProcessor.IS_WAR_FROM_PROJECT_PROPERTIES" value="true"/>
<listAttribute key="com.google.gwt.eclipse.core.ENTRY_POINT_MODULES">
<listEntry value="com.sap.sailing.gwt.ui.Simulator"/>
<listEntry value="com.sap.sailing.gwt.ui.YoutubePopup"/>
<listEntry value="com.sap.sailing.gwt.ui.VideoPopup"/>
<listEntry value="com.sap.sailing.gwt.ui.UserManagement"/>
@@ -16,6 +15,7 @@
<listEntry value="com.sap.sailing.gwt.ui.Leaderboard"/>
<listEntry value="com.sap.sailing.gwt.ui.AdminConsole"/>
<listEntry value="com.sap.sailing.gwt.ui.RegattaOverview"/>
<listEntry value="com.sap.sailing.gwt.ui.Simulator"/>
</listAttribute>
<stringAttribute key="com.google.gwt.eclipse.core.URL" value="/gwt/AdminConsole.html"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
@@ -53,7 +53,6 @@
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/org.moxieapps.gwt.highcharts/src&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.sap.sailing.geocoding/src&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.sap.sailing.server.replication/src&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/de.csenk.gwt.ws/src&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.google.gwt.osgi/lib/gwt-user.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#13;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;com.sap.sailing.gwt.ui&quot;/&gt;&#13;&#10;&lt;/runtimeClasspathEntry&gt;&#13;&#10;"/>
</listAttribute>
@@ -191,16 +191,6 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
*/
void removeRace(Regatta regatta, RaceDefinition race) throws MalformedURLException, IOException,InterruptedException;
/**
* Stops all {@link RaceTracker}s currently tracking <code>race</code>. Note that if the same tracker also may have
* been tracking other races. Other races of the same event that are currently tracked will continue to be tracked.
* If wind tracking for the race is currently running, it will be stopped (see also
* {@link #stopTrackingWind(Regatta, RaceDefinition)}). The <code>race</code> (and the other races tracked by the
* same tracker) as well as the corresponding {@link TrackedRace}s will continue to exist, e.g., when asking
* {@link #getTrackedRace(Regatta, RaceDefinition)}.
*/
void stopTracking(Regatta regatta, RaceDefinition race) throws MalformedURLException, IOException, InterruptedException;
/**
* @param port
* the UDP port on which to listen for incoming messages from Expedition clients
@@ -1240,9 +1240,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
RaceTracker raceTracker = trackerIter.next();
if (raceTracker.getRaces() != null && raceTracker.getRaces().contains(race)) {
logger.info("Found tracker to stop for races " + raceTracker.getRaces());
raceTracker.stop(); // this also removes the TrackedRace from trackedRegatta
// do not remove the tracker from raceTrackersByRegatta, because it should still exist there,
// but with the state "non-tracked"
raceTracker.stop();
trackerIter.remove();
raceTrackersByID.remove(raceTracker.getID());
}
@@ -1251,7 +1249,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
logger.warning("Didn't find any trackers for regatta " + regatta);
}
stopTrackingWind(regatta, race);
// if the last tracked race was removed, remove the entire regatta
// if the last tracked race was removed, confirm that tracking for the entire regatta has stopped
if (raceTrackersByRegatta.get(regatta).isEmpty()) {
stopTracking(regatta);
}