public virtual void Initialize() { if (Interlocked.Increment(ref _initialized) > 1) { return; } Logger.Debug(Messages.InitializingStorage); TryMongo(() => { PersistedCommits.EnsureIndex(IndexKeys.Ascending("Dispatched").Ascending(MongoFields.CommitStamp), IndexOptions.SetName("Dispatched_Index").SetUnique(false)); PersistedCommits.EnsureIndex(IndexKeys.Ascending("_id.BucketId", "_id.StreamId", "Events.StreamRevision"), IndexOptions.SetName("GetFrom_Index").SetUnique(true)); PersistedCommits.EnsureIndex(IndexKeys.Ascending(MongoFields.CommitStamp), IndexOptions.SetName("CommitStamp_Index").SetUnique(false)); PersistedStreamHeads.EnsureIndex(IndexKeys.Ascending("Unsnapshotted"), IndexOptions.SetName("Unsnapshotted_Index").SetUnique(false)); IMongoQuery query = Query.EQ("_id", MongoFields.CheckpointNumber); IMongoUpdate update = Update.Replace(new BsonDocument { { "_id", "CheckpointNumber" }, { "seq", 0 } }); Counters.Update(query, update, UpdateFlags.Upsert, WriteConcern.Acknowledged); }); }
public virtual void Initialize() { if (Interlocked.Increment(ref _initialized) > 1) { return; } Logger.Debug(Messages.InitializingStorage); TryMongo(() => { PersistedCommits.EnsureIndex(IndexKeys.Ascending("Dispatched").Ascending(MongoFields.CommitStamp), IndexOptions.SetName("Dispatched_Index").SetUnique(false)); PersistedCommits.EnsureIndex(IndexKeys.Ascending("_id.BucketId", "_id.StreamId", "Events.StreamRevision"), IndexOptions.SetName("GetFrom_Index").SetUnique(true)); PersistedCommits.EnsureIndex(IndexKeys.Ascending(MongoFields.CommitStamp), IndexOptions.SetName("CommitStamp_Index").SetUnique(false)); PersistedStreamHeads.EnsureIndex(IndexKeys.Ascending("Unsnapshotted"), IndexOptions.SetName("Unsnapshotted_Index").SetUnique(false)); }); }