Beispiel #1
0
        void ConfigureProjections()
        {
            _checkpointTracker.SetUp(_allProjections, 1);
            var lastCommit = GetLastCommitId();

            foreach (var slot in _projectionsBySlot)
            {
                var maxCheckpointDispatchedInSlot = slot.Value
                                                    .Select(projection =>
                {
                    var checkpoint     = _checkpointTracker.GetCheckpoint(projection);
                    var longCheckpoint = LongCheckpoint.Parse(checkpoint);
                    return(longCheckpoint.LongValue);
                })
                                                    .Max();

                foreach (var projection in slot.Value)
                {
                    //Rebuild the slot only if it has at least one dispatched commit
                    if (_checkpointTracker.NeedsRebuild(projection) && maxCheckpointDispatchedInSlot >= 0)
                    {
                        //be sure that projection in rebuild has the same Last dispatched commit fo the entire slot
                        _checkpointTracker.SetCheckpoint(projection.GetCommonName(), maxCheckpointDispatchedInSlot.ToString());
                        projection.Drop();
                        projection.StartRebuild(_rebuildContext);
                        _checkpointTracker.RebuildStarted(projection, lastCommit);
                    }

                    projection.SetUp();
                }
            }
        }
        void ConfigureProjections()
        {
            _checkpointTracker.SetUp(_allProjections, 1);
            var lastCommit = GetLastCommitId();

            foreach (var slot in _projectionsBySlot)
            {
                var maxCheckpointDispatchedInSlot = slot.Value
                                                    .Select(projection =>
                {
                    var checkpoint     = _checkpointTracker.GetCheckpoint(projection);
                    var longCheckpoint = LongCheckpoint.Parse(checkpoint);
                    return(longCheckpoint.LongValue);
                })
                                                    .Max();

                foreach (var projection in slot.Value)
                {
                    if (_checkpointTracker.NeedsRebuild(projection))
                    {
                        //Check if this slot has ever dispatched at least one commit
                        if (maxCheckpointDispatchedInSlot > 0)
                        {
                            _checkpointTracker.SetCheckpoint(projection.GetCommonName(),
                                                             maxCheckpointDispatchedInSlot.ToString());
                            projection.Drop();
                            projection.StartRebuild(_rebuildContext);
                            _checkpointTracker.RebuildStarted(projection, lastCommit);
                        }
                        else
                        {
                            //this is a new slot, all the projection should execute
                            //as if they are not in rebuild, because they are new
                            //so we need to immediately stop rebuilding.
                            projection.StopRebuild();
                        }
                    }

                    projection.SetUp();
                }
            }
            var errors = _checkpointTracker.GetCheckpointErrors();

            if (errors.Any())
            {
                StringBuilder fullError = new StringBuilder();
                foreach (var error in errors)
                {
                    Logger.ErrorFormat("CheckpointError: {0}", error);
                    fullError.AppendLine(error);
                }
                throw new Exception(String.Format("Found {0} errors in checkpoint status: {1}", errors.Count, fullError.ToString()));
            }
        }
Beispiel #3
0
        void ConfigureProjections()
        {
            _checkpointTracker.SetUp(_allProjections, 1, false);
            var lastCommit = GetLastCommitId();

            foreach (var slot in _projectionsBySlot)
            {
                var maxCheckpointDispatchedInSlot = slot.Value
                                                    .Select(projection =>
                {
                    var checkpoint     = _checkpointTracker.GetCheckpoint(projection);
                    var longCheckpoint = checkpoint;
                    return(longCheckpoint);
                })
                                                    .Max();

                foreach (var projection in slot.Value)
                {
                    //Check if this slot has ever dispatched at least one commit
                    if (maxCheckpointDispatchedInSlot > 0)
                    {
                        _checkpointTracker.SetCheckpoint(projection.GetCommonName(),
                                                         maxCheckpointDispatchedInSlot);
                        projection.Drop();
                        projection.StartRebuild(_rebuildContext);
                        _checkpointTracker.RebuildStarted(projection, lastCommit);
                    }
                    else
                    {
                        //this is a new slot, all the projection should execute
                        //as if they are not in rebuild, because they are new
                        //so we need to immediately stop rebuilding.
                        projection.StopRebuild();
                    }
                    projection.SetUp();
                }
            }
            //Standard projection engine now executes check for GetCheckpointErrors but
            //it is not useful here, because we are in rebuild, so every error will be fixed.
        }