mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
Merge branch 'master' into bug2918
This commit is contained in:
commit
2e4f2dbae4
9 files changed
+234
-103
No files matched your search
+7
-4
@@ -590,14 +590,17 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
DeviceConfiguration getDeviceConfigurationByName(String deviceConfigurationName);
|
||||
|
||||
/**
|
||||
* Adds a device configuration.
|
||||
* @param matcher defining for which the configuration applies.
|
||||
* @param configuration of the device.
|
||||
* Adds a device configuration. The effect is replicated.
|
||||
*
|
||||
* @param matcher
|
||||
* defining for which the configuration applies.
|
||||
* @param configuration
|
||||
* of the device.
|
||||
*/
|
||||
void createOrUpdateDeviceConfiguration(DeviceConfiguration configuration);
|
||||
|
||||
/**
|
||||
* Removes a configuration by its ID.
|
||||
* Removes a configuration by its ID. The effect is replicated.
|
||||
*/
|
||||
void removeDeviceConfiguration(UUID id);
|
||||
|
||||
|
||||
+85
-61
@@ -112,6 +112,26 @@ public class ImportMasterDataOperation extends
|
||||
this.connectivityParametersToRestore = masterData.getConnectivityParametersToRestore();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Operations of this type are expected to be explicitly sent out <em>before</em> the operation is applied locally on
|
||||
* the master server. This is important because otherwise tracking-related operations may be sent out before the
|
||||
* structures for regattas, events, etc. have been replicated. This also holds for the "reverse" replication direction
|
||||
* from a replica to a master. See also bug5574.
|
||||
*/
|
||||
@Override
|
||||
public boolean isRequiresExplicitTransitiveReplication() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
// TODO Implement ImportMasterDataOperation.clone(...)
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MasterDataImportObjectCreationCountImpl internalApplyTo(RacingEventService toState) throws Exception {
|
||||
final DataImportLockWithProgress dataImportLock = toState.getDataImportLock();
|
||||
@@ -154,7 +174,6 @@ public class ImportMasterDataOperation extends
|
||||
if (masterData.getDeviceConfigurations() != null) {
|
||||
importDeviceConfigurations(toState);
|
||||
}
|
||||
|
||||
Collection<MediaTrack> allMediaTracksToImport = masterData.getFilteredMediaTracks();
|
||||
for (MediaTrack trackToImport : allMediaTracksToImport) {
|
||||
ensureOwnership(trackToImport.getIdentifier(), securityService);
|
||||
@@ -175,23 +194,25 @@ public class ImportMasterDataOperation extends
|
||||
}
|
||||
|
||||
private void importDeviceConfigurations(RacingEventService toState) {
|
||||
Iterable<DeviceConfiguration> newConfigs = masterData.getDeviceConfigurations();
|
||||
for (DeviceConfiguration config : newConfigs) {
|
||||
if (toState.getDeviceConfigurationById(config.getId()) != null) {
|
||||
if (override) {
|
||||
logger.info(String.format(
|
||||
"Device configuration [%s] with name \"%s\" already exists. Overwrite because override flag is set.",
|
||||
config.getId(), config.getName()));
|
||||
toState.removeDeviceConfiguration(config.getId());
|
||||
toState.createOrUpdateDeviceConfiguration(config);
|
||||
// FIXME ownership here!
|
||||
if (toState.getMasterDescriptor() == null) { // don't do this on a replica's RacingEventService; device config removals/additions are replicated by RacingEventService
|
||||
Iterable<DeviceConfiguration> newConfigs = masterData.getDeviceConfigurations();
|
||||
for (DeviceConfiguration config : newConfigs) {
|
||||
if (toState.getDeviceConfigurationById(config.getId()) != null) {
|
||||
if (override) {
|
||||
logger.info(String.format(
|
||||
"Device configuration [%s] with name \"%s\" already exists. Overwrite because override flag is set.",
|
||||
config.getId(), config.getName()));
|
||||
toState.removeDeviceConfiguration(config.getId());
|
||||
toState.createOrUpdateDeviceConfiguration(config);
|
||||
// FIXME ownership here!
|
||||
} else {
|
||||
logger.info(String
|
||||
.format("Device configuration [%s] with name \"%s\" already exists. Not overwriting because override flag is not set.",
|
||||
config.getId(), config.getName()));
|
||||
}
|
||||
} else {
|
||||
logger.info(String
|
||||
.format("Device configuration [%s] with name \"%s\" already exists. Not overwriting because override flag is not set.",
|
||||
config.getId(), config.getName()));
|
||||
toState.createOrUpdateDeviceConfiguration(config);
|
||||
}
|
||||
} else {
|
||||
toState.createOrUpdateDeviceConfiguration(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -407,62 +428,66 @@ public class ImportMasterDataOperation extends
|
||||
}
|
||||
|
||||
private void createWindTracks(RacingEventService toState) {
|
||||
int numOfWindTracks = masterData.getWindTrackMasterData().size();
|
||||
int i = 0;
|
||||
for (WindTrackMasterData windMasterData : masterData.getWindTrackMasterData()) {
|
||||
DummyTrackedRace trackedRaceWithNameAndId = new DummyTrackedRace(windMasterData.getRaceName(), windMasterData.getRaceId());
|
||||
WindTrack windTrackToWriteTo = toState.getWindStore().getWindTrack(windMasterData.getRegattaName(), trackedRaceWithNameAndId, windMasterData.getWindSource(), 0, -1);
|
||||
final WindTrack windTrackToReadFrom = windMasterData.getWindTrack();
|
||||
windTrackToReadFrom.lockForRead();
|
||||
try {
|
||||
for (Wind fix : windTrackToReadFrom.getRawFixes()) {
|
||||
Wind existingFix = windTrackToWriteTo.getFirstRawFixAtOrAfter(fix.getTimePoint());
|
||||
if (existingFix == null || !(existingFix.equals(fix) && fix.getTimePoint().equals(existingFix.getTimePoint())
|
||||
&& Util.equalsWithNull(fix.getPosition(), existingFix.getPosition()))) {
|
||||
windTrackToWriteTo.add(fix);
|
||||
} else {
|
||||
logger.info("Didn't add wind fix in import, because equal fix was already there.");
|
||||
if (toState.getMasterDescriptor() == null) { // don't do this on a replica's RacingEventService; wind data will be received through the tracked race loading replication
|
||||
int numOfWindTracks = masterData.getWindTrackMasterData().size();
|
||||
int i = 0;
|
||||
for (WindTrackMasterData windMasterData : masterData.getWindTrackMasterData()) {
|
||||
DummyTrackedRace trackedRaceWithNameAndId = new DummyTrackedRace(windMasterData.getRaceName(), windMasterData.getRaceId());
|
||||
WindTrack windTrackToWriteTo = toState.getWindStore().getWindTrack(windMasterData.getRegattaName(), trackedRaceWithNameAndId, windMasterData.getWindSource(), 0, -1);
|
||||
final WindTrack windTrackToReadFrom = windMasterData.getWindTrack();
|
||||
windTrackToReadFrom.lockForRead();
|
||||
try {
|
||||
for (Wind fix : windTrackToReadFrom.getRawFixes()) {
|
||||
Wind existingFix = windTrackToWriteTo.getFirstRawFixAtOrAfter(fix.getTimePoint());
|
||||
if (existingFix == null || !(existingFix.equals(fix) && fix.getTimePoint().equals(existingFix.getTimePoint())
|
||||
&& Util.equalsWithNull(fix.getPosition(), existingFix.getPosition()))) {
|
||||
windTrackToWriteTo.add(fix);
|
||||
} else {
|
||||
logger.fine("Didn't add wind fix in import, because equal fix was already there.");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
windTrackToReadFrom.unlockAfterRead();
|
||||
}
|
||||
} finally {
|
||||
windTrackToReadFrom.unlockAfterRead();
|
||||
i++;
|
||||
progress.setCurrentSubProgressPct((double) i / numOfWindTracks);
|
||||
progress.setOverAllProgressPct(0.5 + (0.3) * ((double) i / numOfWindTracks));
|
||||
}
|
||||
i++;
|
||||
progress.setCurrentSubProgressPct((double) i / numOfWindTracks);
|
||||
progress.setOverAllProgressPct(0.5 + (0.3) * ((double) i / numOfWindTracks));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void importRaceLogTrackingGPSFixes(RacingEventService toState) {
|
||||
Map<DeviceIdentifier, Set<Timed>> raceLogTrackingFixes = masterData.getRaceLogTrackingFixes();
|
||||
if (raceLogTrackingFixes != null) {
|
||||
SensorFixStore store = toState.getSensorFixStore();
|
||||
int i = 0;
|
||||
final int numberOfDevices = raceLogTrackingFixes.size();
|
||||
for (Entry<DeviceIdentifier, Set<Timed>> entry : raceLogTrackingFixes.entrySet()) {
|
||||
DeviceIdentifier device = entry.getKey();
|
||||
final Collection<Timed> fixesToAddAsBatch = new ArrayList<>(BATCH_SIZE_FOR_IMPORTING_FIXES);
|
||||
for (Timed fixToAdd : entry.getValue()) {
|
||||
if (fixToAdd instanceof VeryCompactGPSFixMovingImpl) {
|
||||
VeryCompactGPSFixMovingImpl gpsFix = (VeryCompactGPSFixMovingImpl) fixToAdd;
|
||||
fixToAdd = new GPSFixMovingImpl(gpsFix.getPosition(), fixToAdd.getTimePoint(),
|
||||
((VeryCompactGPSFixMovingImpl) fixToAdd).getSpeed());
|
||||
} else if (fixToAdd instanceof VeryCompactGPSFixImpl) {
|
||||
VeryCompactGPSFixImpl gpsFix = (VeryCompactGPSFixImpl) fixToAdd;
|
||||
fixToAdd = new GPSFixImpl(gpsFix.getPosition(), fixToAdd.getTimePoint());
|
||||
}
|
||||
fixesToAddAsBatch.add(fixToAdd);
|
||||
if (fixesToAddAsBatch.size() == BATCH_SIZE_FOR_IMPORTING_FIXES) {
|
||||
if (toState.getMasterDescriptor() == null) { // don't do this on a replica's RacingEventService; tracking data will be received through the tracked race loading replication
|
||||
Map<DeviceIdentifier, Set<Timed>> raceLogTrackingFixes = masterData.getRaceLogTrackingFixes();
|
||||
if (raceLogTrackingFixes != null) {
|
||||
SensorFixStore store = toState.getSensorFixStore();
|
||||
int i = 0;
|
||||
final int numberOfDevices = raceLogTrackingFixes.size();
|
||||
for (Entry<DeviceIdentifier, Set<Timed>> entry : raceLogTrackingFixes.entrySet()) {
|
||||
DeviceIdentifier device = entry.getKey();
|
||||
final Collection<Timed> fixesToAddAsBatch = new ArrayList<>(BATCH_SIZE_FOR_IMPORTING_FIXES);
|
||||
for (Timed fixToAdd : entry.getValue()) {
|
||||
if (fixToAdd instanceof VeryCompactGPSFixMovingImpl) {
|
||||
VeryCompactGPSFixMovingImpl gpsFix = (VeryCompactGPSFixMovingImpl) fixToAdd;
|
||||
fixToAdd = new GPSFixMovingImpl(gpsFix.getPosition(), fixToAdd.getTimePoint(),
|
||||
((VeryCompactGPSFixMovingImpl) fixToAdd).getSpeed());
|
||||
} else if (fixToAdd instanceof VeryCompactGPSFixImpl) {
|
||||
VeryCompactGPSFixImpl gpsFix = (VeryCompactGPSFixImpl) fixToAdd;
|
||||
fixToAdd = new GPSFixImpl(gpsFix.getPosition(), fixToAdd.getTimePoint());
|
||||
}
|
||||
fixesToAddAsBatch.add(fixToAdd);
|
||||
if (fixesToAddAsBatch.size() == BATCH_SIZE_FOR_IMPORTING_FIXES) {
|
||||
storeFixes(store, device, fixesToAddAsBatch);
|
||||
}
|
||||
}
|
||||
if (!fixesToAddAsBatch.isEmpty()) {
|
||||
storeFixes(store, device, fixesToAddAsBatch);
|
||||
}
|
||||
i++;
|
||||
progress.setCurrentSubProgressPct((double) i / numberOfDevices);
|
||||
}
|
||||
if (!fixesToAddAsBatch.isEmpty()) {
|
||||
storeFixes(store, device, fixesToAddAsBatch);
|
||||
}
|
||||
i++;
|
||||
progress.setCurrentSubProgressPct((double) i / numberOfDevices);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -484,7 +509,6 @@ public class ImportMasterDataOperation extends
|
||||
if (leaderboard instanceof RegattaLeaderboard) {
|
||||
RegattaLeaderboard regattaLeaderboard = (RegattaLeaderboard) leaderboard;
|
||||
Regatta regatta = regattaLeaderboard.getRegatta();
|
||||
|
||||
Regatta existingRegatta = toState.getRegatta(regatta.getRegattaIdentifier());
|
||||
if (existingRegatta != null) {
|
||||
if (creationCount.alreadyAddedRegattaWithId(existingRegatta.getId().toString())) {
|
||||
|
||||
Reference in new issue
Block a user