private static void ConfigureRebuild(DocumentStoreConfiguration config)
        {
            if (!Environment.UserInteractive)
            {
                return;
            }

            if (!_documentStoreConfiguration.IsReadmodelBuilder)
            {
                return;
            }

            Banner();

            RebuildSettings.Init(config.Rebuild, config.NitroMode);

            if (RebuildSettings.ShouldRebuild)
            {
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("---> Rebuild the readmodel (y/N)?");

                var res = Console.ReadLine().Trim().ToLowerInvariant();
                if (res != "y")
                {
                    RebuildSettings.DisableRebuild();
                }
            }
        }
        public void Verify_check_of_new_projection_ok_when_rebuild()
        {
            SetupOneProjectionNew();
            RebuildSettings.Init(true, false);
            var errors = _sut.GetCheckpointErrors();

            Assert.That(errors, Has.Count.EqualTo(0));
        }
Beispiel #3
0
        public void Verify_check_of_signature_change_during_rebuild()
        {
            RebuildSettings.Init(true, true);
            SetupOneProjectionChangedSignature();
            var errors = _slotStatusCheckerSut.GetCheckpointErrors();

            Assert.That(errors, Has.Count.EqualTo(0));
        }
        public void Verify_check_of_generic_projection_checkpoint_error()
        {
            SetupTwoProjectionsError();
            RebuildSettings.Init(false, false);
            var errors = _sut.GetCheckpointErrors();

            Assert.That(errors, Has.Count.EqualTo(1));
            Assert.That(errors[0], Is.EqualTo("Error in slot default, not all projection at the same checkpoint value. Please check reamodel db!"));
        }
        public void Verify_check_of_new_projection()
        {
            SetupOneProjectionNew();
            RebuildSettings.Init(false, false);
            var errors = _sut.GetCheckpointErrors();

            Assert.That(errors, Has.Count.EqualTo(1));
            Assert.That(errors[0], Is.EqualTo("Error in slot default: we have new projections at checkpoint 0, rebuild needed!"));
        }
Beispiel #6
0
        public void Verify_check_of_signature_change()
        {
            RebuildSettings.Init(false, false);
            SetupOneProjectionChangedSignature();
            var errors = _slotStatusCheckerSut.GetCheckpointErrors();

            Assert.That(errors, Has.Count.EqualTo(1));
            Assert.That(errors.ElementAt(0), Is.EqualTo("Projection Projection2 [slot default] has signature V2 but checkpoint on database has signature oldSignature.\n REBUILD NEEDED"));
        }
Beispiel #7
0
        public void Verify_check_of_new_projection()
        {
            SetupOneProjectionNew();
            RebuildSettings.Init(false, false);
            var errors = _slotStatusCheckerSut.GetCheckpointErrors();

            Assert.That(errors, Has.Count.EqualTo(1));
            Assert.That(errors.ElementAt(0), Is.EqualTo("Error in slot default: we have new projections at checkpoint 0.\n REBUILD NEEDED!"));
        }
Beispiel #8
0
        public void Verify_current_null_should_be_rebuilded()
        {
            RebuildSettings.Init(false, false);
            SetupOneProjectionWithCurrentNull();
            var errors = _slotStatusCheckerSut.GetCheckpointErrors();

            Assert.That(errors, Has.Count.EqualTo(1));
            Assert.That(errors.ElementAt(0), Is.EqualTo("Projection Projection [slot default] had an interrupted rebuild because current is 0 and value is 42 \n REBUILD NEEDED"));
        }
Beispiel #9
0
        protected void ConfigureProjectionEngine(Boolean dropCheckpoints = true)
        {
            if (Engine != null)
            {
                Engine.Stop();
            }
            if (dropCheckpoints)
            {
                _checkpoints.Drop();
            }
            _tracker       = new ConcurrentCheckpointTracker(Database);
            _statusChecker = new ConcurrentCheckpointStatusChecker(Database);

            var tenantId = new TenantId("engine");

            var config = new ProjectionEngineConfig()
            {
                Slots = new[] { "*" },
                EventStoreConnectionString = _eventStoreConnectionString,
                TenantId   = tenantId,
                BucketInfo = new List <BucketInfo>()
                {
                    new BucketInfo()
                    {
                        Slots = new[] { "*" }, BufferSize = 10
                    }
                },
                DelayedStartInMilliseconds = 1000,
                ForcedGcSecondsInterval    = 0,
                EngineVersion = "v2",
            };

            RebuildSettings.Init(OnShouldRebuild(), OnShouldUseNitro());

            _rebuildContext = new RebuildContext(RebuildSettings.NitroMode);
            StorageFactory  = new MongoStorageFactory(Database, _rebuildContext);
            Func <IPersistStreams, CommitPollingClient> pollingClientFactory =
                ps => new CommitPollingClient(
                    ps,
                    new CommitEnhancer(_identityConverter),
                    OnGetPollingClientId(),
                    NullLogger.Instance);

            Engine = new ProjectionEngine(
                pollingClientFactory,
                _tracker,
                BuildProjections().ToArray(),
                new NullHouseKeeper(),
                _rebuildContext,
                new NullNotifyCommitHandled(),
                config
                );
            Engine.LoggerFactory = Substitute.For <ILoggerFactory>();
            Engine.LoggerFactory.Create(Arg.Any <Type>()).Returns(NullLogger.Instance);
            OnStartPolling();
        }
        protected async Task ConfigureProjectionEngineAsync(Boolean dropCheckpoints = true)
        {
            Engine?.Stop();
            if (dropCheckpoints)
            {
                _checkpoints.Drop();
            }
            _tracker       = new ConcurrentCheckpointTracker(Database);
            _statusChecker = new MongoDirectConcurrentCheckpointStatusChecker(Database);

            var tenantId = new TenantId("engine");

            var config = new ProjectionEngineConfig()
            {
                Slots = new[] { "*" },
                EventStoreConnectionString = _eventStoreConnectionString,
                TenantId   = tenantId,
                BucketInfo = new List <BucketInfo>()
                {
                    new BucketInfo()
                    {
                        Slots = new[] { "*" }, BufferSize = 10
                    }
                },
                DelayedStartInMilliseconds = 0,
                ForcedGcSecondsInterval    = 0,
                EngineVersion = "v2",
            };

            RebuildSettings.Init(OnShouldRebuild(), OnShouldUseNitro());

            var rebuildContext = new RebuildContext(RebuildSettings.NitroMode);

            StorageFactory = new MongoStorageFactory(Database, rebuildContext);

            Engine = new ProjectionEngine(
                _pollingClientFactory,
                Persistence,
                _tracker,
                BuildProjections().ToArray(),
                new NullHouseKeeper(),
                new NullNotifyCommitHandled(),
                config,
                NullLogger.Instance,
                NullLoggerThreadContextManager.Instance);
            Engine.LoggerFactory = Substitute.For <ILoggerFactory>();
            Engine.LoggerFactory.Create(Arg.Any <Type>()).Returns(NullLogger.Instance);
            await OnStartPolling().ConfigureAwait(false);
        }