public void setup()
        {
            _subscribeProjectionHandler = new TestHandler<ReaderSubscriptionManagement.Subscribe>();
            _writeEventHandler = new TestHandler<ClientMessage.WriteEvents>();
            _bus.Subscribe(_subscribeProjectionHandler);
            _bus.Subscribe(_writeEventHandler);


            _stateHandler = GivenProjectionStateHandler();
            _firstWriteCorrelationId = Guid.NewGuid();
            _workerId = Guid.NewGuid();
            var dispatcher = new ProjectionManagerMessageDispatcher(new Dictionary<Guid, IPublisher>{{_workerId, GetInputQueue()}});
            _projectionCorrelationId = Guid.NewGuid();
            _projectionConfig = GivenProjectionConfig();
            var projectionProcessingStrategy = GivenProjectionProcessingStrategy();
            _coreProjection = GivenCoreProjection(projectionProcessingStrategy);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointCompleted>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointLoaded>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.RestartRequested>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.Failed>(_coreProjection);
            _bus.Subscribe(new AdHocHandler<ProjectionCoreServiceMessage.CoreTick>(tick => tick.Action()));
            _bus.Subscribe(new AdHocHandler<ReaderCoreServiceMessage.ReaderTick>(tick => tick.Action()));
            _bus.Subscribe<PartitionProcessingResultOutputBase>(dispatcher);
            PreWhen();
            When();
        }
        public void setup()
        {
            _subscribeProjectionHandler = new TestHandler <ReaderSubscriptionManagement.Subscribe>();
            _writeEventHandler          = new TestHandler <ClientMessage.WriteEvents>();
            _bus.Subscribe(_subscribeProjectionHandler);
            _bus.Subscribe(_writeEventHandler);


            _stateHandler = _stateHandler
                            ?? new FakeProjectionStateHandler(configureBuilder: _configureBuilderByQuerySource);
            _firstWriteCorrelationId = Guid.NewGuid();
            _projectionCorrelationId = Guid.NewGuid();
            _projectionConfig        = new ProjectionConfig(null,
                                                            _checkpointHandledThreshold, _checkpointUnhandledBytesThreshold, 1000, 250, true, true,
                                                            _createTempStreams, _stopOnEof);
            _coreProjection = CoreProjection.CreateAndPrepare(
                "projection", _version, _projectionCorrelationId, _bus, _stateHandler, _projectionConfig, _readDispatcher,
                _writeDispatcher, _subscriptionDispatcher, null, _timeProvider);
            _bus.Subscribe <CoreProjectionProcessingMessage.CheckpointCompleted>(_coreProjection);
            _bus.Subscribe <CoreProjectionProcessingMessage.CheckpointLoaded>(_coreProjection);
            _bus.Subscribe <CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_coreProjection);
            _bus.Subscribe <CoreProjectionProcessingMessage.RestartRequested>(_coreProjection);
            _bus.Subscribe <CoreProjectionProcessingMessage.Failed>(_coreProjection);
            _bus.Subscribe <EventReaderSubscriptionMessage.CommittedEventReceived>(_coreProjection);
            _bus.Subscribe <EventReaderSubscriptionMessage.CheckpointSuggested>(_coreProjection);
            _bus.Subscribe <EventReaderSubscriptionMessage.EofReached>(_coreProjection);
            _bus.Subscribe <EventReaderSubscriptionMessage.ProgressChanged>(_coreProjection);
            _bus.Subscribe <EventReaderSubscriptionMessage.NotAuthorized>(_coreProjection);
            _bus.Subscribe(new AdHocHandler <ProjectionCoreServiceMessage.CoreTick>(tick => tick.Action()));
            _bus.Subscribe(new AdHocHandler <ReaderCoreServiceMessage.ReaderTick>(tick => tick.Action()));
            PreWhen();
            When();
        }
 protected override IProjectionProcessingPhase[] CreateProjectionProcessingPhases(
     IPublisher publisher, Guid projectionCorrelationId, ProjectionNamesBuilder namingBuilder,
     PartitionStateCache partitionStateCache, CoreProjection coreProjection, IODispatcher ioDispatcher,
     IProjectionProcessingPhase firstPhase)
 {
     return new[] {firstPhase};
 }
