Esempio n. 1
0
 protected override IProjectionProcessingPhase CreateFirstProcessingPhase(
     IPublisher publisher,
     IPublisher inputQueue,
     Guid projectionCorrelationId,
     PartitionStateCache partitionStateCache,
     Action updateStatistics,
     CoreProjection coreProjection,
     ReaderSubscriptionDispatcher subscriptionDispatcher,
     CheckpointTag zeroCheckpointTag,
     ICoreProjectionCheckpointManager checkpointManager,
     IReaderStrategy readerStrategy,
     IResultWriter resultWriter,
     IEmittedStreamsTracker emittedStreamsTracker)
 {
     return(new ParallelQueryMasterProjectionProcessingPhase(
                coreProjection,
                projectionCorrelationId,
                publisher,
                inputQueue,
                _projectionConfig,
                updateStatistics,
                _stateHandler,
                partitionStateCache,
                _name,
                _logger,
                zeroCheckpointTag,
                checkpointManager,
                subscriptionDispatcher,
                readerStrategy,
                resultWriter,
                _projectionConfig.CheckpointsEnabled,
                this.GetStopOnEof(),
                _spoolProcessingResponseDispatcher,
                emittedStreamsTracker));
 }
        public WriteQueryResultProjectionProcessingPhaseBase(
            IPublisher publisher,
            int phase,
            string resultStream,
            ICoreProjectionForProcessingPhase coreProjection,
            PartitionStateCache stateCache,
            ICoreProjectionCheckpointManager checkpointManager,
            IEmittedEventWriter emittedEventWriter,
            IEmittedStreamsTracker emittedStreamsTracker)
        {
            if (resultStream == null) throw new ArgumentNullException("resultStream");
            if (coreProjection == null) throw new ArgumentNullException("coreProjection");
            if (stateCache == null) throw new ArgumentNullException("stateCache");
            if (checkpointManager == null) throw new ArgumentNullException("checkpointManager");
            if (emittedEventWriter == null) throw new ArgumentNullException("emittedEventWriter");
            if (emittedStreamsTracker == null) throw new ArgumentNullException("emittedStreamsTracker");
            if (string.IsNullOrEmpty(resultStream)) throw new ArgumentException("resultStream");

            _publisher = publisher;
            _phase = phase;
            _resultStream = resultStream;
            _coreProjection = coreProjection;
            _stateCache = stateCache;
            _checkpointManager = checkpointManager;
            _emittedEventWriter = emittedEventWriter;
            _emittedStreamsTracker = emittedStreamsTracker;
        }
Esempio n. 3
0
 public FakeProjectionProcessingPhase(int phase, specification_with_multi_phase_core_projection specification,
                                      ICoreProjectionCheckpointManager checkpointManager, IReaderStrategy readerStrategy, IEmittedStreamsTracker emittedStreamsTracker)
 {
     _phase                 = phase;
     _specification         = specification;
     _checkpointManager     = checkpointManager;
     _readerStrategy        = readerStrategy;
     _emittedStreamsTracker = emittedStreamsTracker;
 }
 public WriteQueryEofProjectionProcessingPhase(
     IPublisher publisher,
     int phase,
     string resultStream,
     ICoreProjectionForProcessingPhase coreProjection,
     PartitionStateCache stateCache,
     ICoreProjectionCheckpointManager checkpointManager,
     IEmittedEventWriter emittedEventWriter,
     IEmittedStreamsTracker emittedStreamsTracker)
     : base(publisher, phase, resultStream, coreProjection, stateCache, checkpointManager, emittedEventWriter, emittedStreamsTracker)
 {
 }
 public WriteQueryEofProjectionProcessingPhase(
     IPublisher publisher,
     int phase,
     string resultStream,
     ICoreProjectionForProcessingPhase coreProjection,
     PartitionStateCache stateCache,
     ICoreProjectionCheckpointManager checkpointManager,
     IEmittedEventWriter emittedEventWriter,
     IEmittedStreamsTracker emittedStreamsTracker)
     : base(publisher, phase, resultStream, coreProjection, stateCache, checkpointManager, emittedEventWriter, emittedStreamsTracker)
 {
 }
