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();
        }
Ejemplo n.º 2
0
 a_checkpoint_threshold_less_tan_checkpoint_handled_threshold_throws_argument_out_of_range_exception()
 {
     Assert.Throws <ArgumentException>(() => {
         IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
         var version          = new ProjectionVersion(1, 0, 0);
         var projectionConfig = new ProjectionConfig(null, 10, 5, 1000, 250, true, true, false, false,
                                                     true, 10000, 1);
         new ContinuousProjectionProcessingStrategy(
             "projection",
             version,
             projectionStateHandler,
             projectionConfig,
             projectionStateHandler.GetSourceDefinition(),
             null,
             _subscriptionDispatcher,
             true).Create(
             Guid.NewGuid(),
             new FakePublisher(),
             Guid.NewGuid(),
             SystemAccounts.System,
             new FakePublisher(),
             _ioDispatcher,
             _subscriptionDispatcher,
             new RealTimeProvider());
     });
 }
        public void a_null_publisher_throws_exception()
        {
            IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();

            CoreProjection.CreateAndPrepare("projection", new ProjectionVersion(1, 0, 0), Guid.NewGuid(), null, projectionStateHandler, _defaultProjectionConfig,
                                            _readDispatcher, _writeDispatcher, _subscriptionDispatcher, null, new RealTimeProvider());
        }
        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));
            _subscriptionDispatcher =
                new PublishSubscribeDispatcher
                <ReaderSubscriptionManagement.Subscribe,
                 ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage, EventReaderSubscriptionMessage>
                    (_bus, v => v.SubscriptionId, v => v.SubscriptionId);
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CommittedEventReceived>());
            _bus.Subscribe(
                _subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.CheckpointSuggested>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.EofReached>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.ProgressChanged>());
            _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber <EventReaderSubscriptionMessage.NotAuthorized>());
            _bus.Subscribe(_readDispatcher);
            _bus.Subscribe(_writeDispatcher);
            IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();

            _projectionConfig = new ProjectionConfig(null, 5, 10, 1000, 250, true, true, false, false);
            _coreProjection   = CoreProjection.CreateAndPrepare(
                "projection", new ProjectionVersion(1, 0, 0), Guid.NewGuid(), _bus, projectionStateHandler, _projectionConfig, _readDispatcher,
                _writeDispatcher, _subscriptionDispatcher, null, new RealTimeProvider());
            _coreProjection.Start();
        }
        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();
        }
 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.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, SystemAccount.Principal, _bus, _ioDispatcher, _subscriptionDispatcher,
         new RealTimeProvider());
     _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));
     _subscriptionDispatcher =
         new PublishSubscribeDispatcher
             <ReaderSubscriptionManagement.Subscribe,
                 ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage, EventReaderSubscriptionMessage>
             (_bus, v => v.SubscriptionId, v => v.SubscriptionId);
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.EofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ProgressChanged>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());
     _bus.Subscribe(_readDispatcher);
     _bus.Subscribe(_writeDispatcher);
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     _projectionConfig = new ProjectionConfig(null, 5, 10, 1000, 250, true, true, false, false);
     _coreProjection = CoreProjection.CreateAndPrepare(
         "projection", new ProjectionVersion(1, 0, 0), Guid.NewGuid(), _bus, projectionStateHandler, _projectionConfig, _readDispatcher,
         _writeDispatcher, _subscriptionDispatcher, null, new RealTimeProvider());
     _coreProjection.Start();
 }
Ejemplo n.º 8
0
 public void a_negative_checkpoint_handled_interval_throws_argument_out_of_range_exception()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => {
         IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
         var version          = new ProjectionVersion(1, 0, 0);
         var projectionConfig = new ProjectionConfig(null, -1, 10, 1000, 250, true, true, false, false, false,
                                                     true, 10000, 1);
         new ContinuousProjectionProcessingStrategy(
             "projection",
             version,
             projectionStateHandler,
             projectionConfig,
             projectionStateHandler.GetSourceDefinition(),
             null,
             _subscriptionDispatcher).Create(
             Guid.NewGuid(),
             new FakePublisher(),
             Guid.NewGuid(),
             SystemAccount.Principal,
             new FakePublisher(),
             _ioDispatcher,
             _subscriptionDispatcher,
             new RealTimeProvider());
     });
 }
