예제 #1
0
 private void DistributeMessage(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
 {
     foreach (var subscriber in _headSubscribers.Values)
     {
         subscriber.Handle(message);
     }
 }
        public override CheckpointTag MakeCheckpointTag(
            CheckpointTag previous, ReaderSubscriptionMessage.EventReaderPartitionDeleted partitionDeleted)
        {
            if (previous.Phase != Phase)
            {
                throw new ArgumentException(
                          string.Format("Invalid checkpoint tag phase.  Expected: {0} Was: {1}", Phase, previous.Phase));
            }

            if (partitionDeleted.DeleteEventOrLinkTargetPosition < previous.Position)
            {
                throw new InvalidOperationException(
                          string.Format(
                              "Cannot make a checkpoint tag at earlier position. '{0}' < '{1}'",
                              partitionDeleted.DeleteEventOrLinkTargetPosition, previous.Position));
            }
            var byIndex = _streams.Contains(partitionDeleted.PositionStreamId);

            //TODO: handle invalid partition deleted messages without required values
            return(byIndex
                                ? previous.UpdateEventTypeIndexPosition(
                       partitionDeleted.DeleteEventOrLinkTargetPosition.Value,
                       _streamToEventType[partitionDeleted.PositionStreamId],
                       partitionDeleted.PositionEventNumber.Value)
                                : previous.UpdateEventTypeIndexPosition(partitionDeleted.DeleteEventOrLinkTargetPosition.Value));
        }
        public void Handle(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
        {
            if (!base._eventFilter.PassesDeleteNotification(message.PositionStreamId))
            {
                return;
            }
            var deletePosition = _positionTagger.MakeCheckpointTag(_positionTracker.LastTag, message);

            PublishPartitionDeleted(message.Partition, deletePosition);
        }
예제 #4
0
        private void CacheRecentMessage(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
        {
            _lastMessages.Enqueue(new PartitionDeletedItem(message));
            if (_lastMessages.Count > _eventCacheSize)
            {
                _lastMessages.Dequeue();
            }
            var lastAvailableCommittedevent = _lastMessages.Peek();

            _subscribeFromPosition = lastAvailableCommittedevent.Position;
        }
예제 #5
0
 private void ValidateEventOrder(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
 {
     if (_lastEventPosition > message.DeleteLinkOrEventPosition.Value ||
         _lastDeletePosition >= message.DeleteLinkOrEventPosition.Value)
     {
         throw new InvalidOperationException(
                   string.Format(
                       "Invalid partition deleted event order.  Last: '{0}' Received: '{1}'  LastDelete: '{2}'",
                       _lastEventPosition, message.DeleteLinkOrEventPosition.Value, _lastEventPosition));
     }
     _lastDeletePosition = message.DeleteLinkOrEventPosition.Value;
 }
예제 #6
0
        public override CheckpointTag MakeCheckpointTag(CheckpointTag previous, ReaderSubscriptionMessage.EventReaderPartitionDeleted partitionDeleted)
        {
            if (previous.Phase != Phase)
            {
                throw new ArgumentException(
                          string.Format("Invalid checkpoint tag phase.  Expected: {0} Was: {1}", Phase, previous.Phase));
            }

            if (partitionDeleted.DeleteLinkOrEventPosition == null)
            {
                throw new ArgumentException("Invalid partiton deleted message. deleteEventOrLinkTargetPosition required");
            }

            return(CheckpointTag.FromPosition(previous.Phase, partitionDeleted.DeleteLinkOrEventPosition.Value));
        }
예제 #7
0
        public bool Handle(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
        {
            EnsureStarted();
            if (message.CorrelationId != _eventReaderId)
            {
                return(false);
            }

            ValidateEventOrder(message);


            CacheRecentMessage(message);
            DistributeMessage(message);
            return(true);
        }
        public override CheckpointTag MakeCheckpointTag(
            CheckpointTag previous, ReaderSubscriptionMessage.EventReaderPartitionDeleted partitionDeleted)
        {
            if (partitionDeleted.PreTagged == null)
            {
                throw new ArgumentException("committedEvent.PreTagged == null", "committedEvent");
            }

            if (previous.Phase != Phase)
            {
                throw new ArgumentException(
                          string.Format("Invalid checkpoint tag phase.  Expected: {0} Was: {1}", Phase, previous.Phase));
            }

            return(partitionDeleted.PreTagged);
        }
예제 #9
0
        public void Handle(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
        {
            Guid projectionId;

            if (_stopped)
            {
                return;
            }
            if (_runHeadingReader && _headingEventReader.Handle(message))
            {
                return;
            }
            if (!_eventReaderSubscriptions.TryGetValue(message.CorrelationId, out projectionId))
            {
                return; // unsubscribed
            }
            _subscriptions[projectionId].Handle(message);
        }
예제 #10
0
        public override CheckpointTag MakeCheckpointTag(
            CheckpointTag previous, ReaderSubscriptionMessage.EventReaderPartitionDeleted partitionDeleted)
        {
            if (previous.Phase != Phase)
            {
                throw new ArgumentException(
                          string.Format("Invalid checkpoint tag phase.  Expected: {0} Was: {1}", Phase, previous.Phase));
            }

            if (partitionDeleted.PositionStreamId != _stream)
            {
                throw new InvalidOperationException(
                          string.Format(
                              "Invalid stream '{0}'.  Expected stream is '{1}'", partitionDeleted.Partition, _stream));
            }

            // return ordinary checkpoint tag (suitable for fromCategory.foreachStream as well as for regular fromStream
            return(CheckpointTag.FromStreamPosition(
                       previous.Phase, partitionDeleted.PositionStreamId, partitionDeleted.PositionEventNumber.Value));
        }
예제 #11
0
        public bool Handle(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
        {
            EnsureStarted();
            if (message.CorrelationId != _eventReaderId)
            {
                return(false);
            }

            ValidateEventOrder(message);


            CacheRecentMessage(message);
            DistributeMessage(message);
            if (_headSubscribers.Count == 0 && !_headEventReaderPaused)
            {
                //                _headEventReader.Pause();
                //                _headEventReaderPaused = true;
            }
            return(true);
        }
예제 #12
0
 public abstract CheckpointTag MakeCheckpointTag(
     CheckpointTag previous, ReaderSubscriptionMessage.EventReaderPartitionDeleted partitionDeleted);
예제 #13
0
 public PartitionDeletedItem(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
     : base(message.DeleteLinkOrEventPosition.Value)
 {
     Message = message;
 }
예제 #14
0
 private void CacheRecentMessage(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
 {
     _lastMessages.Enqueue(new PartitionDeletedItem(message));
     CleanUpCache();
 }
예제 #15
0
 public void Handle(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
 {
     _receivedPartitionDeletedNotifications.Add(message);
 }
 public override CheckpointTag MakeCheckpointTag(
     CheckpointTag previous, ReaderSubscriptionMessage.EventReaderPartitionDeleted partitionDeleted)
 {
     throw new NotSupportedException();
 }
 public void Handle(ReaderSubscriptionMessage.EventReaderPartitionDeleted message)
 {
     throw new NotSupportedException();
 }