Esempio n. 6
0
 protected override ProjectionProcessingStrategy GivenProjectionProcessingStrategy()
 {
     _phase1checkpointManager = new FakeCheckpointManager(_bus, _projectionCorrelationId);
     _phase2checkpointManager = new FakeCheckpointManager(_bus, _projectionCorrelationId);
     _emittedStreamsTracker   = new FakeEmittedStreamsTracker();
     _phase1readerStrategy    = GivenPhase1ReaderStrategy();
     _phase2readerStrategy    = GivenPhase2ReaderStrategy();
     _phase1 = new FakeProjectionProcessingPhase(0, this, Phase1CheckpointManager, _phase1readerStrategy, _emittedStreamsTracker);
     _phase2 = new FakeProjectionProcessingPhase(1, this, Phase2CheckpointManager, _phase2readerStrategy, _emittedStreamsTracker);
     return(new FakeProjectionProcessingStrategy(
                _projectionName, _version, new ConsoleLogger(), Phase1, Phase2));
 }
Esempio n. 7
0
        public EventProcessingProjectionProcessingPhase(
            CoreProjection coreProjection,
            Guid projectionCorrelationId,
            IPublisher publisher,
            IPublisher inputQueue,
            ProjectionConfig projectionConfig,
            Action updateStatistics,
            IProjectionStateHandler projectionStateHandler,
            PartitionStateCache partitionStateCache,
            bool definesStateTransform,
            string projectionName,
            ILogger logger,
            CheckpointTag zeroCheckpointTag,
            ICoreProjectionCheckpointManager coreProjectionCheckpointManager,
            StatePartitionSelector statePartitionSelector,
            ReaderSubscriptionDispatcher subscriptionDispatcher,
            IReaderStrategy readerStrategy,
            IResultWriter resultWriter,
            bool useCheckpoints,
            bool stopOnEof,
            bool isBiState,
            bool orderedPartitionProcessing,
            IEmittedStreamsTracker emittedStreamsTracker,
            bool enableContentTypeValidation)
            : base(
                publisher,
                inputQueue,
                coreProjection,
                projectionCorrelationId,
                coreProjectionCheckpointManager,
                projectionConfig,
                projectionName,
                logger,
                zeroCheckpointTag,
                partitionStateCache,
                resultWriter,
                updateStatistics,
                subscriptionDispatcher,
                readerStrategy,
                useCheckpoints,
                stopOnEof,
                orderedPartitionProcessing,
                isBiState,
                emittedStreamsTracker,
                enableContentTypeValidation)
        {
            _projectionStateHandler = projectionStateHandler;
            _definesStateTransform  = definesStateTransform;
            _statePartitionSelector = statePartitionSelector;
            _isBiState = isBiState;

            _stopwatch = new Stopwatch();
        }
