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(); }
protected override void Given() { _projectionId = Guid.NewGuid(); _workerId = Guid.NewGuid(); _projectionName = "projection"; _handlerType = "JS"; _query = "from()"; _config = new ProjectionConfig( new OpenGenericPrincipal("user", "a", "b"), 1000, 100000, 2000, 200, true, true, true, true, true); var builder = new SourceDefinitionBuilder(); builder.FromStream("s1"); builder.FromStream("s2"); builder.IncludeEvent("e1"); builder.IncludeEvent("e2"); builder.SetByStream(); builder.SetResultStreamNameOption("result-stream"); _definition = QuerySourcesDefinition.From(builder); }
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() { Given(); _config = new ProjectionConfig( _projectionMode, _checkpointHandledThreshold, _checkpointUnhandledBytesThreshold, _pendingEventsThreshold, _maxWriteBatchLength, _publishStateUpdates, _emitEventEnabled, _checkpointsEnabled); When(); }
public void setup() { Given(); _namingBuilder = ProjectionNamesBuilder.CreateForTest("projection"); _config = new ProjectionConfig(null, _checkpointHandledThreshold, _checkpointUnhandledBytesThreshold, _pendingEventsThreshold, _maxWriteBatchLength, _emitEventEnabled, _checkpointsEnabled, _createTempStreams, _stopOnEof, isSlaveProjection: false); When(); }
public CreateAndPrepare( IEnvelope envelope, Guid projectionId, string name, ProjectionConfig config, Func<IProjectionStateHandler> handlerFactory) : base(projectionId) { _envelope = envelope; _name = name; _config = config; _handlerFactory = handlerFactory; }
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()); }
public PersistedProjectionConfig(ProjectionConfig config) { RunAs = config.RunAs.Identity.Name; RunAsRoles = config.RunAs == SystemAccount.Principal ? new string[0] : ((OpenGenericPrincipal) config.RunAs).Roles; CheckpointHandledThreshold = config.CheckpointHandledThreshold; CheckpointUnhandledBytesThreshold = config.CheckpointUnhandledBytesThreshold; PendingEventsThreshold = config.PendingEventsThreshold; MaxWriteBatchLength = config.MaxWriteBatchLength; EmitEventEnabled = config.EmitEventEnabled; CheckpointsEnabled = config.CheckpointsEnabled; CreateTempStreams = config.CreateTempStreams; StopOnEof = config.StopOnEof; IsSlaveProjection = config.IsSlaveProjection; TrackEmittedStreams = config.TrackEmittedStreams; }
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(); }
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(); }
protected override void Given() { _projectionId = Guid.NewGuid(); _workerId = Guid.NewGuid(); _projectionName = "projection"; _handlerType = "JS"; _query = "from()"; _config = new ProjectionConfig( new OpenGenericPrincipal("user", "a", "b"), 1000, 100000, 2000, 200, true, true, true, true, true); }
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 CreatePrepared( IEnvelope envelope, Guid projectionId, string name, ProjectionVersion version, ProjectionConfig config, ISourceDefinitionConfigurator sourceDefinition) : base(projectionId) { if (name == null) throw new ArgumentNullException("name"); if (config == null) throw new ArgumentNullException("config"); if (sourceDefinition == null) throw new ArgumentNullException("sourceDefinition"); _envelope = envelope; _name = name; _version = version; _config = config; _sourceDefinition = sourceDefinition; }
public CreatePrepared( IEnvelope envelope, Guid projectionId, string name, ProjectionVersion version, ProjectionConfig config, IQuerySources sourceDefinition, string handlerType, string query) : base(projectionId) { if (name == null) throw new ArgumentNullException("name"); if (config == null) throw new ArgumentNullException("config"); if (sourceDefinition == null) throw new ArgumentNullException("sourceDefinition"); if (handlerType == null) throw new ArgumentNullException("handlerType"); if (query == null) throw new ArgumentNullException("query"); _envelope = envelope; _name = name; _version = version; _config = config; _sourceDefinition = sourceDefinition; _handlerType = handlerType; _query = query; }
public CreateAndPrepareSlave( IEnvelope envelope, Guid projectionId, string name, ProjectionVersion version, ProjectionConfig config, IPublisher resultsPublisher, Guid masterCoreProjectionId, Func<IProjectionStateHandler> handlerFactory) : base(projectionId) { if (envelope == null) throw new ArgumentNullException("envelope"); if (name == null) throw new ArgumentNullException("name"); if (config == null) throw new ArgumentNullException("config"); if (resultsPublisher == null) throw new ArgumentNullException("resultsPublisher"); if (handlerFactory == null) throw new ArgumentNullException("handlerFactory"); _envelope = envelope; _name = name; _version = version; _config = config; _resultsPublisher = resultsPublisher; _masterCoreProjectionId = masterCoreProjectionId; _handlerFactory = handlerFactory; }
public CreateAndPrepare( IEnvelope envelope, Guid projectionId, string name, ProjectionVersion version, ProjectionConfig config, string handlerType, string query, Func<IProjectionStateHandler> handlerFactory) : base(projectionId) { _envelope = envelope; _name = name; _version = version; _config = config; _handlerType = handlerType; _query = query; _handlerFactory = handlerFactory; }
public CreateAndPrepareSlave( Guid projectionId, Guid workerId, string name, ProjectionVersion version, ProjectionConfig config, Guid masterMasterWorkerId, Guid masterCoreProjectionId, string handlerType, string query) : base(projectionId, workerId) { if (name == null) throw new ArgumentNullException("name"); if (config == null) throw new ArgumentNullException("config"); if (handlerType == null) throw new ArgumentNullException("handlerType"); if (query == null) throw new ArgumentNullException("query"); if (masterMasterWorkerId == Guid.Empty) throw new ArgumentException("Must not be empty", "masterMasterWorkerId"); _name = name; _version = version; _config = config; _masterWorkerId = masterMasterWorkerId; _masterCoreProjectionId = masterCoreProjectionId; _handlerType = handlerType; _query = query; }
public CreateAndPrepare( Guid projectionId, Guid workerId, string name, ProjectionVersion version, ProjectionConfig config, string handlerType, string query) : base(projectionId, workerId) { _name = name; _version = version; _config = config; _handlerType = handlerType; _query = query; }