示例#4
0
 public ProgressWorkItem(
     CoreProjection projection, ICoreProjectionCheckpointManager checkpointManager, float progress)
     : base(projection, null) 
 {
     _checkpointManager = checkpointManager;
     _progress = progress;
 }
        public void setup()
        {
            _subscribeProjectionHandler = new TestHandler<ReaderSubscriptionManagement.Subscribe>();
            _writeEventHandler = new TestHandler<ClientMessage.WriteEvents>();
            _bus.Subscribe(_subscribeProjectionHandler);
            _bus.Subscribe(_writeEventHandler);


            _stateHandler = _stateHandler
                            ?? new FakeProjectionStateHandler(configureBuilder: _configureBuilderByQuerySource);
            _firstWriteCorrelationId = Guid.NewGuid();
            _projectionCorrelationId = Guid.NewGuid();
            _projectionConfig = new ProjectionConfig(null, 
                _checkpointHandledThreshold, _checkpointUnhandledBytesThreshold, 1000, 250, true, true,
                _createTempStreams, _stopOnEof);
            _coreProjection = CoreProjection.CreateAndPrepare(
                "projection", _version, _projectionCorrelationId, _bus, _stateHandler, _projectionConfig, _readDispatcher,
                _writeDispatcher, _subscriptionDispatcher, null, _timeProvider);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointCompleted>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointLoaded>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.RestartRequested>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.Failed>(_coreProjection);
            _bus.Subscribe<EventReaderSubscriptionMessage.CommittedEventReceived>(_coreProjection);
            _bus.Subscribe<EventReaderSubscriptionMessage.CheckpointSuggested>(_coreProjection);
            _bus.Subscribe<EventReaderSubscriptionMessage.EofReached>(_coreProjection);
            _bus.Subscribe<EventReaderSubscriptionMessage.ProgressChanged>(_coreProjection);
            _bus.Subscribe<EventReaderSubscriptionMessage.NotAuthorized>(_coreProjection);
            _bus.Subscribe(new AdHocHandler<ProjectionCoreServiceMessage.CoreTick>(tick => tick.Action()));
            _bus.Subscribe(new AdHocHandler<ReaderCoreServiceMessage.ReaderTick>(tick => tick.Action()));
            PreWhen();
            When();
        }