Ejemplo n.º 9
0
        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 = 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();
        }
Ejemplo n.º 12
0
        public void a_zero_checkpoint_handled_threshold_throws_argument_out_of_range_exception()
        {
            IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();

            CoreProjection.CreateAndPrepare("projection", new ProjectionVersion(1, 0, 0), Guid.NewGuid(), new FakePublisher(), projectionStateHandler,
                                            new ProjectionConfig(null, 0, 10, 1000, 250, true, true, false, false), _readDispatcher,
                                            _writeDispatcher, _subscriptionDispatcher, null, new RealTimeProvider());
        }
 public void a_null_name_throws_argument_null_excveption()
 {
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     var version = new ProjectionVersion(1, 0, 0);
     new ContinuousProjectionProcessingStrategy(
         null, version, projectionStateHandler, _defaultProjectionConfig,
         projectionStateHandler.GetSourceDefinition(), null, _subscriptionDispatcher).Create(
             Guid.NewGuid(), new FakePublisher(), SystemAccount.Principal, new FakePublisher(), _ioDispatcher,
             _subscriptionDispatcher, new RealTimeProvider());
 }
 protected override void Given()
 {
     ExistingEvent(
         "$projections-projection-result", "Result", @"{""c"": 100, ""p"": 50}", "{}");
     ExistingEvent(
         "$projections-projection-checkpoint", "$ProjectionCheckpoint",
         @"{""c"": 100, ""p"": 50}", "{}");
     NoStream("$projections-projection-order");
     AllWritesToSucceed("$projections-projection-order");
     _stateHandler = new FakeProjectionStateHandler(failOnProcessEvent: true);
 }
Ejemplo n.º 15
0
 protected override void Given()
 {
     ExistingEvent(
         "$projections-projection-result", "Result", @"{""c"": 100, ""p"": 50}", "{}");
     ExistingEvent(
         "$projections-projection-checkpoint", "$ProjectionCheckpoint",
         @"{""c"": 100, ""p"": 50}", "{}");
     NoStream("$projections-projection-order");
     AllWritesToSucceed("$projections-projection-order");
     _stateHandler = new FakeProjectionStateHandler(failOnProcessEvent: true);
 }
 public void a_negative_checkpoint_handled_interval_throws_argument_out_of_range_exception()
 {
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     var version = new ProjectionVersion(1, 0, 0);
     var projectionConfig = new ProjectionConfig(null, -1, 10, 1000, 250, true, true, false, false, false);
     new ContinuousProjectionProcessingStrategy(
         "projection", version, projectionStateHandler, projectionConfig,
         projectionStateHandler.GetSourceDefinition(), null, _subscriptionDispatcher).Create(
             Guid.NewGuid(), new FakePublisher(), SystemAccount.Principal, new FakePublisher(), _ioDispatcher,
             _subscriptionDispatcher, new RealTimeProvider());
 }
Ejemplo n.º 17
0
        public void a_null_run_as_does_not_throw_exception()
        {
            IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
            var version = new ProjectionVersion(1, 0, 0);

            new ContinuousProjectionProcessingStrategy(
                "projection", version, projectionStateHandler, _defaultProjectionConfig,
                projectionStateHandler.GetSourceDefinition(), null, _subscriptionDispatcher).Create(
                Guid.NewGuid(), new FakePublisher(), null, new FakePublisher(), _ioDispatcher,
                _subscriptionDispatcher, new RealTimeProvider());
        }
