mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-19 02:29:58 +00:00
Merge branch 'master' into bug4009
This commit is contained in:
commit
3acb4fbcd1
17 files changed
+176
-277
No files matched your search
+7
-4
@@ -85,12 +85,15 @@ public class TrackedRaceWithContext implements HasTrackedRaceContext {
|
||||
private Integer calculateYear() {
|
||||
TimePoint startOfRace = getTrackedRace().getStartOfRace();
|
||||
TimePoint time = startOfRace != null ? startOfRace : getTrackedRace().getStartOfTracking();
|
||||
final Integer result;
|
||||
if (time == null) {
|
||||
year = 0;
|
||||
result = 0;
|
||||
} else {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(time.asDate());
|
||||
result = calendar.get(Calendar.YEAR);
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(time.asDate());
|
||||
return calendar.get(Calendar.YEAR);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
@@ -15,4 +15,16 @@ public class KnotSpeedImpl extends AbstractSpeedImpl implements Speed {
|
||||
public double getKnots() {
|
||||
return knots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves extra work by only converting the other object's speed to knots; useful in particular
|
||||
* if both speeds are knot-based speeds
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == null || !(object instanceof Speed)) {
|
||||
return false;
|
||||
}
|
||||
return getKnots() == ((Speed) object).getKnots();
|
||||
}
|
||||
}
|
||||
Executable → Regular
+2
@@ -390,6 +390,8 @@ public class FixLoaderAndTracker implements TrackingDataLoader {
|
||||
}
|
||||
updateCallback.run();
|
||||
}
|
||||
} catch(Throwable t) {
|
||||
logger.log(Level.SEVERE, "Error while updating device mappings and loading fixes for race: " + trackedRace.getRaceIdentifier(), t);
|
||||
} finally {
|
||||
try {
|
||||
synchronized (FixLoaderAndTracker.this) {
|
||||
|
||||
+4
-3
@@ -125,9 +125,8 @@ public abstract class RegattaLogDeviceMappings<ItemT extends WithID> {
|
||||
public void stop() {
|
||||
LockUtil.executeWithWriteLock(knownRegattaLogsLock, () -> {
|
||||
knownRegattaLogs.forEach((log) -> log.removeListener(regattaLogEventVisitor));
|
||||
knownRegattaLogs.clear();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateMappings() {
|
||||
try {
|
||||
@@ -284,7 +283,9 @@ public abstract class RegattaLogDeviceMappings<ItemT extends WithID> {
|
||||
mappingChangedInternal(oldMapping, newMapping);
|
||||
}
|
||||
}
|
||||
mappingsAddedInternal(addedMappings, item);
|
||||
if (!addedMappings.isEmpty()) {
|
||||
mappingsAddedInternal(addedMappings, item);
|
||||
}
|
||||
// oldMappings now still contains those mappings that were not entirely substituted by the new mappings
|
||||
oldMappings.forEach(this::mappingRemovedInternal);
|
||||
}
|
||||
|
||||
+32
-40
@@ -4,7 +4,6 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
@@ -23,8 +22,7 @@ import com.sap.sailing.domain.tractracadapter.DomainFactory;
|
||||
import com.sap.sailing.domain.tractracadapter.TracTracConnectionConstants;
|
||||
import com.sap.sailing.domain.tractracadapter.TracTracRaceTracker;
|
||||
import com.sap.sailing.domain.tractracadapter.impl.DomainFactoryImpl;
|
||||
import com.tractrac.model.lib.api.event.CreateModelException;
|
||||
import com.tractrac.subscription.lib.api.SubscriberInitializationException;
|
||||
import com.sap.sailing.domain.tractracadapter.impl.RaceTrackingConnectivityParametersImpl;
|
||||
|
||||
public class MultipleClassesInRegattaTest {
|
||||
private static final boolean tractracTunnel = Boolean.valueOf(System.getProperty("tractrac.tunnel", "false"));
|
||||
@@ -41,7 +39,7 @@ public class MultipleClassesInRegattaTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadTwoRacesWithEqualEventNameButDifferentClasses() throws MalformedURLException, FileNotFoundException, URISyntaxException, CreateModelException, SubscriberInitializationException {
|
||||
public void testLoadTwoRacesWithEqualEventNameButDifferentClasses() throws Exception {
|
||||
String httpAndHost = "http://" + TracTracConnectionConstants.HOST_NAME;
|
||||
String liveURI = "tcp://" + TracTracConnectionConstants.HOST_NAME + ":" + TracTracConnectionConstants.PORT_LIVE;
|
||||
String storedURI = "tcp://" + TracTracConnectionConstants.HOST_NAME + ":" + TracTracConnectionConstants.PORT_STORED;
|
||||
@@ -54,48 +52,28 @@ public class MultipleClassesInRegattaTest {
|
||||
}
|
||||
kiwotest1 = domainFactory
|
||||
.createRaceTracker(
|
||||
new URL(
|
||||
httpAndHost
|
||||
+ "/events/event_20110505_SailingTea/clientparams.php?event=event_20110505_SailingTea&race=cce678c8-97e6-11e0-9aed-406186cbf87c"),
|
||||
new URI(liveURI), new URI(storedURI), new URI(courseDesignUpdateURI),
|
||||
/* startOfTracking */null, /* endOfTracking */null, /* delayToLiveInMillis */0l, /* offsetToStartTimeOfSimulatedRace */ null, /* ignoreTracTracMarkPassings*/
|
||||
false, EmptyRaceLogStore.INSTANCE, EmptyRegattaLogStore.INSTANCE, EmptyWindStore.INSTANCE,
|
||||
tracTracUsername, tracTracPassword,
|
||||
TracTracConnectionConstants.ONLINE_STATUS, TracTracConnectionConstants.ONLINE_VISIBILITY,
|
||||
new DummyTrackedRegattaRegistry(), mock(RaceLogResolver.class), /* connectivityParams */ null, /* preferReplayIfAvailable */ false);
|
||||
EmptyRaceLogStore.INSTANCE,
|
||||
EmptyRegattaLogStore.INSTANCE, EmptyWindStore.INSTANCE, new DummyTrackedRegattaRegistry(),
|
||||
mock(RaceLogResolver.class), createConnectivityParams(httpAndHost, liveURI, storedURI, courseDesignUpdateURI,
|
||||
tracTracUsername, tracTracPassword, "cce678c8-97e6-11e0-9aed-406186cbf87c"));
|
||||
kiwotest2 = domainFactory
|
||||
.createRaceTracker(
|
||||
new URL(
|
||||
httpAndHost
|
||||
+ "/events/event_20110505_SailingTea/clientparams.php?event=event_20110505_SailingTea&race=11290bd6-97e7-11e0-9aed-406186cbf87c"),
|
||||
new URI(liveURI), new URI(storedURI), new URI(courseDesignUpdateURI),
|
||||
/* startOfTracking */null, /* endOfTracking */null, /* delayToLiveInMillis */0l, /* offsetToStartTimeOfSimulatedRace */ null, /* ignoreTracTracMarkPassings*/
|
||||
false, EmptyRaceLogStore.INSTANCE, EmptyRegattaLogStore.INSTANCE, EmptyWindStore.INSTANCE,
|
||||
tracTracUsername, tracTracPassword,
|
||||
TracTracConnectionConstants.ONLINE_STATUS, TracTracConnectionConstants.ONLINE_VISIBILITY,
|
||||
new DummyTrackedRegattaRegistry(), mock(RaceLogResolver.class), /* connectivityParams */ null, /* preferReplayIfAvailable */ false);
|
||||
EmptyRaceLogStore.INSTANCE,
|
||||
EmptyRegattaLogStore.INSTANCE, EmptyWindStore.INSTANCE, new DummyTrackedRegattaRegistry(),
|
||||
mock(RaceLogResolver.class), createConnectivityParams(httpAndHost, liveURI, storedURI, courseDesignUpdateURI,
|
||||
tracTracUsername, tracTracPassword, "11290bd6-97e7-11e0-9aed-406186cbf87c"));
|
||||
kiwotest3 = domainFactory
|
||||
.createRaceTracker(
|
||||
new URL(
|
||||
httpAndHost
|
||||
+ "/events/event_20110505_SailingTea/clientparams.php?event=event_20110505_SailingTea&race=39635b24-97e7-11e0-9aed-406186cbf87c"),
|
||||
new URI(liveURI), new URI(storedURI), new URI(courseDesignUpdateURI),
|
||||
/* startOfTracking */null, /* endOfTracking */null, /* delayToLiveInMillis */0l, /* offsetToStartTimeOfSimulatedRace */ null, /* ignoreTracTracMarkPassings*/
|
||||
false, EmptyRaceLogStore.INSTANCE, EmptyRegattaLogStore.INSTANCE, EmptyWindStore.INSTANCE,
|
||||
tracTracUsername, tracTracPassword,
|
||||
TracTracConnectionConstants.ONLINE_STATUS, TracTracConnectionConstants.ONLINE_VISIBILITY,
|
||||
new DummyTrackedRegattaRegistry(), mock(RaceLogResolver.class), /* connectivityParams */ null, /* preferReplayIfAvailable */ false);
|
||||
EmptyRaceLogStore.INSTANCE,
|
||||
EmptyRegattaLogStore.INSTANCE, EmptyWindStore.INSTANCE, new DummyTrackedRegattaRegistry(),
|
||||
mock(RaceLogResolver.class), createConnectivityParams(httpAndHost, liveURI, storedURI, courseDesignUpdateURI,
|
||||
tracTracUsername, tracTracPassword, "39635b24-97e7-11e0-9aed-406186cbf87c"));
|
||||
weym470may112014_2 = domainFactory
|
||||
.createRaceTracker(
|
||||
new URL(
|
||||
httpAndHost
|
||||
+ "/events/event_20110505_SailingTea/clientparams.php?event=event_20110505_SailingTea&race=04498426-7dfd-11e0-8236-406186cbf87c"),
|
||||
new URI(liveURI), new URI(storedURI), new URI(courseDesignUpdateURI),
|
||||
/* startOfTracking */null, /* endOfTracking */null, /* delayToLiveInMillis */0l, /* offsetToStartTimeOfSimulatedRace */ null, /* ignoreTracTracMarkPassings*/
|
||||
false, EmptyRaceLogStore.INSTANCE, EmptyRegattaLogStore.INSTANCE, EmptyWindStore.INSTANCE,
|
||||
tracTracUsername, tracTracPassword,
|
||||
TracTracConnectionConstants.ONLINE_STATUS, TracTracConnectionConstants.ONLINE_VISIBILITY,
|
||||
new DummyTrackedRegattaRegistry(), mock(RaceLogResolver.class), /* connectivityParams */ null, /* preferReplayIfAvailable */ false);
|
||||
EmptyRaceLogStore.INSTANCE,
|
||||
EmptyRegattaLogStore.INSTANCE, EmptyWindStore.INSTANCE, new DummyTrackedRegattaRegistry(),
|
||||
mock(RaceLogResolver.class), createConnectivityParams(httpAndHost, liveURI, storedURI, courseDesignUpdateURI,
|
||||
tracTracUsername, tracTracPassword, "04498426-7dfd-11e0-8236-406186cbf87c"));
|
||||
|
||||
assertEquals("STG", kiwotest1.getRegatta().getBoatClass().getName());
|
||||
assertEquals("5O5", kiwotest2.getRegatta().getBoatClass().getName());
|
||||
@@ -105,6 +83,20 @@ public class MultipleClassesInRegattaTest {
|
||||
assertNotSame(kiwotest1.getRegatta(), kiwotest3.getRegatta());
|
||||
assertNotSame(kiwotest2.getRegatta(), kiwotest3.getRegatta());
|
||||
}
|
||||
|
||||
private RaceTrackingConnectivityParametersImpl createConnectivityParams(String httpAndHost, String liveURI,
|
||||
String storedURI, String courseDesignUpdateURI, String tracTracUsername, String tracTracPassword, String raceId)
|
||||
throws Exception, MalformedURLException, URISyntaxException {
|
||||
return new RaceTrackingConnectivityParametersImpl(new URL(
|
||||
httpAndHost
|
||||
+ "/events/event_20110505_SailingTea/clientparams.php?event=event_20110505_SailingTea&race="+raceId),
|
||||
new URI(liveURI), new URI(storedURI), new URI(courseDesignUpdateURI),
|
||||
/* startOfTracking */null, /* endOfTracking */null, /* delayToLiveInMillis */0l,
|
||||
/* offsetToStartTimeOfSimulatedRace */ null, /* ignoreTracTracMarkPassings*/
|
||||
false, EmptyRaceLogStore.INSTANCE, EmptyRegattaLogStore.INSTANCE, domainFactory,
|
||||
tracTracUsername, tracTracPassword, TracTracConnectionConstants.ONLINE_STATUS, TracTracConnectionConstants.ONLINE_VISIBILITY,
|
||||
/* trackWind */ false, /* correctWindDirectionByMagneticDeclination */ true, /* preferReplayIfAvailable */ false);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws MalformedURLException, IOException, InterruptedException {
|
||||
|
||||
+19
-22
@@ -3,12 +3,10 @@ package com.sap.sailing.domain.test;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@@ -26,8 +24,7 @@ import com.sap.sailing.domain.tractracadapter.DomainFactory;
|
||||
import com.sap.sailing.domain.tractracadapter.TracTracConnectionConstants;
|
||||
import com.sap.sailing.domain.tractracadapter.TracTracRaceTracker;
|
||||
import com.sap.sailing.domain.tractracadapter.impl.DomainFactoryImpl;
|
||||
import com.tractrac.model.lib.api.event.CreateModelException;
|
||||
import com.tractrac.subscription.lib.api.SubscriberInitializationException;
|
||||
import com.sap.sailing.domain.tractracadapter.impl.RaceTrackingConnectivityParametersImpl;
|
||||
|
||||
public class UnicodeCharactersInCompetitorNamesTest {
|
||||
protected static final boolean tractracTunnel = Boolean.valueOf(System.getProperty("tractrac.tunnel", "false"));
|
||||
@@ -41,7 +38,7 @@ public class UnicodeCharactersInCompetitorNamesTest {
|
||||
domainFactory = new DomainFactoryImpl(new com.sap.sailing.domain.base.impl.DomainFactoryImpl((srlid)->null));
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException, CreateModelException, SubscriberInitializationException {
|
||||
public static void main(String[] args) throws Exception {
|
||||
UnicodeCharactersInCompetitorNamesTest t = new UnicodeCharactersInCompetitorNamesTest();
|
||||
t.setUp();
|
||||
t.readJSONURLAndCheckCompetitorNames();
|
||||
@@ -49,28 +46,28 @@ public class UnicodeCharactersInCompetitorNamesTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindUnicodeCharactersInCompetitorNames() throws MalformedURLException, FileNotFoundException,
|
||||
URISyntaxException, IOException, InterruptedException, CreateModelException,
|
||||
SubscriberInitializationException {
|
||||
public void testFindUnicodeCharactersInCompetitorNames() throws Exception {
|
||||
TracTracRaceTracker fourtyninerYellow_2 = domainFactory
|
||||
.createRaceTracker(
|
||||
new URL(
|
||||
EmptyRaceLogStore.INSTANCE,
|
||||
EmptyRegattaLogStore.INSTANCE,
|
||||
EmptyWindStore.INSTANCE, new DummyTrackedRegattaRegistry(),
|
||||
mock(RaceLogResolver.class), new RaceTrackingConnectivityParametersImpl(new URL(
|
||||
"http://"
|
||||
+ TracTracConnectionConstants.HOST_NAME
|
||||
+ "/events/event_20110609_KielerWoch/clientparams.php?event=event_20110609_KielerWoch&race=5b08a9ee-9933-11e0-85be-406186cbf87c"),
|
||||
tractracTunnel ? new URI("tcp://" + tractracTunnelHost + ":"
|
||||
+ TracTracConnectionConstants.PORT_TUNNEL_LIVE) : new URI("tcp://"
|
||||
+ TracTracConnectionConstants.HOST_NAME + ":" + TracTracConnectionConstants.PORT_LIVE),
|
||||
tractracTunnel ? new URI("tcp://" + tractracTunnelHost + ":"
|
||||
+ TracTracConnectionConstants.PORT_TUNNEL_STORED)
|
||||
: new URI("tcp://" + TracTracConnectionConstants.HOST_NAME + ":"
|
||||
+ TracTracConnectionConstants.PORT_STORED), new URI(
|
||||
"http://tracms.traclive.dk/update_course"),
|
||||
/* startOfTracking */null, /* endOfTracking */null, /* delayToLiveInMillis */0l,
|
||||
/* offsetToStartTimeOfSimulatedRace */ null, /* ignoreTracTracMarkPassings*/
|
||||
false, EmptyRaceLogStore.INSTANCE, EmptyRegattaLogStore.INSTANCE,
|
||||
EmptyWindStore.INSTANCE, "tracTest", "tracTest", "", "",
|
||||
new DummyTrackedRegattaRegistry(), mock(RaceLogResolver.class), /* connectivityParams */ null, /* preferReplayIfAvailable */ false);
|
||||
tractracTunnel ? new URI("tcp://" + tractracTunnelHost + ":"
|
||||
+ TracTracConnectionConstants.PORT_TUNNEL_LIVE) : new URI("tcp://"
|
||||
+ TracTracConnectionConstants.HOST_NAME + ":" + TracTracConnectionConstants.PORT_LIVE),
|
||||
tractracTunnel ? new URI("tcp://" + tractracTunnelHost + ":"
|
||||
+ TracTracConnectionConstants.PORT_TUNNEL_STORED)
|
||||
: new URI("tcp://" + TracTracConnectionConstants.HOST_NAME + ":"
|
||||
+ TracTracConnectionConstants.PORT_STORED),
|
||||
new URI("http://tracms.traclive.dk/update_course"),
|
||||
/* startOfTracking */null, /* endOfTracking */null, /* delayToLiveInMillis */0l,
|
||||
/* offsetToStartTimeOfSimulatedRace */ null, /* ignoreTracTracMarkPassings*/
|
||||
false, EmptyRaceLogStore.INSTANCE, EmptyRegattaLogStore.INSTANCE, domainFactory,
|
||||
"tracTest", "tracTest", "", "", /* trackWind */ false, /* correctWindDirectionByMagneticDeclination */ true, /* preferReplayIfAvailable */ false));
|
||||
|
||||
Iterable<Competitor> competitors = fourtyninerYellow_2.getRaceHandle().getRace().getCompetitors();
|
||||
for (Competitor competitor : competitors) {
|
||||
|
||||
+1
-3
@@ -1,8 +1,6 @@
|
||||
package com.sap.sailing.domain.tractracadapter.persistence.impl;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -74,7 +72,7 @@ public class TracTracConnectivityParamsHandler extends AbstractRaceTrackingConne
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceTrackingConnectivityParameters mapTo(Map<String, Object> map) throws MalformedURLException, URISyntaxException {
|
||||
public RaceTrackingConnectivityParameters mapTo(Map<String, Object> map) throws Exception {
|
||||
return new RaceTrackingConnectivityParametersImpl(
|
||||
new URL(map.get(PARAM_URL).toString()),
|
||||
map.get(LIVE_URI) == null ? null : new URI(map.get(LIVE_URI).toString()),
|
||||
|
||||
+5
-39
@@ -124,55 +124,21 @@ public interface DomainFactory {
|
||||
* respond with the {@link RaceDefinition} when its {@link DomainFactory#getRaceID(IRace)} is called with the
|
||||
* TracTrac {@link IEvent} as argument that is used for its tracking.
|
||||
* <p>
|
||||
*
|
||||
* @param startOfTracking
|
||||
* if <code>null</code>, all stored data from the "beginning of time" will be loaded that the event has
|
||||
* to provide, particularly for the mark positions which are stored per event, not per race; otherwise,
|
||||
* particularly the mark position loading will be constrained to this start time.
|
||||
* @param endOfTracking
|
||||
* if <code>null</code>, all stored data until the "end of time" will be loaded that the event has to
|
||||
* provide, particularly for the mark positions which are stored per event, not per race; otherwise,
|
||||
* particularly the mark position loading will be constrained to this end time.
|
||||
* @param offsetToStartTimeOfSimulatedRace
|
||||
* if non-<code>null</code>, the {@link Simulator} will be used with this duration as start offset
|
||||
* @param windStore
|
||||
* Provides the capability to obtain the {@link WindTrack}s for the different wind sources. A trivial
|
||||
* implementation is {@link EmptyWindStore} which simply provides new, empty tracks. This is always
|
||||
* available but loses track of the wind, e.g., during server restarts.
|
||||
* @param preferReplayIfAvailable
|
||||
* when a non-{@code null} {@code storedURI} and/or {@code liveURI} are provided and the {@link IRace}
|
||||
* specifies something different and claims to be in replay mode ({@link IRace#getConnectionType} is
|
||||
* {@code File}) then if this parameter is {@code true} the race will be loaded from the replay file
|
||||
* instead of the {@code storedURI}/{@code liveURI} specified. This is particularly useful for restoring
|
||||
* races if since the last connection the race was migrated to a replay file format.
|
||||
*/
|
||||
TracTracRaceTracker createRaceTracker(URL paramURL, URI liveURI, URI storedURI, URI courseDesignUpdateURI,
|
||||
TimePoint startOfTracking, TimePoint endOfTracking, long delayToLiveInMillis,
|
||||
Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm, RaceLogStore raceLogStore, RegattaLogStore regattaLogStore,
|
||||
WindStore windStore, String tracTracUsername, String tracTracPassword,
|
||||
String raceStatus, String raceVisibility, TrackedRegattaRegistry trackedRegattaRegistry, RaceLogResolver raceLogResolver,
|
||||
RaceTrackingConnectivityParametersImpl connectivityParams, boolean preferReplayIfAvailable)
|
||||
TracTracRaceTracker createRaceTracker(RaceLogStore raceLogStore, RegattaLogStore regattaLogStore, WindStore windStore, TrackedRegattaRegistry trackedRegattaRegistry,
|
||||
RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams)
|
||||
throws MalformedURLException, FileNotFoundException, URISyntaxException, CreateModelException, SubscriberInitializationException;
|
||||
|
||||
/**
|
||||
* Same as {@link #createRaceTracker(URL, URI, URI, URI, TimePoint, TimePoint, WindStore, TrackedRegattaRegistry)},
|
||||
* only that a predefined {@link Regatta} is used to hold the resulting races.
|
||||
*
|
||||
* @param offsetToStartTimeOfSimulatedRace
|
||||
* if non-<code>null</code>, the {@link Simulator} will be used with this duration as start offset
|
||||
* @param preferReplayIfAvailable
|
||||
* when a non-{@code null} {@code storedURI} and/or {@code liveURI} are provided and the {@link IRace}
|
||||
* specifies something different and claims to be in replay mode ({@link IRace#getConnectionType} is
|
||||
* {@code File}) then if this parameter is {@code true} the race will be loaded from the replay file
|
||||
* instead of the {@code storedURI}/{@code liveURI} specified. This is particularly useful for restoring
|
||||
* races if since the last connection the race was migrated to a replay file format.
|
||||
*/
|
||||
RaceTracker createRaceTracker(Regatta regatta, URL paramURL, URI liveURI, URI storedURI, URI courseDesignUpdateURI,
|
||||
TimePoint startOfTracking, TimePoint endOfTracking, long delayToLiveInMillis,
|
||||
Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm, RaceLogStore raceLogStore, RegattaLogStore regattaLogStore,
|
||||
WindStore windStore, String tracTracUsername, String tracTracPassword,
|
||||
String raceStatus, String raceVisibility, TrackedRegattaRegistry trackedRegattaRegistry, RaceLogResolver raceLogResolver,
|
||||
RaceTrackingConnectivityParametersImpl connectivityParams, boolean preferReplayIfAvailable)
|
||||
RaceTracker createRaceTracker(Regatta regatta, RaceLogStore raceLogStore, RegattaLogStore regattaLogStore, WindStore windStore, TrackedRegattaRegistry trackedRegattaRegistry,
|
||||
RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams)
|
||||
throws MalformedURLException, FileNotFoundException, URISyntaxException, CreateModelException,
|
||||
SubscriberInitializationException;
|
||||
|
||||
@@ -291,7 +257,7 @@ public interface DomainFactory {
|
||||
URI courseDesignUpdateURI, TimePoint startOfTracking, TimePoint endOfTracking, long delayToLiveInMillis,
|
||||
Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm, RaceLogStore raceLogStore, RegattaLogStore regattaLogStore,
|
||||
String tracTracUsername, String tracTracPassword, String raceStatus, String raceVisibility, boolean trackWind, boolean correctWindDirectionByMagneticDeclination,
|
||||
boolean preferReplayIfAvailable);
|
||||
boolean preferReplayIfAvailable) throws Exception;
|
||||
/**
|
||||
* Removes all knowledge about <code>tractracRace</code> which includes removing it from the race cache, from the
|
||||
* {@link com.sap.sailing.domain.base.Regatta} and, if a {@link TrackedRace} for the corresponding
|
||||
|
||||
+8
-23
@@ -652,34 +652,19 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TracTracRaceTracker createRaceTracker(URL paramURL, URI liveURI, URI storedURI, URI courseDesignUpdateURI,
|
||||
TimePoint startOfTracking, TimePoint endOfTracking, long delayToLiveInMillis,
|
||||
Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm,
|
||||
RaceLogStore raceLogStore, RegattaLogStore regattaLogStore, WindStore windStore, String tracTracUsername,
|
||||
String tracTracPassword, String raceStatus, String raceVisibility,
|
||||
TrackedRegattaRegistry trackedRegattaRegistry, RaceLogResolver raceLogResolver,
|
||||
RaceTrackingConnectivityParametersImpl connectivityParams, boolean preferReplayIfAvailable) throws MalformedURLException,
|
||||
public TracTracRaceTracker createRaceTracker(RaceLogStore raceLogStore, RegattaLogStore regattaLogStore, WindStore windStore, TrackedRegattaRegistry trackedRegattaRegistry,
|
||||
RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams) throws MalformedURLException,
|
||||
FileNotFoundException, URISyntaxException, CreateModelException, SubscriberInitializationException {
|
||||
return new TracTracRaceTrackerImpl(this, paramURL, liveURI, storedURI, courseDesignUpdateURI, startOfTracking,
|
||||
endOfTracking, delayToLiveInMillis, offsetToStartTimeOfSimulatedRace, useInternalMarkPassingAlgorithm,
|
||||
raceLogStore, regattaLogStore, windStore, tracTracUsername, tracTracPassword, raceStatus,
|
||||
raceVisibility, trackedRegattaRegistry, raceLogResolver, connectivityParams, preferReplayIfAvailable);
|
||||
return new TracTracRaceTrackerImpl(this, raceLogStore, regattaLogStore, windStore, trackedRegattaRegistry, raceLogResolver, connectivityParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceTracker createRaceTracker(Regatta regatta, URL paramURL, URI liveURI, URI storedURI,
|
||||
URI courseDesignUpdateURI, TimePoint startOfTracking, TimePoint endOfTracking, long delayToLiveInMillis,
|
||||
Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm, RaceLogStore raceLogStore,
|
||||
RegattaLogStore regattaLogStore, WindStore windStore, String tracTracUsername,
|
||||
String tracTracPassword, String raceStatus, String raceVisibility,
|
||||
TrackedRegattaRegistry trackedRegattaRegistry, RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams,
|
||||
boolean preferReplayIfAvailable)
|
||||
public RaceTracker createRaceTracker(Regatta regatta, RaceLogStore raceLogStore, RegattaLogStore regattaLogStore, WindStore windStore,
|
||||
TrackedRegattaRegistry trackedRegattaRegistry, RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams)
|
||||
throws MalformedURLException, FileNotFoundException, URISyntaxException, CreateModelException,
|
||||
SubscriberInitializationException {
|
||||
return new TracTracRaceTrackerImpl(regatta, this, paramURL, liveURI, storedURI, courseDesignUpdateURI,
|
||||
startOfTracking, endOfTracking, delayToLiveInMillis, offsetToStartTimeOfSimulatedRace, useInternalMarkPassingAlgorithm, raceLogStore,
|
||||
regattaLogStore, windStore, tracTracUsername, tracTracPassword, raceStatus,
|
||||
raceVisibility, trackedRegattaRegistry, raceLogResolver, connectivityParams, preferReplayIfAvailable);
|
||||
return new TracTracRaceTrackerImpl(regatta, this, raceLogStore, regattaLogStore, windStore, trackedRegattaRegistry,
|
||||
raceLogResolver, connectivityParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -697,7 +682,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
URI storedURI, URI courseDesignUpdateURI, TimePoint startOfTracking, TimePoint endOfTracking,
|
||||
long delayToLiveInMillis, Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm, RaceLogStore raceLogStore,
|
||||
RegattaLogStore regattaLogStore, String tracTracUsername, String tracTracPassword, String raceStatus,
|
||||
String raceVisibility, boolean trackWind, boolean correctWindDirectionByMagneticDeclination, boolean preferReplayIfAvailable) {
|
||||
String raceVisibility, boolean trackWind, boolean correctWindDirectionByMagneticDeclination, boolean preferReplayIfAvailable) throws Exception {
|
||||
return new RaceTrackingConnectivityParametersImpl(paramURL, liveURI, storedURI, courseDesignUpdateURI,
|
||||
startOfTracking, endOfTracking, delayToLiveInMillis, offsetToStartTimeOfSimulatedRace, useInternalMarkPassingAlgorithm, raceLogStore,
|
||||
regattaLogStore, this, tracTracUsername, tracTracPassword, raceStatus, raceVisibility, trackWind, correctWindDirectionByMagneticDeclination,
|
||||
|
||||
+37
-13
@@ -5,6 +5,7 @@ import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceLogResolver;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
@@ -17,11 +18,14 @@ import com.sap.sailing.domain.tracking.impl.AbstractRaceTrackingConnectivityPara
|
||||
import com.sap.sailing.domain.tractracadapter.DomainFactory;
|
||||
import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.tractrac.model.lib.api.ModelLocator;
|
||||
import com.tractrac.model.lib.api.event.CreateModelException;
|
||||
import com.tractrac.model.lib.api.event.IRace;
|
||||
import com.tractrac.subscription.lib.api.SubscriberInitializationException;
|
||||
|
||||
public class RaceTrackingConnectivityParametersImpl extends AbstractRaceTrackingConnectivityParameters {
|
||||
private static final Logger logger = Logger.getLogger(RaceTrackingConnectivityParametersImpl.class.getName());
|
||||
public static final String TYPE = "TRAC_TRAC";
|
||||
|
||||
private final URL paramURL;
|
||||
@@ -41,6 +45,7 @@ public class RaceTrackingConnectivityParametersImpl extends AbstractRaceTracking
|
||||
private final String raceVisibility;
|
||||
private final boolean useInternalMarkPassingAlgorithm;
|
||||
private final boolean preferReplayIfAvailable;
|
||||
private final IRace tractracRace;
|
||||
|
||||
/**
|
||||
* @param preferReplayIfAvailable
|
||||
@@ -52,13 +57,25 @@ public class RaceTrackingConnectivityParametersImpl extends AbstractRaceTracking
|
||||
*/
|
||||
public RaceTrackingConnectivityParametersImpl(URL paramURL, URI liveURI, URI storedURI, URI courseDesignUpdateURI,
|
||||
TimePoint startOfTracking, TimePoint endOfTracking, long delayToLiveInMillis,
|
||||
Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm, RaceLogStore raceLogStore, RegattaLogStore regattaLogStore,
|
||||
DomainFactory domainFactory, String tracTracUsername, String tracTracPassword, String raceStatus,
|
||||
String raceVisibility, boolean trackWind, boolean correctWindDirectionByMagneticDeclination, boolean preferReplayIfAvailable) {
|
||||
Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm,
|
||||
RaceLogStore raceLogStore, RegattaLogStore regattaLogStore, DomainFactory domainFactory,
|
||||
String tracTracUsername, String tracTracPassword, String raceStatus, String raceVisibility,
|
||||
boolean trackWind, boolean correctWindDirectionByMagneticDeclination, boolean preferReplayIfAvailable)
|
||||
throws Exception {
|
||||
super(trackWind, correctWindDirectionByMagneticDeclination);
|
||||
this.paramURL = paramURL;
|
||||
this.liveURI = liveURI;
|
||||
this.storedURI = storedURI;
|
||||
this.tractracRace = ModelLocator.getEventFactory().createRace(new URI(paramURL.toString()));
|
||||
if (preferReplayIfAvailable && isReplayRace(tractracRace) &&
|
||||
(!Util.equalsWithNull(liveURI, tractracRace.getLiveURI()) || !Util.equalsWithNull(storedURI, tractracRace.getStoredURI()))) {
|
||||
logger.info("Replay format available and preferred for race " + tractracRace.getName()
|
||||
+ "; using storedURI " + tractracRace.getStoredURI() + " instead of " + storedURI
|
||||
+ " and liveURI " + tractracRace.getLiveURI() + " instead of " + liveURI);
|
||||
this.liveURI = tractracRace.getLiveURI();
|
||||
this.storedURI = tractracRace.getStoredURI();
|
||||
} else {
|
||||
this.liveURI = liveURI;
|
||||
this.storedURI = storedURI;
|
||||
}
|
||||
this.courseDesignUpdateURI = courseDesignUpdateURI;
|
||||
this.startOfTracking = startOfTracking;
|
||||
this.endOfTracking = endOfTracking;
|
||||
@@ -75,6 +92,15 @@ public class RaceTrackingConnectivityParametersImpl extends AbstractRaceTracking
|
||||
this.preferReplayIfAvailable = preferReplayIfAvailable;
|
||||
}
|
||||
|
||||
private boolean isReplayRace(IRace tractracRace) {
|
||||
// TODO bug 4037: change into tractracRace.getConnectionType() == File once TracAPI 3.3.2 is available
|
||||
return tractracRace.getStoredURI() != null && tractracRace.getStoredURI().toString().toLowerCase().endsWith(".mtb");
|
||||
}
|
||||
|
||||
public IRace getTractracRace() {
|
||||
return tractracRace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeIdentifier() {
|
||||
return TYPE;
|
||||
@@ -84,20 +110,15 @@ public class RaceTrackingConnectivityParametersImpl extends AbstractRaceTracking
|
||||
public RaceTracker createRaceTracker(TrackedRegattaRegistry trackedRegattaRegistry, WindStore windStore,
|
||||
RaceLogResolver raceLogResolver) throws MalformedURLException, FileNotFoundException, URISyntaxException,
|
||||
CreateModelException, SubscriberInitializationException {
|
||||
RaceTracker tracker = domainFactory.createRaceTracker(paramURL, liveURI, storedURI, courseDesignUpdateURI,
|
||||
startOfTracking, endOfTracking, delayToLiveInMillis, offsetToStartTimeOfSimulatedRace, useInternalMarkPassingAlgorithm, raceLogStore,
|
||||
regattaLogStore, windStore, tracTracUsername, tracTracPassword, raceStatus,
|
||||
raceVisibility, trackedRegattaRegistry, raceLogResolver, this, preferReplayIfAvailable);
|
||||
RaceTracker tracker = domainFactory.createRaceTracker(raceLogStore, regattaLogStore, windStore, trackedRegattaRegistry, raceLogResolver, this);
|
||||
return tracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceTracker createRaceTracker(Regatta regatta, TrackedRegattaRegistry trackedRegattaRegistry,
|
||||
WindStore windStore, RaceLogResolver raceLogResolver) throws Exception {
|
||||
RaceTracker tracker = domainFactory.createRaceTracker(regatta, paramURL, liveURI, storedURI,
|
||||
courseDesignUpdateURI, startOfTracking, endOfTracking, delayToLiveInMillis, offsetToStartTimeOfSimulatedRace, useInternalMarkPassingAlgorithm,
|
||||
raceLogStore, regattaLogStore, windStore, tracTracUsername, tracTracPassword, raceStatus,
|
||||
raceVisibility, trackedRegattaRegistry, raceLogResolver, this, preferReplayIfAvailable);
|
||||
RaceTracker tracker = domainFactory.createRaceTracker(regatta, raceLogStore, regattaLogStore, windStore,
|
||||
trackedRegattaRegistry, raceLogResolver, this);
|
||||
return tracker;
|
||||
}
|
||||
|
||||
@@ -159,4 +180,7 @@ public class RaceTrackingConnectivityParametersImpl extends AbstractRaceTracking
|
||||
return useInternalMarkPassingAlgorithm;
|
||||
}
|
||||
|
||||
public boolean isPreferReplayIfAvailable() {
|
||||
return preferReplayIfAvailable;
|
||||
}
|
||||
}
|
||||
+34
-116
@@ -53,8 +53,6 @@ import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.util.impl.ThreadFactoryWithPriority;
|
||||
import com.tractrac.model.lib.api.ModelLocator;
|
||||
import com.tractrac.model.lib.api.event.CreateModelException;
|
||||
import com.tractrac.model.lib.api.event.ICompetitor;
|
||||
import com.tractrac.model.lib.api.event.IEvent;
|
||||
import com.tractrac.model.lib.api.event.IRace;
|
||||
@@ -238,62 +236,19 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl
|
||||
* respond with the {@link RaceDefinition} when its {@link DomainFactory#getRaceID(com.tractrac.model.lib.api.event.IRace)} is called with the
|
||||
* TracTrac {@link IEvent} as argument that is used for its tracking.
|
||||
* <p>
|
||||
* @param startOfTracking
|
||||
* if <code>null</code>, all stored data from the "beginning of time" will be loaded that the event has
|
||||
* to provide, particularly for the mark positions which are stored per event, not per race; otherwise,
|
||||
* particularly the mark position loading will be constrained to this start time.
|
||||
* @param endOfTracking
|
||||
* if <code>null</code>, all stored data until the "end of time" will be loaded that the event has to
|
||||
* provide, particularly for the mark positions which are stored per event, not per race; otherwise,
|
||||
* particularly the mark position loading will be constrained to this end time.
|
||||
* @param windStore
|
||||
* Provides the capability to obtain the {@link WindTrack}s for the different wind sources. A trivial
|
||||
* implementation is {@link EmptyWindStore} which simply provides new, empty tracks. This is always
|
||||
* available but loses track of the wind, e.g., during server restarts.
|
||||
* @param trackedRegattaRegistry
|
||||
* used to create the {@link TrackedRegatta} for the domain event
|
||||
* @param preferReplayIfAvailable
|
||||
* when a non-{@code null} {@code storedURI} and/or {@code liveURI} are provided and the {@link IRace}
|
||||
* specifies something different and claims to be in replay mode ({@link IRace#getConnectionType} is
|
||||
* {@code File}) then if this parameter is {@code true} the race will be loaded from the replay file
|
||||
* instead of the {@code storedURI}/{@code liveURI} specified. This is particularly useful for restoring
|
||||
* races if since the last connection the race was migrated to a replay file format.
|
||||
*/
|
||||
protected TracTracRaceTrackerImpl(DomainFactory domainFactory, URL paramURL, URI liveURI, URI storedURI,
|
||||
URI courseDesignUpdateURI, TimePoint startOfTracking, TimePoint endOfTracking, long delayToLiveInMillis,
|
||||
Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm, RaceLogStore raceLogStore, RegattaLogStore regattaLogStore,
|
||||
WindStore windStore, String tracTracUsername, String tracTracPassword,
|
||||
String raceStatus, String raceVisibility, TrackedRegattaRegistry trackedRegattaRegistry, RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams,
|
||||
boolean preferReplayIfAvailable)
|
||||
throws URISyntaxException, MalformedURLException, FileNotFoundException, CreateModelException,
|
||||
SubscriberInitializationException {
|
||||
this(ModelLocator.getEventFactory().createRace(new URI(paramURL.toString())), domainFactory, paramURL, liveURI,
|
||||
storedURI, courseDesignUpdateURI, startOfTracking, endOfTracking, delayToLiveInMillis,
|
||||
offsetToStartTimeOfSimulatedRace, useInternalMarkPassingAlgorithm, raceLogStore, regattaLogStore,
|
||||
windStore, tracTracUsername,
|
||||
tracTracPassword, raceStatus, raceVisibility, trackedRegattaRegistry, raceLogResolver, connectivityParams, preferReplayIfAvailable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param preferReplayIfAvailable
|
||||
* when a non-{@code null} {@code storedURI} and/or {@code liveURI} are provided and the {@link IRace}
|
||||
* specifies something different and claims to be in replay mode ({@link IRace#getConnectionType} is
|
||||
* {@code File}) then if this parameter is {@code true} the race will be loaded from the replay file
|
||||
* instead of the {@code storedURI}/{@code liveURI} specified. This is particularly useful for restoring
|
||||
* races if since the last connection the race was migrated to a replay file format.
|
||||
*/
|
||||
private TracTracRaceTrackerImpl(IRace tractracRace, DomainFactory domainFactory, URL paramURL, URI liveURI,
|
||||
URI storedURI, URI courseDesignUpdateURI, TimePoint startOfTracking, TimePoint endOfTracking,
|
||||
long delayToLiveInMillis, Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm, RaceLogStore raceLogStore,
|
||||
RegattaLogStore regattaLogStore, WindStore windStore, String tracTracUsername,
|
||||
String tracTracPassword, String raceStatus, String raceVisibility,
|
||||
TrackedRegattaRegistry trackedRegattaRegistry, RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams,
|
||||
boolean preferReplayIfAvailable) throws URISyntaxException, MalformedURLException,
|
||||
FileNotFoundException, SubscriberInitializationException {
|
||||
this(tractracRace, /* regatta */ null, domainFactory, paramURL, liveURI, storedURI, courseDesignUpdateURI, startOfTracking,
|
||||
endOfTracking, delayToLiveInMillis, offsetToStartTimeOfSimulatedRace, useInternalMarkPassingAlgorithm, raceLogStore, regattaLogStore, windStore,
|
||||
tracTracUsername, tracTracPassword, raceStatus, raceVisibility, trackedRegattaRegistry,
|
||||
raceLogResolver, connectivityParams, preferReplayIfAvailable);
|
||||
TracTracRaceTrackerImpl(DomainFactory domainFactory, RaceLogStore raceLogStore,
|
||||
RegattaLogStore regattaLogStore, WindStore windStore, TrackedRegattaRegistry trackedRegattaRegistry,
|
||||
RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams)
|
||||
throws URISyntaxException, MalformedURLException, FileNotFoundException, SubscriberInitializationException {
|
||||
this(/* regatta */ null, domainFactory, raceLogStore, regattaLogStore, windStore, trackedRegattaRegistry,
|
||||
raceLogResolver, connectivityParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,72 +257,31 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl
|
||||
* create a default {@link Regatta} with only a single default {@link Series} and {@link Fleet} which may not always
|
||||
* be what you want.
|
||||
*
|
||||
* @param preferReplayIfAvailable
|
||||
* when a non-{@code null} {@code storedURI} and/or {@code liveURI} are provided and the {@link IRace}
|
||||
* specifies something different and claims to be in replay mode ({@link IRace#getConnectionType} is
|
||||
* {@code File}) then if this parameter is {@code true} the race will be loaded from the replay file
|
||||
* instead of the {@code storedURI}/{@code liveURI} specified. This is particularly useful for restoring
|
||||
* races if since the last connection the race was migrated to a replay file format.
|
||||
*/
|
||||
protected TracTracRaceTrackerImpl(Regatta regatta, DomainFactory domainFactory, URL paramURL, URI liveURI,
|
||||
URI storedURI, URI courseDesignUpdateURI, TimePoint startOfTracking, TimePoint endOfTracking,
|
||||
long delayToLiveInMillis, Duration offsetToStartTimeOfSimulatedRace, boolean ignoreTracTracMarkPassings, RaceLogStore raceLogStore,
|
||||
RegattaLogStore regattaLogStore, WindStore windStore, String tracTracUsername,
|
||||
String tracTracPassword, String raceStatus, String raceVisibility,
|
||||
TrackedRegattaRegistry trackedRegattaRegistry, RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams,
|
||||
boolean preferReplayIfAvailable) throws URISyntaxException,
|
||||
MalformedURLException, FileNotFoundException, CreateModelException, SubscriberInitializationException {
|
||||
this(ModelLocator.getEventFactory().createRace(new URI(paramURL.toString())), regatta, domainFactory, paramURL,
|
||||
liveURI, storedURI, courseDesignUpdateURI, startOfTracking, endOfTracking, delayToLiveInMillis,
|
||||
offsetToStartTimeOfSimulatedRace, ignoreTracTracMarkPassings, raceLogStore, regattaLogStore, windStore,
|
||||
tracTracUsername,
|
||||
tracTracPassword, raceStatus, raceVisibility, trackedRegattaRegistry, raceLogResolver, connectivityParams, preferReplayIfAvailable);
|
||||
}
|
||||
|
||||
private boolean isReplayRace(IRace tractracRace) {
|
||||
// TODO bug 4037: change into tractracRace.getConnectionType() == File once TracAPI 3.3.2 is available
|
||||
return tractracRace.getStoredURI() != null && tractracRace.getStoredURI().toString().toLowerCase().endsWith(".mtb");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param regatta
|
||||
* if <code>null</code>, then <code>domainFactory.getOrCreateRegatta(tractracEvent)</code> will be used
|
||||
* to obtain a default regatta
|
||||
* @param offsetToStartTimeOfSimulatedRace
|
||||
* if not <code>null</code>, the connector will adjust the time stamps of all events received such that
|
||||
* the first mark passing for the first waypoint will be set to "now." It will delay the forwarding of
|
||||
* all events received such that they seem to be sent in "real-time" +
|
||||
* <code>offsetToStartTimeOfSimulatedRace</code> So, more or less the time points attached to the events
|
||||
* sent to the receivers will again approximate the wall time.
|
||||
* @param preferReplayIfAvailable
|
||||
* when a non-{@code null} {@code storedURI} and/or {@code liveURI} are provided and the {@link IRace}
|
||||
* specifies something different and claims to be in replay mode ({@link IRace#getConnectionType} is
|
||||
* {@code File}) then if this parameter is {@code true} the race will be loaded from the replay file
|
||||
* instead of the {@code storedURI}/{@code liveURI} specified. This is particularly useful for restoring
|
||||
* races if since the last connection the race was migrated to a replay file format.
|
||||
*/
|
||||
private TracTracRaceTrackerImpl(IRace tractracRace, final Regatta regatta, DomainFactory domainFactory,
|
||||
URL paramURL, URI liveURI, URI storedURI, URI tracTracUpdateURI, TimePoint startOfTracking,
|
||||
TimePoint endOfTracking, long delayToLiveInMillis, Duration offsetToStartTimeOfSimulatedRace, boolean useInternalMarkPassingAlgorithm,
|
||||
RaceLogStore raceLogStore, RegattaLogStore regattaLogStore, WindStore windStore,
|
||||
String tracTracUsername, String tracTracPassword, String raceStatus, String raceVisibility,
|
||||
TrackedRegattaRegistry trackedRegattaRegistry, RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams,
|
||||
boolean preferReplayIfAvailable) throws URISyntaxException, MalformedURLException,
|
||||
FileNotFoundException, SubscriberInitializationException {
|
||||
TracTracRaceTrackerImpl(final Regatta regatta, DomainFactory domainFactory, RaceLogStore raceLogStore,
|
||||
RegattaLogStore regattaLogStore, WindStore windStore, TrackedRegattaRegistry trackedRegattaRegistry,
|
||||
RaceLogResolver raceLogResolver, RaceTrackingConnectivityParametersImpl connectivityParams)
|
||||
throws URISyntaxException, MalformedURLException, FileNotFoundException, SubscriberInitializationException {
|
||||
super(connectivityParams);
|
||||
final URL paramURL = connectivityParams.getParamURL();
|
||||
final URI liveURI = connectivityParams.getLiveURI();
|
||||
final URI storedURI = connectivityParams.getStoredURI();
|
||||
final URI tracTracUpdateURI = connectivityParams.getCourseDesignUpdateURI();
|
||||
final TimePoint startOfTracking = connectivityParams.getStartOfTracking();
|
||||
final TimePoint endOfTracking = connectivityParams.getEndOfTracking();
|
||||
final long delayToLiveInMillis = connectivityParams.getDelayToLiveInMillis();
|
||||
final Duration offsetToStartTimeOfSimulatedRace = connectivityParams.getOffsetToStartTimeOfSimulatedRace();
|
||||
final boolean useInternalMarkPassingAlgorithm = connectivityParams.isUseInternalMarkPassingAlgorithm();
|
||||
final String tracTracUsername = connectivityParams.getTracTracUsername();
|
||||
final String tracTracPassword = connectivityParams.getTracTracPassword();
|
||||
final String raceStatus = connectivityParams.getRaceStatus();
|
||||
final String raceVisibility = connectivityParams.getRaceVisibility();
|
||||
this.trackedRegattaRegistry = trackedRegattaRegistry;
|
||||
this.tractracRace = tractracRace;
|
||||
this.tractracRace = connectivityParams.getTractracRace();
|
||||
this.tractracEvent = tractracRace.getEvent();
|
||||
if (preferReplayIfAvailable && isReplayRace(tractracRace)) {
|
||||
if (!Util.equalsWithNull(liveURI, tractracRace.getLiveURI())
|
||||
|| !Util.equalsWithNull(storedURI, tractracRace.getStoredURI())) {
|
||||
logger.info("Replay format available and preferred for race " + tractracRace.getName()
|
||||
+ "; using storedURI " + tractracRace.getStoredURI() + " instead of " + storedURI
|
||||
+ " and liveURI " + tractracRace.getLiveURI() + " instead of " + liveURI);
|
||||
liveURI = tractracRace.getLiveURI();
|
||||
storedURI = tractracRace.getStoredURI();
|
||||
}
|
||||
}
|
||||
this.id = createID(paramURL, liveURI, storedURI);
|
||||
isLiveTracking = liveURI != null;
|
||||
this.race = null; // no race received yet
|
||||
@@ -383,17 +297,21 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl
|
||||
}
|
||||
// check if there is a directory configured where stored data files can be cached
|
||||
// only cache files for races in REPLAY state
|
||||
final URI effectifeStoredURI; // may be altered by legacy caching mechanism; won't affect this tracker's ID
|
||||
if ( (raceStatus != null && raceStatus.equals(TracTracConnectionConstants.REPLAY_STATUS)) ||
|
||||
(raceVisibility != null && raceVisibility.equals(TracTracConnectionConstants.REPLAY_VISIBILITY)) ) {
|
||||
storedURI = checkForCachedStoredData(storedURI);
|
||||
effectifeStoredURI = checkForCachedStoredData(storedURI);
|
||||
} else {
|
||||
effectifeStoredURI = storedURI;
|
||||
}
|
||||
|
||||
logger.info("Starting race tracker: " + tractracRace.getName() + " " + paramURL + " " + liveURI + " "
|
||||
+ storedURI + " startOfTracking:" + (startOfTracking != null ? startOfTracking.asMillis() : "n/a") + " endOfTracking:" + (endOfTracking != null ? endOfTracking.asMillis() : "n/a"));
|
||||
|
||||
+ effectifeStoredURI + " startOfTracking:"
|
||||
+ (startOfTracking != null ? startOfTracking.asMillis() : "n/a") + " endOfTracking:"
|
||||
+ (endOfTracking != null ? endOfTracking.asMillis() : "n/a"));
|
||||
|
||||
// Initialize data controller using live and stored data sources
|
||||
ISubscriberFactory subscriberFactory = SubscriptionLocator.getSusbcriberFactory();
|
||||
eventSubscriber = subscriberFactory.createEventSubscriber(tractracEvent, liveURI, storedURI);
|
||||
eventSubscriber = subscriberFactory.createEventSubscriber(tractracEvent, liveURI, effectifeStoredURI);
|
||||
eventSubscriber.subscribeCompetitors(new ICompetitorsListener() {
|
||||
@Override
|
||||
public void updateCompetitor(ICompetitor competitor) {
|
||||
@@ -432,7 +350,7 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl
|
||||
});
|
||||
// Start live and stored data streams
|
||||
final Regatta effectiveRegatta;
|
||||
raceSubscriber = subscriberFactory.createRaceSubscriber(tractracRace, liveURI, storedURI);
|
||||
raceSubscriber = subscriberFactory.createRaceSubscriber(tractracRace, liveURI, effectifeStoredURI);
|
||||
raceSubscriber.subscribeConnectionStatus(this);
|
||||
// Try to find a pre-associated event based on the Race ID
|
||||
if (regatta == null) {
|
||||
|
||||
+2
-2
@@ -263,7 +263,7 @@ public class MarkPassingCalculator {
|
||||
logger.fine("MPC for "+raceName+" received "+ allNewFixInsertions.size()+" new updates.");
|
||||
for (StorePositionUpdateStrategy fixInsertion : allNewFixInsertions) {
|
||||
if (isEndMarker(fixInsertion)) {
|
||||
logger.info("Stopping "+MarkPassingCalculator.this+"'s listener for race "+raceName);
|
||||
logger.fine("Stopping "+MarkPassingCalculator.this+"'s listener for race "+raceName);
|
||||
finished = true;
|
||||
break;
|
||||
} else {
|
||||
@@ -321,7 +321,7 @@ public class MarkPassingCalculator {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
logger.info("MarkPassingCalculator Listen thread terminating for race "+raceName);
|
||||
logger.fine("MarkPassingCalculator Listen thread terminating for race "+raceName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
package com.sap.sailing.domain.tracking;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -37,7 +35,7 @@ public interface RaceTrackingConnectivityParametersHandler {
|
||||
* produced {@code map} by passing it to this service's {@link #mapFrom(RaceTrackingConnectivityParameters)}
|
||||
* method.
|
||||
*/
|
||||
RaceTrackingConnectivityParameters mapTo(Map<String, Object> map) throws MalformedURLException, URISyntaxException;
|
||||
RaceTrackingConnectivityParameters mapTo(Map<String, Object> map) throws Exception;
|
||||
|
||||
/**
|
||||
* @return a map that contains the {@link TypeBasedServiceFinder#TYPE} identifier as taken from
|
||||
|
||||
+2
-4
@@ -3,9 +3,7 @@ package com.sap.sailing.mongodb.test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashSet;
|
||||
@@ -29,11 +27,11 @@ public class TracTracConnectivityParamsLoadAndStoreTest extends AbstractConnecti
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoreAndLoadSimpleTracTracParams() throws MalformedURLException, URISyntaxException {
|
||||
public void testStoreAndLoadSimpleTracTracParams() throws Exception {
|
||||
// set up
|
||||
final boolean trackWind = true;
|
||||
final boolean correctWindDirectionByMagneticDeclination = true;
|
||||
final URL paramURL = new URL("http://tractrac.com/some/url");
|
||||
final URL paramURL = new URL("http://event.tractrac.com/events/event_20160604_JuniorenSe/clientparams.php?event=event_20160604_JuniorenSe&race=4b9f0190-0b0d-0134-5b24-60a44ce903c3");
|
||||
final URI storedURI = new URI("live://tractrac.com/storedURI");
|
||||
final URI courseDesignUpdateURI = new URI("https://skitrac.dk/reverse/update");
|
||||
final TimePoint startOfTracking = MillisecondsTimePoint.now();
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_20"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/sapjvm_8"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console -clean"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y -ea -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dfile.encoding=cp1252 -Dexpedition.udp.port=2010 -Xmx6000m -XX:+UseG1GC -Djetty.home=${project_loc:com.sap.sailing.server}/../target/configuration/jetty -Djava.util.logging.config.file=${project_loc:com.sap.sailing.server}/../target/configuration/logging_debug.properties -Dkiwo.results=${project_loc:com.sap.sailing.kiworesultimport.test}/resources -Dpersistentcompetitors.clear=false -XX:+UseMembar"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y -ea -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dfile.encoding=cp1252 -Dexpedition.udp.port=2010 -Xmx6000m -XX:+UseG1GC -Djetty.home=${project_loc:com.sap.sailing.server}/../target/configuration/jetty -Djava.util.logging.config.file=${project_loc:com.sap.sailing.server}/../target/configuration/logging_debug.properties -Dkiwo.results=${project_loc:com.sap.sailing.kiworesultimport.test}/resources -Dpersistentcompetitors.clear=false -XX:+UseMembar -Drestore.tracked.races=true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<booleanAttribute key="show_selected_only" value="false"/>
|
||||
|
||||
+1
-1
@@ -1432,7 +1432,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
}
|
||||
LockUtil.lockForWrite(raceTrackersByRegattaLock);
|
||||
try {
|
||||
raceTrackersByID.put(trackerID, tracker);
|
||||
raceTrackersByID.put(tracker.getID(), tracker);
|
||||
Set<RaceTracker> trackers = raceTrackersByRegatta.get(tracker.getRegatta());
|
||||
if (trackers == null) {
|
||||
trackers = Collections.newSetFromMap(new ConcurrentHashMap<RaceTracker, Boolean>());
|
||||
|
||||
@@ -27,8 +27,13 @@ public abstract class HasTracingGetImpl<V> implements HasTracingGet<V> {
|
||||
try {
|
||||
return future.get(MILLIS_AFTER_WHICH_TO_TRACE_NON_RETURNING_GET, TimeUnit.MILLISECONDS);
|
||||
} catch (TimeoutException e) {
|
||||
logger.log(Level.INFO, ""+Thread.currentThread()+": Timeout waiting for future task "+future+
|
||||
" (retrying); "+ getAdditionalTraceInfo(), e);
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE, ""+Thread.currentThread()+": Timeout waiting for future task "+future+
|
||||
" (retrying); "+ getAdditionalTraceInfo(), e);
|
||||
} else {
|
||||
logger.info(""+Thread.currentThread()+": Timeout waiting for future task "+future+
|
||||
" (retrying); "+ getAdditionalTraceInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user