Esempio n. 8
0
 protected abstract IProjectionProcessingPhase CreateFirstProcessingPhase(
     IPublisher publisher,
     IPublisher inputQueue,
     Guid projectionCorrelationId,
     PartitionStateCache partitionStateCache,
     Action updateStatistics,
     CoreProjection coreProjection,
     ReaderSubscriptionDispatcher subscriptionDispatcher,
     CheckpointTag zeroCheckpointTag,
     ICoreProjectionCheckpointManager checkpointManager,
     IReaderStrategy readerStrategy,
     IResultWriter resultWriter,
     IEmittedStreamsTracker emittedStreamsTracker);
 protected override void Given()
 {
     _ioDispatcher = new IODispatcher(_node.Node.MainQueue, new PublishEnvelope(_node.Node.MainQueue));
     _node.Node.MainBus.Subscribe(_ioDispatcher.BackwardReader);
     _node.Node.MainBus.Subscribe(_ioDispatcher.ForwardReader);
     _node.Node.MainBus.Subscribe(_ioDispatcher.Writer);
     _node.Node.MainBus.Subscribe(_ioDispatcher.StreamDeleter);
     _node.Node.MainBus.Subscribe(_ioDispatcher.Awaker);
     _node.Node.MainBus.Subscribe(_ioDispatcher);
     _projectionNamesBuilder = ProjectionNamesBuilder.CreateForTest(_projectionName);
     _emittedStreamsTracker  = new EmittedStreamsTracker(_ioDispatcher, new ProjectionConfig(null, 1000, 1000 * 1000, 100, 500, true, true, false, false, false, _trackEmittedStreams), _projectionNamesBuilder);
     _emittedStreamsDeleter  = new EmittedStreamsDeleter(_ioDispatcher, _projectionNamesBuilder.GetEmittedStreamsName(), _projectionNamesBuilder.GetEmittedStreamsCheckpointName());
 }
 protected override void Given()
 {
     _ioDispatcher = new IODispatcher(_node.Node.MainQueue, new PublishEnvelope(_node.Node.MainQueue));
     _node.Node.MainBus.Subscribe(_ioDispatcher.BackwardReader);
     _node.Node.MainBus.Subscribe(_ioDispatcher.ForwardReader);
     _node.Node.MainBus.Subscribe(_ioDispatcher.Writer);
     _node.Node.MainBus.Subscribe(_ioDispatcher.StreamDeleter);
     _node.Node.MainBus.Subscribe(_ioDispatcher.Awaker);
     _node.Node.MainBus.Subscribe(_ioDispatcher);
     _projectionNamesBuilder = ProjectionNamesBuilder.CreateForTest(_projectionName);
     _emittedStreamsTracker = new EmittedStreamsTracker(_ioDispatcher, new ProjectionConfig(null, 1000, 1000 * 1000, 100, 500, true, true, false, false, false, _trackEmittedStreams), _projectionNamesBuilder);
     _emittedStreamsDeleter = new EmittedStreamsDeleter(_ioDispatcher, _projectionNamesBuilder.GetEmittedStreamsName(), _projectionNamesBuilder.GetEmittedStreamsCheckpointName());
 }
 protected EventSubscriptionBasedProjectionProcessingPhase(
     IPublisher publisher,
     IPublisher inputQueue,
     ICoreProjectionForProcessingPhase coreProjection,
     Guid projectionCorrelationId,
     ICoreProjectionCheckpointManager checkpointManager,
     ProjectionConfig projectionConfig,
     string projectionName,
     ILogger logger,
     CheckpointTag zeroCheckpointTag,
     PartitionStateCache partitionStateCache,
     IResultWriter resultWriter,
     Action updateStatistics,
     ReaderSubscriptionDispatcher subscriptionDispatcher,
     IReaderStrategy readerStrategy,
     bool useCheckpoints,
     bool stopOnEof,
     bool orderedPartitionProcessing,
     bool isBiState,
     IEmittedStreamsTracker emittedStreamsTracker,
     bool enableContentTypeValidation)
 {
     _publisher               = publisher;
     _inputQueue              = inputQueue;
     _coreProjection          = coreProjection;
     _projectionCorrelationId = projectionCorrelationId;
     _checkpointManager       = checkpointManager;
     _projectionConfig        = projectionConfig;
     _projectionName          = projectionName;
     _logger              = logger;
     _zeroCheckpointTag   = zeroCheckpointTag;
     _partitionStateCache = partitionStateCache;
     _resultWriter        = resultWriter;
     _updateStatistics    = updateStatistics;
     _processingQueue     = new CoreProjectionQueue(publisher,
                                                    projectionConfig.PendingEventsThreshold,
                                                    orderedPartitionProcessing);
     _processingQueue.EnsureTickPending += EnsureTickPending;
     _subscriptionDispatcher             = subscriptionDispatcher;
     _readerStrategy              = readerStrategy;
     _useCheckpoints              = useCheckpoints;
     _stopOnEof                   = stopOnEof;
     _isBiState                   = isBiState;
     _progressResultWriter        = new ProgressResultWriter(this, _resultWriter);
     _inutQueueEnvelope           = new PublishEnvelope(_inputQueue);
     _emittedStreamsTracker       = emittedStreamsTracker;
     _enableContentTypeValidation = enableContentTypeValidation;
 }
