mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-24 13:03:55 +00:00
Added data import lock
This commit is contained in:
1 parent
3b7733a701
commit
d81a894cce
2 files changed
+20
No files matched your search
@@ -14,6 +14,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import com.sap.sailing.domain.base.CourseArea;
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
@@ -484,4 +485,10 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
DomainObjectFactory getDomainObjectFactory();
|
||||
|
||||
WindStore getWindStore();
|
||||
|
||||
/**
|
||||
* This lock exists to allow only one master data import at a time to avoid situation where multiple Imports
|
||||
* override each other in unpredictable fashion
|
||||
*/
|
||||
ReentrantLock getDataImportLock();
|
||||
}
|
||||
+13
@@ -24,6 +24,7 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -242,6 +243,12 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
|
||||
|
||||
private final WindStore windStore;
|
||||
|
||||
/**
|
||||
* Allow only one master data import at a time to avoid situation where multiple Imports override each other in
|
||||
* unpredictable fashion
|
||||
*/
|
||||
private final ReentrantLock dataImportLock;
|
||||
|
||||
/**
|
||||
* If this service runs in the context of an OSGi environment, the activator should {@link #setBundleContext set the bundle context} on this
|
||||
* object so that service lookups become possible.
|
||||
@@ -313,6 +320,7 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
|
||||
this.mediaDB = mediaDb;
|
||||
this.competitorStore = competitorStore;
|
||||
this.windStore = windStore;
|
||||
this.dataImportLock = new ReentrantLock(true);
|
||||
|
||||
regattasByName = new ConcurrentHashMap<String, Regatta>();
|
||||
eventsById = new ConcurrentHashMap<Serializable, Event>();
|
||||
@@ -2196,4 +2204,9 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReentrantLock getDataImportLock() {
|
||||
return dataImportLock;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user