Prepare() 공개 메소드

public Prepare ( CheckpointTag position ) : void
position CheckpointTag
리턴 void
 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
 }
예제 #2
0
        /// <returns>true - if checkpoint has been completed in-sync</returns>
        private bool StartCheckpoint(PositionTracker lastProcessedEventPosition, PartitionState projectionState)
        {
            Contract.Requires(_closingCheckpoint == null);
            if (projectionState == null)
            {
                throw new ArgumentNullException("projectionState");
            }

            CheckpointTag requestedCheckpointPosition = lastProcessedEventPosition.LastTag;

            if (requestedCheckpointPosition == _lastCompletedCheckpointPosition)
            {
                return(true);                // either suggested or requested to stop
            }
            if (_usePersistentCheckpoints)   // do not emit any events if we do not use persistent checkpoints
            {
                EmitPartitionCheckpoints();
            }

            _inCheckpoint = true;
            _requestedCheckpointPosition = requestedCheckpointPosition;
            _requestedCheckpointState    = projectionState;
            _closingCheckpoint           = _currentCheckpoint;
            _currentCheckpoint           = CreateProjectionCheckpoint(requestedCheckpointPosition);
            // checkpoint only after assigning new current checkpoint, as it may call back immediately
            _closingCheckpoint.Prepare(requestedCheckpointPosition);
            return(false);            // even if prepare completes in sync it notifies the world by a message
        }
 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(_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));
 }
예제 #5
0
        private void CompleteCheckpoint(PositionTracker lastProcessedEventPosition, string projectionState)
        {
            CheckpointTag requestedCheckpointPosition = lastProcessedEventPosition.LastTag;

            if (requestedCheckpointPosition == _lastCompletedCheckpointPosition)
            {
                return; // either suggested or requested to stop
            }
            _inCheckpoint = true;
            _requestedCheckpointPosition  = requestedCheckpointPosition;
            _requestedCheckpointState     = projectionState;
            _handledEventsAfterCheckpoint = 0;

            _closingCheckpoint = _currentCheckpoint;
            _currentCheckpoint = new ProjectionCheckpoint(
                _publisher, this, requestedCheckpointPosition, _positionTagger.MakeZeroCheckpointTag(), _projectionConfig.MaxWriteBatchLength, _logger);
            // checkpoint only after assigning new current checkpoint, as it may call back immediately
            _closingCheckpoint.Prepare(requestedCheckpointPosition);
        }
 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("stream2", Guid.NewGuid(), "type", "data4"),
             },
         CheckpointTag.FromPosition(120, 110));
     _checkpoint.EmitEvents(
         new[] {new EmittedEvent("stream1", Guid.NewGuid(), "type", "data")},
         CheckpointTag.FromPosition(140, 130));
     _checkpoint.EmitEvents(
         new[] {new EmittedEvent("stream1", Guid.NewGuid(), "type", "data")},
         CheckpointTag.FromPosition(160, 150));
     _checkpoint.Prepare(CheckpointTag.FromPosition(200, 150));
 }
예제 #7
0
        private void CompleteCheckpoint()
        {
            CheckpointTag requestedCheckpointPosition = _lastProcessedEventPosition.LastTag;

            if (requestedCheckpointPosition == _lastCompletedCheckpointPosition)
            {
                return; // either suggested or requested to stop
            }
            _inCheckpoint = true;
            _requestedCheckpointPosition  = requestedCheckpointPosition;
            _requestedCheckpointStateJson = GetProjectionState();
            _handledEventsAfterCheckpoint = 0;

            _closingCheckpoint = _currentCheckpoint;
            _recoveryMode      = false;
            _currentCheckpoint = new ProjectionCheckpoint(
                _publisher, this, false, requestedCheckpointPosition, _projectionConfig.MaxWriteBatchLength, _logger);
            // checkpoint only after assigning new current checkpoint, as it may call back immediately
            _closingCheckpoint.Prepare(requestedCheckpointPosition);
        }
 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
 }
        private void CompleteCheckpoint(PositionTracker lastProcessedEventPosition, string projectionState)
        {
            CheckpointTag requestedCheckpointPosition = lastProcessedEventPosition.LastTag;
            if (requestedCheckpointPosition == _lastCompletedCheckpointPosition)
                return; // either suggested or requested to stop
            _inCheckpoint = true;
            _requestedCheckpointPosition = requestedCheckpointPosition;
            _requestedCheckpointState = projectionState;
            _handledEventsAfterCheckpoint = 0;

            _closingCheckpoint = _currentCheckpoint;
            _currentCheckpoint = new ProjectionCheckpoint(
                _publisher, this, requestedCheckpointPosition, _positionTagger.MakeZeroCheckpointTag(), _projectionConfig.MaxWriteBatchLength, _logger);
            // checkpoint only after assigning new current checkpoint, as it may call back immediately
            _closingCheckpoint.Prepare(requestedCheckpointPosition);
        }
        /// <returns>true - if checkpoint has been completed in-sync</returns>
        private bool StartCheckpoint(PositionTracker lastProcessedEventPosition, PartitionState projectionState)
        {
            Contract.Requires(_closingCheckpoint == null);
            if (projectionState == null) throw new ArgumentNullException("projectionState");

            CheckpointTag requestedCheckpointPosition = lastProcessedEventPosition.LastTag;
            if (requestedCheckpointPosition == _lastCompletedCheckpointPosition)
                return true; // either suggested or requested to stop

            if (_usePersistentCheckpoints) // do not emit any events if we do not use persistent checkpoints
                EmitPartitionCheckpoints();

            _inCheckpoint = true;
            _requestedCheckpointPosition = requestedCheckpointPosition;
            _requestedCheckpointState = projectionState;
            _closingCheckpoint = _currentCheckpoint;
            _currentCheckpoint = CreateProjectionCheckpoint(requestedCheckpointPosition);
            // checkpoint only after assigning new current checkpoint, as it may call back immediately
            _closingCheckpoint.Prepare(requestedCheckpointPosition);
            return false; // even if prepare completes in sync it notifies the world by a message
        }