public void setup() { _readyHandler = new TestMessageHandler<ProjectionMessage.Projections.ReadyForCheckpoint>(); _checkpoint = new ProjectionCheckpoint( new FakePublisher(), _readyHandler, false, CheckpointTag.FromPosition(0, -1), 250); _checkpoint.Start(); }
public void setup() { _readyHandler = new TestCheckpointManagerMessageHandler(); _checkpoint = new ProjectionCheckpoint( _readDispatcher, _writeDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler, CheckpointTag.FromPosition(100, 50), new TransactionFilePositionTagger(), CheckpointTag.FromPosition(0, -1), 250); _checkpoint.ValidateOrderAndEmitEvents( new[] { new EmittedDataEvent( "stream2", Guid.NewGuid(), "type", "data2", null, CheckpointTag.FromPosition(120, 110), null), new EmittedDataEvent( "stream3", Guid.NewGuid(), "type", "data3", null, CheckpointTag.FromPosition(120, 110), null), new EmittedDataEvent( "stream2", Guid.NewGuid(), "type", "data4", null, CheckpointTag.FromPosition(120, 110), null), }); _checkpoint.ValidateOrderAndEmitEvents( new[] { new EmittedDataEvent( "stream1", Guid.NewGuid(), "type", "data", null, CheckpointTag.FromPosition(140, 130), null) }); _checkpoint.Start(); }
public void setup() { _readyHandler = new TestCheckpointManagerMessageHandler(); _checkpoint = new ProjectionCheckpoint( _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler, CheckpointTag.FromPosition(0, 100, 50), new TransactionFilePositionTagger(0), CheckpointTag.FromPosition(0, 0, -1), 250); _checkpoint.Start(); _checkpoint.ValidateOrderAndEmitEvents( new[] { new EmittedEventEnvelope( new EmittedDataEvent( "stream2", Guid.NewGuid(), "type", true, "data2", null, CheckpointTag.FromPosition(0, 120, 110), null)), new EmittedEventEnvelope( new EmittedDataEvent( "stream2", Guid.NewGuid(), "type", true, "data4", null, CheckpointTag.FromPosition(0, 120, 110), null)), }); _checkpoint.ValidateOrderAndEmitEvents( new[] { new EmittedEventEnvelope( new EmittedDataEvent( "stream1", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 140, 130), null)) }); var writes = _consumer.HandledMessages.OfType<ClientMessage.WriteEvents>().ToArray(); writes[0].Envelope.ReplyWith(new ClientMessage.WriteEventsCompleted(writes[0].CorrelationId, 0, 0)); writes[1].Envelope.ReplyWith(new ClientMessage.WriteEventsCompleted(writes[1].CorrelationId, 0, 0)); _checkpoint.Prepare(CheckpointTag.FromPosition(0, 200, 150)); //TODO: test whether checkpoint does not allow positions before last emitted event caused by position }
public void setup() { _readyHandler = new TestCheckpointManagerMessageHandler(); _checkpoint = new ProjectionCheckpoint( _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler, CheckpointTag.FromPosition(0, 100, 50), new TransactionFilePositionTagger(0), CheckpointTag.FromPosition(0, 0, -1), 250); _checkpoint.Start(); _checkpoint.ValidateOrderAndEmitEvents( new[] { new EmittedEventEnvelope( new EmittedDataEvent( "stream2", Guid.NewGuid(), "type", true, "data2", null, CheckpointTag.FromPosition(0, 120, 110), null)), new EmittedEventEnvelope( new EmittedDataEvent( "stream2", Guid.NewGuid(), "type", true, "data4", null, CheckpointTag.FromPosition(0, 120, 110), null)), }); _checkpoint.ValidateOrderAndEmitEvents( new[] { new EmittedEventEnvelope( new EmittedDataEvent( "stream1", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 140, 130), null)) }); _checkpoint.ValidateOrderAndEmitEvents( new[] { new EmittedEventEnvelope( new EmittedDataEvent( "stream1", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 160, 150), null)) }); _checkpoint.Prepare(CheckpointTag.FromPosition(0, 200, 150)); }
public void setup() { _readyHandler = new TestCheckpointManagerMessageHandler();; _checkpoint = new ProjectionCheckpoint( new FakePublisher(), _readyHandler, CheckpointTag.FromPosition(0, -1), CheckpointTag.FromPosition(0, -1), 250); _checkpoint.Start(); }
public void setup() { _readyHandler = new TestCheckpointManagerMessageHandler(); _checkpoint = new ProjectionCheckpoint( _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler, CheckpointTag.FromPosition(0, 0, -1), new TransactionFilePositionTagger(0), 250); _checkpoint.Start(); }
public virtual void Start(CheckpointTag checkpointTag) { Contract.Requires(_currentCheckpoint == null); if (_started) { throw new InvalidOperationException("Already started"); } _started = true; _lastProcessedEventPosition.UpdateByCheckpointTagInitial(checkpointTag); _lastProcessedEventProgress = -1; _lastCompletedCheckpointPosition = checkpointTag; _requestedCheckpointPosition = null; _currentCheckpoint = CreateProjectionCheckpoint(_lastProcessedEventPosition.LastTag); _currentCheckpoint.Start(); }
private void EnterSubscribed() { _lastEnqueuedEventTag = _checkpointStrategy.PositionTagger.MakeZeroCheckpointTag(); _requestedCheckpointPosition = null; _currentCheckpoint = new ProjectionCheckpoint( _publisher, this, _recoveryMode, _lastProcessedEventPosition.LastTag, _projectionConfig.MaxWriteBatchLength, _logger); _currentCheckpoint.Start(); _publisher.Publish( new ProjectionMessage.Projections.SubscribeProjection( _projectionCorrelationId, this, _lastProcessedEventPosition.LastTag, _checkpointStrategy, _projectionConfig.CheckpointUnhandledBytesThreshold)); _publisher.Publish(new ProjectionMessage.Projections.Started(_projectionCorrelationId)); GoToState(State.Running); }
protected void CheckpointWritten() { _lastCompletedCheckpointPosition = _requestedCheckpointPosition; _closingCheckpoint = null; if (!_stopping) { // ignore any writes pending in the current checkpoint (this is not the best, but they will never hit the storage, so it is safe) _currentCheckpoint.Start(); } _inCheckpoint = false; ProcessCheckpoints(); _coreProjection.Handle( new CoreProjectionProcessingMessage.CheckpointCompleted(_lastCompletedCheckpointPosition)); }
public void setup() { _readyHandler = new TestCheckpointManagerMessageHandler();; _checkpoint = new ProjectionCheckpoint(_bus, _readyHandler, CheckpointTag.FromPosition(100, 50), CheckpointTag.FromPosition(0, -1), 250); _checkpoint.Start(); _checkpoint.ValidateOrderAndEmitEvents( new[] { new EmittedEvent("stream2", Guid.NewGuid(), "type", "data2", CheckpointTag.FromPosition(120, 110), null), new EmittedEvent("stream2", Guid.NewGuid(), "type", "data4", CheckpointTag.FromPosition(120, 110), null), }); _checkpoint.ValidateOrderAndEmitEvents( new[] {new EmittedEvent("stream1", Guid.NewGuid(), "type", "data", CheckpointTag.FromPosition(140, 130), null)}); _checkpoint.ValidateOrderAndEmitEvents( new[] {new EmittedEvent("stream1", Guid.NewGuid(), "type", "data", CheckpointTag.FromPosition(160, 150), null)}); _checkpoint.Prepare(CheckpointTag.FromPosition(200, 150)); }
public void setup() { _readyHandler = new TestMessageHandler<ProjectionMessage.Projections.ReadyForCheckpoint>(); _checkpoint = new ProjectionCheckpoint(_bus, _readyHandler, false, CheckpointTag.FromPosition(100, 50), 250); _checkpoint.Start(); _checkpoint.EmitEvents( new[] { new EmittedEvent("stream2", Guid.NewGuid(), "type", "data2"), new EmittedEvent("stream3", Guid.NewGuid(), "type", "data3"), new EmittedEvent("stream2", Guid.NewGuid(), "type", "data4"), }, CheckpointTag.FromPosition(120, 110)); _checkpoint.EmitEvents( new[] {new EmittedEvent("stream1", Guid.NewGuid(), "type", "data")}, CheckpointTag.FromPosition(140, 130)); }
protected void CheckpointWritten(CheckpointTag lastCompletedCheckpointPosition) { Contract.Requires(_closingCheckpoint != null); _lastCompletedCheckpointPosition = lastCompletedCheckpointPosition; _closingCheckpoint.Dispose(); _closingCheckpoint = null; if (!_stopping) { // ignore any writes pending in the current checkpoint (this is not the best, but they will never hit the storage, so it is safe) _currentCheckpoint.Start(); } _inCheckpoint = false; //NOTE: the next checkpoint will start by completing checkpoint work item _publisher.Publish( new CoreProjectionProcessingMessage.CheckpointCompleted( _projectionCorrelationId, _lastCompletedCheckpointPosition)); }
public void Start(CheckpointTag checkpointTag) { if (!_stateLoaded) { throw new InvalidOperationException("State is not loaded"); } if (_started) { throw new InvalidOperationException("Already started"); } _started = true; _lastProcessedEventPosition.UpdateByCheckpointTagInitial(checkpointTag); _lastCompletedCheckpointPosition = checkpointTag; _requestedCheckpointPosition = null; _currentCheckpoint = new ProjectionCheckpoint( _publisher, this, _lastProcessedEventPosition.LastTag, _projectionConfig.MaxWriteBatchLength, _logger); _currentCheckpoint.Start(); }
public void setup() { _readyHandler = new TestCheckpointManagerMessageHandler();; _checkpoint = new ProjectionCheckpoint(_bus, _readyHandler, CheckpointTag.FromPosition(100, 50), CheckpointTag.FromPosition(0, -1), 250); _checkpoint.Start(); _checkpoint.EmitEvents( new[] { new EmittedEvent("stream2", Guid.NewGuid(), "type", "data2", CheckpointTag.FromPosition(120, 110), null), new EmittedEvent("stream2", Guid.NewGuid(), "type", "data4", CheckpointTag.FromPosition(120, 110), null), } ); _checkpoint.EmitEvents( new[] {new EmittedEvent("stream1", Guid.NewGuid(), "type", "data", CheckpointTag.FromPosition(140, 130), null)}); var writes = _consumer.HandledMessages.OfType<ClientMessage.WriteEvents>().ToArray(); writes[0].Envelope.ReplyWith( new ClientMessage.WriteEventsCompleted(writes[0].CorrelationId, writes[0].EventStreamId, 0)); writes[1].Envelope.ReplyWith( new ClientMessage.WriteEventsCompleted(writes[1].CorrelationId, writes[1].EventStreamId, 0)); _checkpoint.Prepare(CheckpointTag.FromPosition(200, 150)); //TODO: test whether checkpoint does not allow positions before last emitted event caused by position }
public void Start(CheckpointTag checkpointTag) { if (!_stateLoaded) throw new InvalidOperationException("State is not loaded"); if (_started) throw new InvalidOperationException("Already started"); _started = true; _lastProcessedEventPosition.UpdateByCheckpointTagInitial(checkpointTag); _lastProcessedEventProgress = -1; _lastCompletedCheckpointPosition = checkpointTag; _requestedCheckpointPosition = null; _currentCheckpoint = new ProjectionCheckpoint( _publisher, this, _lastProcessedEventPosition.LastTag, _positionTagger.MakeZeroCheckpointTag(), _projectionConfig.MaxWriteBatchLength, _logger); _currentCheckpoint.Start(); }
public virtual void Start(CheckpointTag checkpointTag) { Contract.Requires(_currentCheckpoint == null); if (_started) throw new InvalidOperationException("Already started"); _started = true; _lastProcessedEventPosition.UpdateByCheckpointTagInitial(checkpointTag); _lastProcessedEventProgress = -1; _lastCompletedCheckpointPosition = checkpointTag; _requestedCheckpointPosition = null; _currentCheckpoint = CreateProjectionCheckpoint(_lastProcessedEventPosition.LastTag); _currentCheckpoint.Start(); }