Esempio n. 12
0
        public WriteQueryResultProjectionProcessingPhaseBase(
            IPublisher publisher,
            int phase,
            string resultStream,
            ICoreProjectionForProcessingPhase coreProjection,
            PartitionStateCache stateCache,
            ICoreProjectionCheckpointManager checkpointManager,
            IEmittedEventWriter emittedEventWriter,
            IEmittedStreamsTracker emittedStreamsTracker)
        {
            if (resultStream == null)
            {
                throw new ArgumentNullException("resultStream");
            }
            if (coreProjection == null)
            {
                throw new ArgumentNullException("coreProjection");
            }
            if (stateCache == null)
            {
                throw new ArgumentNullException("stateCache");
            }
            if (checkpointManager == null)
            {
                throw new ArgumentNullException("checkpointManager");
            }
            if (emittedEventWriter == null)
            {
                throw new ArgumentNullException("emittedEventWriter");
            }
            if (emittedStreamsTracker == null)
            {
                throw new ArgumentNullException("emittedStreamsTracker");
            }
            if (string.IsNullOrEmpty(resultStream))
            {
                throw new ArgumentException("resultStream");
            }

            _publisher             = publisher;
            _phase                 = phase;
            _resultStream          = resultStream;
            _coreProjection        = coreProjection;
            _stateCache            = stateCache;
            _checkpointManager     = checkpointManager;
            _emittedEventWriter    = emittedEventWriter;
            _emittedStreamsTracker = emittedStreamsTracker;
        }
Esempio n. 13
0
 public ParallelQueryMasterProjectionProcessingPhase(
     CoreProjection coreProjection,
     Guid projectionCorrelationId,
     IPublisher publisher,
     IPublisher inputQueue,
     ProjectionConfig projectionConfig,
     Action updateStatistics,
     IProjectionStateHandler stateHandler,
     PartitionStateCache partitionStateCache,
     string name,
     ILogger logger,
     CheckpointTag zeroCheckpointTag,
     ICoreProjectionCheckpointManager checkpointManager,
     ReaderSubscriptionDispatcher subscriptionDispatcher,
     IReaderStrategy readerStrategy,
     IResultWriter resultWriter,
     bool checkpointsEnabled,
     bool stopOnEof,
     SpooledStreamReadingDispatcher spoolProcessingResponseDispatcher,
     IEmittedStreamsTracker emittedStreamsTracker)
     : base(
         publisher,
         inputQueue,
         coreProjection,
         projectionCorrelationId,
         checkpointManager,
         projectionConfig,
         name,
         logger,
         zeroCheckpointTag,
         partitionStateCache,
         resultWriter,
         updateStatistics,
         subscriptionDispatcher,
         readerStrategy,
         checkpointsEnabled,
         stopOnEof,
         orderedPartitionProcessing: true,
         isBiState: false,
         emittedStreamsTracker: emittedStreamsTracker)
 {
     _stateHandler = stateHandler;
     _spoolProcessingResponseDispatcher = spoolProcessingResponseDispatcher;
     _spoolProcessingWorkItems          = new Dictionary <Guid, SpoolStreamProcessingWorkItem>();
 }
