Merge branch 'master' into bug5197

This commit is contained in:
Axel Uhl
2020-03-24 09:52:55 +01:00
6 changed files with 15 additions and 15 deletions
@@ -383,18 +383,18 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
}
static void ensureIndicesOnWindTracks(MongoCollection<Document> windTracks) {
windTracks.createIndex(new Document(FieldNames.RACE_ID.name(), 1), new IndexOptions().name("windbyrace")); // for new programmatic access
windTracks.createIndex(new Document(FieldNames.REGATTA_NAME.name(), 1), new IndexOptions().name("windbyregatta")); // for export or human look-up
windTracks.createIndex(new Document(FieldNames.RACE_ID.name(), 1), new IndexOptions().name("windbyrace").background(false)); // for new programmatic access
windTracks.createIndex(new Document(FieldNames.REGATTA_NAME.name(), 1), new IndexOptions().name("windbyregatta").background(false)); // for export or human look-up
// for legacy access to not yet migrated fixes
windTracks.createIndex(new Document().append(FieldNames.EVENT_NAME.name(), 1)
.append(FieldNames.RACE_NAME.name(), 1), new IndexOptions().name("windbyeventandrace"));
.append(FieldNames.RACE_NAME.name(), 1), new IndexOptions().name("windbyeventandrace").background(false));
// Unique index
try {
windTracks.createIndex(
new Document().append(FieldNames.RACE_ID.name(), 1)
.append(FieldNames.WIND_SOURCE_NAME.name(), 1).append(FieldNames.WIND_SOURCE_ID.name(), 1)
.append(FieldNames.WIND.name() + "." + FieldNames.TIME_AS_MILLIS.name(), 1),
new IndexOptions().name("windByRaceSourceAndTime").unique(true));
new IndexOptions().name("windByRaceSourceAndTime").unique(true).background(false));
} catch (MongoException exception) {
if (exception.getCode() == 10092) {
logger.warning(String.format(
@@ -263,7 +263,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
index.put(FieldNames.DEVICE_ID.name()+"."+com.sap.sailing.shared.persistence.impl.FieldNames.DEVICE_TYPE.name(), 1);
index.put(FieldNames.DEVICE_ID.name()+"."+com.sap.sailing.shared.persistence.impl.FieldNames.DEVICE_TYPE_SPECIFIC_ID.name(), 1);
index.put(FieldNames.DEVICE_ID.name()+"."+com.sap.sailing.shared.persistence.impl.FieldNames.DEVICE_STRING_REPRESENTATION.name(), 1);
gpsFixCollection.createIndex(index, new IndexOptions().name("fixbytimeanddev"));
gpsFixCollection.createIndex(index, new IndexOptions().name("fixbytimeanddev").background(false));
return gpsFixCollection;
}
@@ -689,18 +689,18 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
MongoCollection<Document> regattasCollection = database.getCollection(CollectionNames.REGATTAS.name());
Document regattaByNameIndexKey = new Document(FieldNames.REGATTA_NAME.name(), 1);
try {
regattasCollection.createIndex(regattaByNameIndexKey, new IndexOptions().unique(true));
regattasCollection.createIndex(regattaByNameIndexKey, new IndexOptions().unique(true).background(false));
} catch (MongoCommandException e) {
// the index probably existed as non-unique; remove and create again
regattasCollection.dropIndex(regattaByNameIndexKey);
regattasCollection.createIndex(regattaByNameIndexKey, new IndexOptions().unique(true));
regattasCollection.createIndex(regattaByNameIndexKey, new IndexOptions().unique(true).background(false));
}
Document regattaByIdIndexKey = new Document(FieldNames.REGATTA_ID.name(), 1);
try {
regattasCollection.createIndex(regattaByIdIndexKey, new IndexOptions().unique(true));
regattasCollection.createIndex(regattaByIdIndexKey, new IndexOptions().unique(true).background(false));
} catch (MongoCommandException e) {
regattasCollection.dropIndex(regattaByIdIndexKey);
regattasCollection.createIndex(regattaByIdIndexKey, new IndexOptions().unique(true));
regattasCollection.createIndex(regattaByIdIndexKey, new IndexOptions().unique(true).background(false));
}
Document dbRegatta = new Document();
Document query = new Document(FieldNames.REGATTA_NAME.name(), regatta.getName());
@@ -1617,7 +1617,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
MongoCollection<Document> result = database.getCollection(CollectionNames.REGATTA_LOGS.name());
Document index = new Document(FieldNames.REGATTA_LOG_IDENTIFIER_TYPE.name(), 1);
index.put(FieldNames.REGATTA_LOG_IDENTIFIER_NAME.name(), 1);
result.createIndex(index, new IndexOptions().name("regattaLogById"));
result.createIndex(index, new IndexOptions().name("regattaLogById").background(false));
return result;
}
@@ -22,7 +22,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
this.expeditionDeviceConfigurationsCollection = db.getCollection(CollectionNames.EXPEDITION_DEVICE_CONFIGURATIONS.name());
BasicDBObject index = new BasicDBObject();
index.put(FieldNames.EXPEDITION_DEVICE_CONFIGURATION_UUID.name(), 1);
expeditionDeviceConfigurationsCollection.createIndex(index, new IndexOptions().name("uuidindex").unique(true));
expeditionDeviceConfigurationsCollection.createIndex(index, new IndexOptions().name("uuidindex").unique(true).background(false));
}
private Document getExpeditionDeviceConfigurationDBKey(ExpeditionDeviceConfiguration expeditionDeviceConfiguration) {
@@ -30,12 +30,12 @@ public class MongoFileStorageServicePropertyStoreImpl implements FileStorageServ
.append(FieldNames.PROPERTY_NAME.name(), 1);
try {
propertiesCollection.createIndex(index,
new IndexOptions().name("svcpropnameunique").unique(true));
new IndexOptions().name("svcpropnameunique").unique(true).background(false));
} catch (Exception e) {
logger.info("Problem creating index, probably due to index format change; dropping indexes and creating again...");
// could be that the index was created with different properties; need to remove and create again:
propertiesCollection.dropIndexes();
propertiesCollection.createIndex(index, new IndexOptions().name("svcpropnameunique").unique(true));
propertiesCollection.createIndex(index, new IndexOptions().name("svcpropnameunique").unique(true).background(false));
}
activeServiceCollection = dbService.getDB().getCollection(ACTIVE_SERVICE_COLLECTION_NAME);
}
@@ -23,7 +23,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
sessionCollection = mongoDatabase.getCollection(CollectionNames.SESSIONS.name());
sessionCollection.createIndex(new Document().
append(FieldNames.CACHE_NAME.name(), 1).
append(FieldNames.SESSION_ID.name(), 1), new IndexOptions().name("cachenameandsessionid"));
append(FieldNames.SESSION_ID.name(), 1), new IndexOptions().name("cachenameandsessionid").background(false));
}
private Document getKey(String cacheName, Session session) {
@@ -53,7 +53,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
}
}
try {
settingCollection.createIndex(new Document(FieldNames.Preferences.USERNAME.name(), 1), new IndexOptions().name("uniquebyusername").unique(true));
settingCollection.createIndex(new Document(FieldNames.Preferences.USERNAME.name(), 1), new IndexOptions().name("uniquebyusername").unique(true).background(false));
} catch (Exception e) {
logger.log(Level.SEVERE, "There are duplicate keys in the "+CollectionNames.PREFERENCES.name()+
" collection. Unique index cannot be created. Consider cleaning up.", e);