Beispiel #1
0
        void Add(IProjection projection, Int64 defaultValue)
        {
            var id = projection.GetCommonName();
            var projectionSignature = projection.GetSignature();
            var projectionSlotName  = projection.GetSlotName();

            var checkPoint = _checkpoints.FindOneById(id) ??
                             new Checkpoint(id, defaultValue, projectionSignature);

            //Check if some projection is changed and rebuild is not active
            if (
                checkPoint.Signature != projectionSignature &&
                !RebuildSettings.ShouldRebuild)
            {
                _checkpointErrors.Add(String.Format("Projection {0} [slot {1}] has signature {2} but checkpoint on database has signature {3}.\n REBUILD NEEDED",
                                                    id, projectionSlotName, projectionSignature, checkPoint.Signature));
            }
            else
            {
                checkPoint.Signature = projectionSignature;
            }
            checkPoint.Slot   = projectionSlotName;
            checkPoint.Active = true;
            _checkpoints.Save(checkPoint, checkPoint.Id);
            _checkpointTracker[id] = checkPoint.Value;
            _projectionToSlot[id]  = checkPoint.Slot;
        }
        public void event_is_dispatched()
        {
            CreateAggregate();

            ConcurrentCheckpointTracker thisTracker = new ConcurrentCheckpointTracker(_db);

            thisTracker.SetUp(new[] { _projection1, _projection3 }, 1, false);
            thisTracker.UpdateSlotAndSetCheckpoint(_projection1.GetSlotName(), new[] { _projection1.GetCommonName() }, 1);
            thisTracker.UpdateSlotAndSetCheckpoint(_projection3.GetSlotName(), new[] { _projection3.GetCommonName() }, 1);

            var status = sut.Rebuild();

            WaitForFinish(status);
            Assert.That(_writer1.All.Count(), Is.EqualTo(1));
            Assert.That(_writer3.All.Count(), Is.EqualTo(1));
        }
        void Add(IProjection projection, string defaultValue)
        {
            var id         = projection.GetCommonName();
            var checkPoint = _checkpoints.FindOneById(id) ?? new Checkpoint(id, defaultValue);

            checkPoint.Signature = projection.GetSignature();
            checkPoint.Slot      = projection.GetSlotName();
            checkPoint.Active    = true;
            _checkpoints.Save(checkPoint);
            _checkpointTracker[id] = checkPoint.Value;
            _projectionToSlot[id]  = checkPoint.Slot;
        }
        public void dispatch_only_until_maximum_checkpoint_already_dispatched()
        {
            CreateAggregate(1);
            CreateAggregate(2);
            CreateAggregate(3);

            //prepare the tracker
            ConcurrentCheckpointTracker thisTracker = new ConcurrentCheckpointTracker(_db);

            thisTracker.SetUp(new[] { _projection }, 1, false);
            thisTracker.UpdateSlotAndSetCheckpoint(_projection.GetSlotName(), new[] { _projection.GetCommonName() }, 2); //Set the projection as dispatched

            var status = sut.Rebuild();

            WaitForFinish(status);
            Assert.That(_writer.All.Count(), Is.EqualTo(2));
        }
        public void event_is_dispatched()
        {
            CreateAggregate();

            ConcurrentCheckpointTracker thisTracker = new ConcurrentCheckpointTracker(_db);

            thisTracker.SetUp(new[] { _projection1, _projection3 }, 1, false);
            thisTracker.UpdateSlotAndSetCheckpoint(_projection1.GetSlotName(), new[] { _projection1.GetCommonName() }, 1);
            thisTracker.UpdateSlotAndSetCheckpoint(_projection3.GetSlotName(), new[] { _projection3.GetCommonName() }, 1);

            var status = sut.Rebuild();

            WaitForFinish(status);
            var coll      = _db.GetCollection <BsonDocument>("Sample");
            var allRecord = coll.FindAll().ToList();

            Assert.That(allRecord, Has.Count.EqualTo(1));
        }