Ejemplo n.º 18
0
        public void a_null_io_dispatcher__throws_argument_null_exception()
        {
            IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
            var version = new ProjectionVersion(1, 0, 0);

            new ContinuousProjectionProcessingStrategy(
                "projection", version, projectionStateHandler, _defaultProjectionConfig,
                projectionStateHandler.GetSourceDefinition(), null, _subscriptionDispatcher).Create(
                Guid.NewGuid(), new FakePublisher(), SystemAccount.Principal, new FakePublisher(), null,
                _subscriptionDispatcher, new RealTimeProvider());
        }
 protected override void Given()
 {
     ExistingEvent(
         "$projections-projection-state", "StateUpdated",
         @"{""CommitPosition"": 100, ""PreparePosition"": 50}", "{}");
     ExistingEvent(
         "$projections-projection-checkpoint", "ProjectionCheckpoint",
         @"{""CommitPosition"": 100, ""PreparePosition"": 50}", "{}");
     NoStream("$projections-projection-order");
     AllWritesToSucceed("$projections-projection-order");
     _stateHandler = new FakeProjectionStateHandler(failOnProcessEvent: true);
 }
 protected override void Given()
 {
     ExistingEvent(
         "$projections-projection-state", "StateUpdated",
         @"{""CommitPosition"": 100, ""PreparePosition"": 50, ""LastSeenEvent"": """
         + Guid.NewGuid().ToString("D") + @"""}", "{}");
     ExistingEvent(
         "$projections-projection-checkpoint", "ProjectionCheckpoint",
         @"{""CommitPosition"": 100, ""PreparePosition"": 50, ""LastSeenEvent"": """
         + Guid.NewGuid().ToString("D") + @"""}", "{}");
     _stateHandler = new FakeProjectionStateHandler(failOnProcessEvent: true);
 }
Ejemplo n.º 21
0
        public void a_zero_checkpoint_handled_threshold_throws_argument_out_of_range_exception()
        {
            IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
            var version          = new ProjectionVersion(1, 0, 0);
            var projectionConfig = new ProjectionConfig(null, 0, 10, 1000, 250, true, true, false, false, false);

            new ContinuousProjectionProcessingStrategy(
                "projection", version, projectionStateHandler, projectionConfig,
                projectionStateHandler.GetSourceDefinition(), null, _subscriptionDispatcher).Create(
                Guid.NewGuid(), new FakePublisher(), SystemAccount.Principal, new FakePublisher(), _ioDispatcher,
                _subscriptionDispatcher, new RealTimeProvider());
        }
Ejemplo n.º 22
0
 protected override void Given()
 {
     ExistingEvent(
         "$projections-projection-state", "StateUpdated",
         @"{""CommitPosition"": 100, ""PreparePosition"": 50, ""LastSeenEvent"": """
         + Guid.NewGuid().ToString("D") + @"""}", "{}");
     ExistingEvent(
         "$projections-projection-checkpoint", "ProjectionCheckpoint",
         @"{""CommitPosition"": 100, ""PreparePosition"": 50, ""LastSeenEvent"": """
         + Guid.NewGuid().ToString("D") + @"""}", "{}");
     _stateHandler = new FakeProjectionStateHandler(failOnProcessEvent: true);
 }
Ejemplo n.º 23
0
        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, true, 10000, 1);
            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();
        }
Ejemplo n.º 24
0
 protected override void Given()
 {
     _configureBuilderByQuerySource = source =>
     {
         source.FromAll();
         source.AllEvents();
         source.SetByCustomPartitions();
         source.SetDefinesStateTransform();
     };
     TicksAreHandledImmediately();
     AllWritesSucceed();
     NoOtherStreams();
     _stateHandler = new FakeProjectionStateHandler(
         configureBuilder: _configureBuilderByQuerySource, failOnGetPartition: false);
 }
 protected override void Given()
 {
     _configureBuilderByQuerySource = source =>
         {
             source.FromAll();
             source.AllEvents();
             source.SetByCustomPartitions();
             source.SetDefinesStateTransform();
         };
     TicksAreHandledImmediately();
     AllWritesSucceed();
     NoOtherStreams();
     _stateHandler = new FakeProjectionStateHandler(
          configureBuilder: _configureBuilderByQuerySource, failOnGetPartition: false);
 }
 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 void Given()
        {
            _configureBuilderByQuerySource = source =>
                {
                    source.FromAll();
                    source.AllEvents();
                    source.SetByCustomPartitions();
                    source.SetEmitStateUpdated();
                };
            TicksAreHandledImmediately();
            NoStream("$projections-projection-state");
            NoStream("$projections-projection-order");
            AllWritesToSucceed("$projections-projection-order");
            NoStream("$projections-projection-checkpoint");
            NoStream("$projections-projection-region-a-state");

            _stateHandler = new FakeProjectionStateHandler(configureBuilder: _configureBuilderByQuerySource, failOnGetPartition: false);

        }
        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();
        }
Ejemplo n.º 30
0
        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();
            _coreProjection          = new CoreProjection(
                "projection", _projectionCorrelationId, _bus, _stateHandler,
                new ProjectionConfig(
                    _projectionMode, _checkpointHandledThreshold, _checkpointUnhandledBytesThreshold, 1000, 250, true, true,
                    true), _readDispatcher, _writeDispatcher);
            _coreProjection.Start();

            When();
        }
Ejemplo n.º 31
0
 public void a_null_time_provider__throws_argument_null_exception()
 {
     Assert.Throws <ArgumentNullException>(() => {
         IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
         var version = new ProjectionVersion(1, 0, 0);
         new ContinuousProjectionProcessingStrategy(
             "projection",
             version,
             projectionStateHandler,
             _defaultProjectionConfig,
             projectionStateHandler.GetSourceDefinition(),
             null,
             _subscriptionDispatcher).Create(
             Guid.NewGuid(),
             new FakePublisher(),
             Guid.NewGuid(),
             SystemAccounts.System,
             new FakePublisher(),
             _ioDispatcher,
             _subscriptionDispatcher,
             null);
     });
 }
Ejemplo n.º 32
0
 public void an_empty_name_throws_argument_exception()
 {
     Assert.Throws <ArgumentException>(() => {
         IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
         var version = new ProjectionVersion(1, 0, 0);
         new ContinuousProjectionProcessingStrategy(
             "",
             version,
             projectionStateHandler,
             _defaultProjectionConfig,
             projectionStateHandler.GetSourceDefinition(),
             null,
             _subscriptionDispatcher).Create(
             Guid.NewGuid(),
             new FakePublisher(),
             Guid.NewGuid(),
             SystemAccount.Principal,
             new FakePublisher(),
             _ioDispatcher,
             _subscriptionDispatcher,
             new RealTimeProvider());
     });
 }
        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_run_as_does_not_throw_exception()
 {
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     var version = new ProjectionVersion(1, 0, 0);
     new ContinuousProjectionProcessingStrategy(
         "projection", version, projectionStateHandler, _defaultProjectionConfig,
         projectionStateHandler.GetSourceDefinition(), null, _subscriptionDispatcher).Create(
             Guid.NewGuid(), new FakePublisher(), null, new FakePublisher(), _ioDispatcher,
             _subscriptionDispatcher, new RealTimeProvider());
 }
 public void a_null_publisher_throws_exception()
 {
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     CoreProjection.CreateAndPrepare("projection", new ProjectionVersion(1, 0, 0), Guid.NewGuid(), null, projectionStateHandler, _defaultProjectionConfig,
                                  _readDispatcher, _writeDispatcher, _subscriptionDispatcher, null, new RealTimeProvider());
 }
 public void an_empty_name_throws_argument_exception()
 {
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     var p = CoreProjection.CreateAndPrepapre("", Guid.NewGuid(), new FakePublisher(), projectionStateHandler, _defaultProjectionConfig,
                                  _readDispatcher, _writeDispatcher, null);
 }
 public void a_null_publisher_throws_exception()
 {
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     var p = CoreProjection.CreateAndPrepapre("projection", Guid.NewGuid(), null, projectionStateHandler, _defaultProjectionConfig,
                                  _readDispatcher, _writeDispatcher, null);
 }
 public void a_checkpoint_threshold_less_tan_checkpoint_handled_threshold_throws_argument_out_of_range_exception(
     )
 {
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     CoreProjection.CreateAndPrepare("projection", new ProjectionVersion(1, 0, 0), Guid.NewGuid(), new FakePublisher(), projectionStateHandler,
                                  new ProjectionConfig(null, 10, 5, 1000, 250, true, true, false, false), _readDispatcher,
                                  _writeDispatcher, _subscriptionDispatcher, null, new RealTimeProvider());
 }
 public void a_negative_checkpoint_handled_interval_throws_argument_out_of_range_exception()
 {
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     var p = CoreProjection.CreateAndPrepapre("projection", Guid.NewGuid(), new FakePublisher(), projectionStateHandler,
                                  new ProjectionConfig(-1, 10, 1000, 250, true, true, false, false), _readDispatcher,
                                  _writeDispatcher, null);
 }