示例#6
0
 public CommittedEventWorkItem(
     CoreProjection projection, ProjectionMessage.Projections.CommittedEventReceived message, string partition)
     : base(projection, message.EventStreamId)
 {
     _message = message;
     _partition = partition;
 }
        protected override IProjectionProcessingPhase[] CreateProjectionProcessingPhases(
            IPublisher publisher, Guid projectionCorrelationId, ProjectionNamesBuilder namingBuilder,
            PartitionStateCache partitionStateCache, CoreProjection coreProjection, IODispatcher ioDispatcher,
            IProjectionProcessingPhase firstPhase)
        {

            var coreProjectionCheckpointWriter =
                new CoreProjectionCheckpointWriter(
                    namingBuilder.MakeCheckpointStreamName(), ioDispatcher, _projectionVersion, _name);
            var checkpointManager2 = new DefaultCheckpointManager(
                publisher, projectionCorrelationId, _projectionVersion, _projectionConfig.RunAs, ioDispatcher,
                _projectionConfig, _name, new PhasePositionTagger(1), namingBuilder, GetUseCheckpoints(), false,
                _sourceDefinition.DefinesFold, coreProjectionCheckpointWriter);

            IProjectionProcessingPhase writeResultsPhase;
            if (GetProducesRunningResults()
                || !string.IsNullOrEmpty(_sourceDefinition.CatalogStream) && _sourceDefinition.ByStreams)
                writeResultsPhase = new WriteQueryEofProjectionProcessingPhase(
                    1, namingBuilder.GetResultStreamName(), coreProjection, partitionStateCache, checkpointManager2,
                    checkpointManager2);
            else
                writeResultsPhase = new WriteQueryResultProjectionProcessingPhase(
                    1, namingBuilder.GetResultStreamName(), coreProjection, partitionStateCache, checkpointManager2,
                    checkpointManager2);

            return new[] {firstPhase, writeResultsPhase};
        }
 public void a_checkpoint_threshold_less_tan_checkpoint_handled_threshold_throws_argument_out_of_range_exception(
     )
 {
     var p = new CoreProjection(
         "projection", Guid.NewGuid(), new FakePublisher(), new FakeProjectionStateHandler(),
         new ProjectionConfig(ProjectionMode.AdHoc, 10, 5, 1000, 250, true, true, true));
 }
        public void setup()
        {
            _subscribeProjectionHandler = new TestHandler <ReaderSubscriptionManagement.Subscribe>();
            _writeEventHandler          = new TestHandler <ClientMessage.WriteEvents>();
            _bus.Subscribe(_subscribeProjectionHandler);
            _bus.Subscribe(_writeEventHandler);


            _stateHandler            = GivenProjectionStateHandler();
            _firstWriteCorrelationId = Guid.NewGuid();
            _projectionCorrelationId = Guid.NewGuid();
            _projectionConfig        = GivenProjectionConfig();
            var projectionProcessingStrategy = GivenProjectionProcessingStrategy();

            _coreProjection = GivenCoreProjection(projectionProcessingStrategy);
            _bus.Subscribe <CoreProjectionProcessingMessage.CheckpointCompleted>(_coreProjection);
            _bus.Subscribe <CoreProjectionProcessingMessage.CheckpointLoaded>(_coreProjection);
            _bus.Subscribe <CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_coreProjection);
            _bus.Subscribe <CoreProjectionProcessingMessage.RestartRequested>(_coreProjection);
            _bus.Subscribe <CoreProjectionProcessingMessage.Failed>(_coreProjection);
            _bus.Subscribe(new AdHocHandler <ProjectionCoreServiceMessage.CoreTick>(tick => tick.Action()));
            _bus.Subscribe(new AdHocHandler <ReaderCoreServiceMessage.ReaderTick>(tick => tick.Action()));
            PreWhen();
            When();
        }
        public override sealed IProjectionProcessingPhase[] CreateProcessingPhases(
            IPublisher publisher, Guid projectionCorrelationId, PartitionStateCache partitionStateCache,
            Action updateStatistics, CoreProjection coreProjection, ProjectionNamesBuilder namingBuilder,
            ITimeProvider timeProvider, IODispatcher ioDispatcher,
            CoreProjectionCheckpointWriter coreProjectionCheckpointWriter)
        {
            var definesFold = _sourceDefinition.DefinesFold;

            var readerStrategy = CreateReaderStrategy(timeProvider);

            var zeroCheckpointTag = readerStrategy.PositionTagger.MakeZeroCheckpointTag();

            var checkpointManager = CreateCheckpointManager(
                projectionCorrelationId, publisher, ioDispatcher, namingBuilder, coreProjectionCheckpointWriter,
                definesFold, readerStrategy);


            var resultWriter = CreateFirstPhaseResultWriter(
                checkpointManager as IEmittedEventWriter, zeroCheckpointTag, namingBuilder);

            var firstPhase = CreateFirstProcessingPhase(
                publisher, projectionCorrelationId, partitionStateCache, updateStatistics, coreProjection,
                _subscriptionDispatcher, zeroCheckpointTag, checkpointManager, readerStrategy, resultWriter);

            return CreateProjectionProcessingPhases(
                publisher, projectionCorrelationId, namingBuilder, partitionStateCache, coreProjection, ioDispatcher,
                firstPhase);
        }
 public CommittedEventWorkItem(
     CoreProjection projection, ProjectionSubscriptionMessage.CommittedEventReceived message,
     StatePartitionSelector statePartitionSelector)
     : base(projection, Guid.NewGuid())
 {
     _statePartitionSelector = statePartitionSelector;
     _message = message;
 }
 public override IProjectionProcessingPhase[] CreateProcessingPhases(
     IPublisher publisher, Guid projectionCorrelationId, PartitionStateCache partitionStateCache,
     Action updateStatistics, CoreProjection coreProjection, ProjectionNamesBuilder namingBuilder,
     ITimeProvider timeProvider, IODispatcher ioDispatcher,
     CoreProjectionCheckpointWriter coreProjectionCheckpointWriter)
 {
     return new IProjectionProcessingPhase[] {_phase1, _phase2};
 }
 // checkpoints are serialized based on string.empty token stream name
 public CheckpointSuggestedWorkItem(
     CoreProjection projection, ProjectionSubscriptionMessage.CheckpointSuggested message,
     ICoreProjectionCheckpointManager checkpointManager)
     : base(projection, "")
 {
     _message = message;
     _checkpointManager = checkpointManager;
 }
 public CommittedEventWorkItem(
     CoreProjection projection, EventReaderSubscriptionMessage.CommittedEventReceived message,
     StatePartitionSelector statePartitionSelector)
     : base(projection, null)
 {
     _statePartitionSelector = statePartitionSelector;
     _message = message;
 }
 public CheckpointSuggestedWorkItem(
     CoreProjection projection, EventReaderSubscriptionMessage.CheckpointSuggested message,
     ICoreProjectionCheckpointManager checkpointManager)
     : base(projection) 
 {
     _projection = projection;
     _message = message;
     _checkpointManager = checkpointManager;
 }
 public void setup()
 {
     _bus = new InMemoryBus("bus");
     _listEventsHandler = new TestMessageHandler<ClientMessage.ReadEventsBackwards>();
     _bus.Subscribe(_listEventsHandler);
     _coreProjection = new CoreProjection(
         "projection", Guid.NewGuid(), _bus, new FakeProjectionStateHandler(),
         new ProjectionConfig(ProjectionMode.AdHoc, 5, 10, 1000, 250, true, true, true));
     _coreProjection.Start();
 }
 public abstract IProjectionProcessingPhase[] CreateProcessingPhases(
     IPublisher publisher,
     IPublisher inputQueue,
     Guid projectionCorrelationId,
     PartitionStateCache partitionStateCache,
     Action updateStatistics,
     CoreProjection coreProjection,
     ProjectionNamesBuilder namingBuilder,
     ITimeProvider timeProvider,
     IODispatcher ioDispatcher,
     CoreProjectionCheckpointWriter coreProjectionCheckpointWriter);
 protected override IProjectionProcessingPhase CreateFirstProcessingPhase(
     IPublisher publisher, Guid projectionCorrelationId, PartitionStateCache partitionStateCache,
     Action updateStatistics, CoreProjection coreProjection, ReaderSubscriptionDispatcher subscriptionDispatcher,
     CheckpointTag zeroCheckpointTag, ICoreProjectionCheckpointManager checkpointManager,
     IReaderStrategy readerStrategy, IResultWriter resultWriter)
 {
     return new ParallelQueryMasterProjectionProcessingPhase(
         coreProjection, projectionCorrelationId, publisher, _projectionConfig, updateStatistics, _stateHandler,
         partitionStateCache, _name, _logger, zeroCheckpointTag, checkpointManager, subscriptionDispatcher,
         readerStrategy, resultWriter, _projectionConfig.CheckpointsEnabled, this.GetStopOnEof(),
         _spoolProcessingResponseDispatcher);
 }
