StartFrom() public method

public StartFrom ( CheckpointTag checkpointTag, int checkpointEventNumber ) : void
checkpointTag CheckpointTag
checkpointEventNumber int
return void
Beispiel #1
0
        public void Handle(CoreProjectionProcessingMessage.CheckpointLoaded message)
        {
            EnsureState(State.LoadStateRequested);
            try {
                var checkpointTag = message.CheckpointTag;
                var phase = checkpointTag == null ? 0 : checkpointTag.Phase;
                var projectionProcessingPhase = _projectionProcessingPhases[phase];
                if (checkpointTag == null)
                    checkpointTag = projectionProcessingPhase.MakeZeroCheckpointTag();
                checkpointTag = projectionProcessingPhase.AdjustTag(checkpointTag);
                //TODO: initialize projection state here (test it)
                //TODO: write test to ensure projection state is correctly loaded from a checkpoint and posted back when enough empty records processed
                //TODO: handle errors
                _coreProjectionCheckpointWriter.StartFrom(checkpointTag, message.CheckpointEventNumber);

                PartitionState rootPartitionState = null;
                if (_requiresRootPartition) {
                    rootPartitionState = PartitionState.Deserialize(message.CheckpointData, checkpointTag);
                    _partitionStateCache.CacheAndLockPartitionState("", rootPartitionState, null);
                }

                BeginPhase(projectionProcessingPhase, checkpointTag, rootPartitionState);
                GoToState(State.StateLoaded);
                if (_startOnLoad) {
                    if (_slaveProjections != null)
                        _projectionProcessingPhase.AssignSlaves(_slaveProjections);
                    _projectionProcessingPhase.Subscribe(checkpointTag, fromCheckpoint: true);
                } else
                    GoToState(State.Stopped);
            } catch (Exception ex) {
                SetFaulted(ex);
            }
        }