Esempio n. 14
0
        protected override IProjectionProcessingPhase CreateFirstProcessingPhase(
            IPublisher publisher,
            IPublisher inputQueue,
            Guid projectionCorrelationId,
            PartitionStateCache partitionStateCache,
            Action updateStatistics,
            CoreProjection coreProjection,
            ReaderSubscriptionDispatcher subscriptionDispatcher,
            CheckpointTag zeroCheckpointTag,
            ICoreProjectionCheckpointManager checkpointManager,
            IReaderStrategy readerStrategy,
            IResultWriter resultWriter,
            IEmittedStreamsTracker emittedStreamsTracker)
        {
            var statePartitionSelector = CreateStatePartitionSelector();

            var orderedPartitionProcessing = _sourceDefinition.ByStreams && _sourceDefinition.IsBiState;

            return(new EventProcessingProjectionProcessingPhase(
                       coreProjection,
                       projectionCorrelationId,
                       publisher,
                       inputQueue,
                       _projectionConfig,
                       updateStatistics,
                       _stateHandler,
                       partitionStateCache,
                       _sourceDefinition.DefinesStateTransform,
                       _name,
                       _logger,
                       zeroCheckpointTag,
                       checkpointManager,
                       statePartitionSelector,
                       subscriptionDispatcher,
                       readerStrategy,
                       resultWriter,
                       _projectionConfig.CheckpointsEnabled,
                       this.GetStopOnEof(),
                       _sourceDefinition.IsBiState,
                       orderedPartitionProcessing: orderedPartitionProcessing,
                       emittedStreamsTracker: emittedStreamsTracker,
                       enableContentTypeValidation: _enableContentTypeValidation));
        }
