mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 09:26:44 +00:00
fixed locking in Mongo tests; made SwissTiming StoreAndForward robust against concurrent database drops
This commit is contained in:
+1
-1
@@ -265,7 +265,7 @@ public class StoreAndForward implements Runnable {
|
||||
while (!stopped && messageAndOptionalSequenceNumber != null) {
|
||||
logger.fine("Received message: "+messageAndOptionalSequenceNumber.getA());
|
||||
DBObject newCountRecord = lastMessageCountCollection.findAndModify(emptyQuery, incrementLastMessageCountQuery);
|
||||
lastMessageCount = (Long) newCountRecord.get(FieldNames.LAST_MESSAGE_COUNT.name());
|
||||
lastMessageCount = (Long) ((newCountRecord == null) ? 0 : newCountRecord.get(FieldNames.LAST_MESSAGE_COUNT.name()));
|
||||
SailMasterMessage message = swissTimingFactory.createMessage(messageAndOptionalSequenceNumber.getA(), lastMessageCount);
|
||||
swissTimingAdapterPersistence.storeSailMasterMessage(message);
|
||||
synchronized (this) {
|
||||
|
||||
+10
-5
@@ -105,11 +105,16 @@ public class TestStoringAndRetrievingWindTracksTest extends AbstractTracTracLive
|
||||
WindTrack result = new DomainObjectFactoryImpl(secondDatabase).loadWindTrack(domainEvent, race, windSource, /* millisecondsOverWhichToAverage */
|
||||
30000);
|
||||
double myBearingDeg = 123.4;
|
||||
for (Wind wind : result.getRawFixes()) {
|
||||
assertEquals(pos, wind.getPosition());
|
||||
assertEquals(10., wind.getKnots(), 0.000000000001);
|
||||
assertEquals(myBearingDeg, wind.getBearing().getDegrees(), 0.000000001);
|
||||
myBearingDeg += 1.1;
|
||||
result.lockForRead();
|
||||
try {
|
||||
for (Wind wind : result.getRawFixes()) {
|
||||
assertEquals(pos, wind.getPosition());
|
||||
assertEquals(10., wind.getKnots(), 0.000000000001);
|
||||
assertEquals(myBearingDeg, wind.getBearing().getDegrees(), 0.000000001);
|
||||
myBearingDeg += 1.1;
|
||||
}
|
||||
} finally {
|
||||
result.unlockAfterRead();
|
||||
}
|
||||
assertTrue("Expected myBeaaringDeg to be >= 139.999999999 but was "+myBearingDeg, myBearingDeg >= 139.999999999);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user