示例#19
0
        private void Start(IPublisher coreOutput, ProjectionStateHandlerFactory handlerFactory, ProjectionConfig config)
        {
            if (coreOutput == null)
            {
                throw new ArgumentNullException("coreOutput");
            }
            if (handlerFactory == null)
            {
                throw new ArgumentNullException("handlerFactory");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (_coreProjection != null)
            {
                throw new InvalidOperationException("CoreProjection has been already created");
            }

            IProjectionStateHandler stateHandler = null;

            try
            {
                stateHandler = handlerFactory.Create(HandlerType, Query, Console.WriteLine);
                var checkpointStrategyBuilder = new CheckpointStrategy.Builder();
                stateHandler.ConfigureSourceProcessingStrategy(checkpointStrategyBuilder);
                checkpointStrategyBuilder.Validate(this.Mode); // avoid future exceptions in coreprojection
                // constructor can fail if wrong source defintion
                //TODO: revise it
                _coreProjection = new CoreProjection(_name, _id, coreOutput, stateHandler, config, _logger);
            }
            catch (Exception ex)
            {
                SetFaulted(
                    String.Format(
                        "Cannot create a projection state handler.\r\n\r\nHandler type: {0}\r\nQuery:\r\n\r\n{1}\r\n\r\nMessage:\r\n\r\n{2}",
                        HandlerType, Query, ex.Message), ex);
                if (stateHandler != null)
                {
                    stateHandler.Dispose();
                }
                return;
            }

            //TODO: load configuration from the definition
            _state = ManagedProjectionState.Running;
            //note: set runnign before start as coreProjection.start() can respond with faulted
            _coreProjection.Start();
        }
 public GetStateWorkItem(
     IEnvelope envelope, Guid correlationId, Guid projectionId, CoreProjection projection,
     PartitionStateCache partitionStateCache, string partition)
     : base(projection, string.Empty)
 {
     if (envelope == null) throw new ArgumentNullException("envelope");
     if (partitionStateCache == null) throw new ArgumentNullException("partitionStateCache");
     if (partition == null) throw new ArgumentNullException("partition");
     _partition = partition;
     _envelope = envelope;
     _correlationId = correlationId;
     _projectionId = projectionId;
     _partitionStateCache = partitionStateCache;
 }
示例#21
0
 private void DisposeCoreProjection()
 {
     if (_coreProjection != null)
     {
         try
         {
             _coreProjection.Dispose();
         }
         catch (Exception ex)
         {
             _logger.ErrorException(ex, "Failed to dispose core projection: {0}", _name);
         }
     }
     _coreProjection = null;
 }
 public void setup()
 {
     _bus = new InMemoryBus("bus");
     _listEventsHandler = new TestMessageHandler<ClientMessage.ReadStreamEventsBackward>();
     _bus.Subscribe(_listEventsHandler);
     _readDispatcher = new RequestResponseDispatcher
         <ClientMessage.ReadStreamEventsBackward, ClientMessage.ReadStreamEventsBackwardCompleted>(
         _bus, v => v.CorrelationId, v => v.CorrelationId, new PublishEnvelope(_bus));
     _writeDispatcher = new RequestResponseDispatcher<ClientMessage.WriteEvents, ClientMessage.WriteEventsCompleted>(
         _bus, v => v.CorrelationId, v => v.CorrelationId, new PublishEnvelope(_bus));
     _bus.Subscribe(_readDispatcher);
     _bus.Subscribe(_writeDispatcher);
     _coreProjection = new CoreProjection(
         "projection", Guid.NewGuid(), _bus, new FakeProjectionStateHandler(),
         new ProjectionConfig(ProjectionMode.AdHoc, 5, 10, 1000, 250, true, true, true), _readDispatcher, _writeDispatcher);
     _coreProjection.Start();
 }
 public void setup()
 {
     _bus = new InMemoryBus("bus");
     _listEventsHandler = new TestHandler<ClientMessage.ReadStreamEventsBackward>();
     _bus.Subscribe(_listEventsHandler);
     _readDispatcher = new RequestResponseDispatcher
         <ClientMessage.ReadStreamEventsBackward, ClientMessage.ReadStreamEventsBackwardCompleted>(
         _bus, v => v.CorrelationId, v => v.CorrelationId, new PublishEnvelope(_bus));
     _writeDispatcher = new RequestResponseDispatcher<ClientMessage.WriteEvents, ClientMessage.WriteEventsCompleted>(
         _bus, v => v.CorrelationId, v => v.CorrelationId, new PublishEnvelope(_bus));
     _bus.Subscribe(_readDispatcher);
     _bus.Subscribe(_writeDispatcher);
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     _projectionConfig = new ProjectionConfig(5, 10, 1000, 250, true, true, false, false);
     _coreProjection = CoreProjection.CreateAndPrepapre(
         "projection", Guid.NewGuid(), _bus, projectionStateHandler, _projectionConfig, _readDispatcher,
         _writeDispatcher, null);
     _coreProjection.Start();
 }
        protected override IProjectionProcessingPhase[] CreateProjectionProcessingPhases(
            IPublisher publisher,
            IPublisher inputQueue,
            Guid projectionCorrelationId,
            ProjectionNamesBuilder namingBuilder,
            PartitionStateCache partitionStateCache,
            CoreProjection coreProjection,
            IODispatcher ioDispatcher,
            IProjectionProcessingPhase firstPhase)
        {
            var coreProjectionCheckpointWriter =
                new CoreProjectionCheckpointWriter(
                    namingBuilder.MakeCheckpointStreamName(),
                    ioDispatcher,
                    _projectionVersion,
                    _name);
            var checkpointManager2 = new DefaultCheckpointManager(
                publisher,
                projectionCorrelationId,
                _projectionVersion,
                _projectionConfig.RunAs,
                ioDispatcher,
                _projectionConfig,
                _name,
                new PhasePositionTagger(1),
                namingBuilder,
                GetUseCheckpoints(),
                false,
                _sourceDefinition.DefinesFold,
                coreProjectionCheckpointWriter);

            var writeResultsPhase = new WriteQueryEofProjectionProcessingPhase(
                publisher,
                1,
                namingBuilder.GetResultStreamName(),
                coreProjection,
                partitionStateCache,
                checkpointManager2,
                checkpointManager2,
                firstPhase.EmittedStreamsTracker);

            return new[] {firstPhase, writeResultsPhase};
        }
 public void setup()
 {
     _bus = new InMemoryBus("bus");
     _listEventsHandler = new TestHandler<ClientMessage.ReadStreamEventsBackward>();
     _bus.Subscribe(_listEventsHandler);
     _ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus));
     _subscriptionDispatcher =
         new ReaderSubscriptionDispatcher
             (_bus);
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.EofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionEofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionMeasured>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionDeleted>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ProgressChanged>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.SubscriptionStarted>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ReaderAssignedReader>());
     _bus.Subscribe(_ioDispatcher.BackwardReader);
     _bus.Subscribe(_ioDispatcher.ForwardReader);
     _bus.Subscribe(_ioDispatcher.Writer);
     _bus.Subscribe(_ioDispatcher);
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     _projectionConfig = new ProjectionConfig(null, 5, 10, 1000, 250, true, true, false, false, false);
     var version = new ProjectionVersion(1, 0, 0);
     var projectionProcessingStrategy = new ContinuousProjectionProcessingStrategy(
         "projection", version, projectionStateHandler, _projectionConfig,
         projectionStateHandler.GetSourceDefinition(), null, _subscriptionDispatcher);
     _coreProjection = projectionProcessingStrategy.Create(
         Guid.NewGuid(),
         _bus,
         Guid.NewGuid(),
         SystemAccount.Principal,
         _bus,
         _ioDispatcher,
         _subscriptionDispatcher,
         new RealTimeProvider());
     _coreProjection.Start();
 }
        public void setup()
        {
            _subscribeProjectionHandler = new TestMessageHandler<ProjectionMessage.Projections.SubscribeProjection>();
            _writeEventHandler = new TestMessageHandler<ClientMessage.WriteEvents>();
            _bus.Subscribe(_subscribeProjectionHandler);
            _bus.Subscribe(_writeEventHandler);

            _stateHandler = _stateHandler
                            ?? new FakeProjectionStateHandler(configureBuilder: _configureBuilderByQuerySource);
            _firstWriteCorrelationId = Guid.NewGuid();
            _projectionCorrelationId = Guid.NewGuid();
            _coreProjection = new CoreProjection(
                "projection", _projectionCorrelationId, _bus, _stateHandler,
                new ProjectionConfig(
                    _projectionMode, _checkpointHandledThreshold, _checkpointUnhandledBytesThreshold, 1000, 250, true, true,
                    true), _readDispatcher, _writeDispatcher);
            _coreProjection.Start();

            When();
        }
        public void setup()
        {
            _subscribeProjectionHandler = new TestHandler<ProjectionSubscriptionManagement.Subscribe>();
            _writeEventHandler = new TestHandler<ClientMessage.WriteEvents>();
            _bus.Subscribe(_subscribeProjectionHandler);
            _bus.Subscribe(_writeEventHandler);


            _stateHandler = _stateHandler
                            ?? new FakeProjectionStateHandler(configureBuilder: _configureBuilderByQuerySource);
            _firstWriteCorrelationId = Guid.NewGuid();
            _projectionCorrelationId = Guid.NewGuid();
            _projectionConfig = new ProjectionConfig(
                _checkpointHandledThreshold, _checkpointUnhandledBytesThreshold, 1000, 250, true, true,
                _createTempStreams, _stopOnEof);
            _coreProjection = CoreProjection.CreateAndPrepapre(
                "projection", _projectionCorrelationId, _bus, _stateHandler, _projectionConfig, _readDispatcher,
                _writeDispatcher, null);
            PreWhen();
            When();
        }
        public void setup()
        {
            _subscribeProjectionHandler = new TestHandler<ReaderSubscriptionManagement.Subscribe>();
            _writeEventHandler = new TestHandler<ClientMessage.WriteEvents>();
            _bus.Subscribe(_subscribeProjectionHandler);
            _bus.Subscribe(_writeEventHandler);


            _stateHandler = GivenProjectionStateHandler();
            _firstWriteCorrelationId = Guid.NewGuid();
            _projectionCorrelationId = Guid.NewGuid();
            _projectionConfig = GivenProjectionConfig();
            var projectionProcessingStrategy = GivenProjectionProcessingStrategy();
            _coreProjection = GivenCoreProjection(projectionProcessingStrategy);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointCompleted>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointLoaded>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.RestartRequested>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.Failed>(_coreProjection);
            _bus.Subscribe(new AdHocHandler<ProjectionCoreServiceMessage.CoreTick>(tick => tick.Action()));
            _bus.Subscribe(new AdHocHandler<ReaderCoreServiceMessage.ReaderTick>(tick => tick.Action()));
            PreWhen();
            When();
        }
 public void a_null_projection_handler_throws_argument_null_exception()
 {
     var p = new CoreProjection(
         "projection", Guid.NewGuid(), new FakePublisher(), null, _defaultProjectionConfig);
 }
 public void a_null_publisher_throws_exception()
 {
     var p = new CoreProjection(
         "projection", Guid.NewGuid(), null, new FakeProjectionStateHandler(), _defaultProjectionConfig);
 }
 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);
        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)
        {
            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);
        }
 protected abstract IProjectionProcessingPhase[] CreateProjectionProcessingPhases(
     IPublisher publisher,
     IPublisher inputQueue,
     Guid projectionCorrelationId,
     ProjectionNamesBuilder namingBuilder,
     PartitionStateCache partitionStateCache,
     CoreProjection coreProjection,
     IODispatcher ioDispatcher,
     IProjectionProcessingPhase firstPhase);
 public void a_checkpoint_threshold_less_tan_checkpoint_handled_threshold_throws_argument_out_of_range_exception(
     )
 {
     var p = new CoreProjection(
         "projection", Guid.NewGuid(), new FakePublisher(), new FakeProjectionStateHandler(),
         new ProjectionConfig(ProjectionMode.AdHoc, 10, 5, 1000, 250, true, true, true));
 }
示例#35
0
 public CompletedWorkItem(CoreProjection projection)
     : base(projection)
 {
     _projection = projection;
 }
 public void a_null_publisher_throws_exception()
 {
     var p = new CoreProjection(
         "projection", Guid.NewGuid(), null, new FakeProjectionStateHandler(), _defaultProjectionConfig);
 }
 public void a_null_name_throws_argument_null_excveption()
 {
     var p = new CoreProjection(
         null, Guid.NewGuid(), new FakePublisher(), new FakeProjectionStateHandler(), _defaultProjectionConfig);
 }
 public void a_negative_checkpoint_handled_interval_throws_argument_out_of_range_exception()
 {
     var p = new CoreProjection(
         "projection", Guid.NewGuid(), new FakePublisher(), new FakeProjectionStateHandler(),
         new ProjectionConfig(ProjectionMode.AdHoc, -1, 10, 1000, 250, true, true, true));
 }