Esempio n. 15
0
 protected override Task Given()
 {
     _ioDispatcher = new IODispatcher(_node.Node.MainQueue, new PublishEnvelope(_node.Node.MainQueue), true);
     _node.Node.MainBus.Subscribe(_ioDispatcher.BackwardReader);
     _node.Node.MainBus.Subscribe(_ioDispatcher.ForwardReader);
     _node.Node.MainBus.Subscribe(_ioDispatcher.Writer);
     _node.Node.MainBus.Subscribe(_ioDispatcher.StreamDeleter);
     _node.Node.MainBus.Subscribe(_ioDispatcher.Awaker);
     _node.Node.MainBus.Subscribe <IODispatcherDelayedMessage>(_ioDispatcher);
     _node.Node.MainBus.Subscribe <ClientMessage.NotHandled>(_ioDispatcher);
     _projectionNamesBuilder = ProjectionNamesBuilder.CreateForTest(_projectionName);
     _emittedStreamsTracker  = new EmittedStreamsTracker(_ioDispatcher,
                                                         new ProjectionConfig(null, 1000, 1000 * 1000, 100, 500, true, true, false, false,
                                                                              _trackEmittedStreams, 10000, 1), _projectionNamesBuilder);
     _emittedStreamsDeleter = new EmittedStreamsDeleter(_ioDispatcher,
                                                        _projectionNamesBuilder.GetEmittedStreamsName(),
                                                        _projectionNamesBuilder.GetEmittedStreamsCheckpointName());
     return(Task.CompletedTask);
 }
 protected abstract IProjectionProcessingPhase CreateFirstProcessingPhase(
     IPublisher publisher,
     IPublisher inputQueue,
     Guid projectionCorrelationId,
     PartitionStateCache partitionStateCache,
     Action updateStatistics,
     CoreProjection coreProjection,
     ReaderSubscriptionDispatcher subscriptionDispatcher,
     CheckpointTag zeroCheckpointTag,
     ICoreProjectionCheckpointManager checkpointManager,
     IReaderStrategy readerStrategy,
     IResultWriter resultWriter,
     IEmittedStreamsTracker emittedStreamsTracker);
 protected override IProjectionProcessingPhase CreateFirstProcessingPhase(
     IPublisher publisher,
     IPublisher inputQueue,
     Guid projectionCorrelationId,
     PartitionStateCache partitionStateCache,
     Action updateStatistics,
     CoreProjection coreProjection,
     ReaderSubscriptionDispatcher subscriptionDispatcher,
     CheckpointTag zeroCheckpointTag,
     ICoreProjectionCheckpointManager checkpointManager,
     IReaderStrategy readerStrategy,
     IResultWriter resultWriter,
     IEmittedStreamsTracker emittedStreamsTracker)
 {
     return new ParallelQueryMasterProjectionProcessingPhase(
         coreProjection,
         projectionCorrelationId,
         publisher,
         inputQueue,
         _projectionConfig,
         updateStatistics,
         _stateHandler,
         partitionStateCache,
         _name,
         _logger,
         zeroCheckpointTag,
         checkpointManager,
         subscriptionDispatcher,
         readerStrategy,
         resultWriter,
         _projectionConfig.CheckpointsEnabled,
         this.GetStopOnEof(),
         _spoolProcessingResponseDispatcher,
         emittedStreamsTracker);
 }
        protected override IProjectionProcessingPhase CreateFirstProcessingPhase(
            IPublisher publisher,
            IPublisher inputQueue,
            Guid projectionCorrelationId,
            PartitionStateCache partitionStateCache,
            Action updateStatistics,
            CoreProjection coreProjection,
            ReaderSubscriptionDispatcher subscriptionDispatcher,
            CheckpointTag zeroCheckpointTag,
            ICoreProjectionCheckpointManager checkpointManager,
            IReaderStrategy readerStrategy,
            IResultWriter resultWriter,
            IEmittedStreamsTracker emittedStreamsTracker)
        {
            var statePartitionSelector = CreateStatePartitionSelector();

            var orderedPartitionProcessing = _sourceDefinition.ByStreams && _sourceDefinition.IsBiState;
            return new EventProcessingProjectionProcessingPhase(
                coreProjection,
                projectionCorrelationId,
                publisher,
                inputQueue,
                _projectionConfig,
                updateStatistics,
                _stateHandler,
                partitionStateCache,
                _sourceDefinition.DefinesStateTransform,
                _name,
                _logger,
                zeroCheckpointTag,
                checkpointManager,
                statePartitionSelector,
                subscriptionDispatcher,
                readerStrategy,
                resultWriter,
                _projectionConfig.CheckpointsEnabled,
                this.GetStopOnEof(),
                _sourceDefinition.IsBiState,
                orderedPartitionProcessing: orderedPartitionProcessing,
                emittedStreamsTracker: emittedStreamsTracker);
        }
 public FakeProjectionProcessingPhase(int phase, specification_with_multi_phase_core_projection specification,
     ICoreProjectionCheckpointManager checkpointManager, IReaderStrategy readerStrategy, IEmittedStreamsTracker emittedStreamsTracker)
 {
     _phase = phase;
     _specification = specification;
     _checkpointManager = checkpointManager;
     _readerStrategy = readerStrategy;
     _emittedStreamsTracker = emittedStreamsTracker;
 }
 protected override ProjectionProcessingStrategy GivenProjectionProcessingStrategy()
 {
     _phase1checkpointManager = new FakeCheckpointManager(_bus, _projectionCorrelationId);
     _phase2checkpointManager = new FakeCheckpointManager(_bus, _projectionCorrelationId);
     _emittedStreamsTracker = new FakeEmittedStreamsTracker();
     _phase1readerStrategy = GivenPhase1ReaderStrategy();
     _phase2readerStrategy = GivenPhase2ReaderStrategy();
     _phase1 = new FakeProjectionProcessingPhase(0, this, Phase1CheckpointManager, _phase1readerStrategy, _emittedStreamsTracker);
     _phase2 = new FakeProjectionProcessingPhase(1, this, Phase2CheckpointManager, _phase2readerStrategy, _emittedStreamsTracker);
     return new FakeProjectionProcessingStrategy(
         _projectionName, _version, new ConsoleLogger(), Phase1, Phase2);
 }