private void DeliverEvent(EventStore.Core.Data.ResolvedEvent pair, float progress) { EventRecord positionEvent = pair.OriginalEvent; if (positionEvent.LogPosition > _limitingCommitPosition) { return; } var resolvedEvent = new ResolvedEvent(pair, null); if (resolvedEvent.IsLinkToDeletedStream || resolvedEvent.IsStreamDeletedEvent) { return; } _publisher.Publish( //TODO: publish both link and event data new ReaderSubscriptionMessage.CommittedEventDistributed( EventReaderCorrelationId, resolvedEvent, _stopOnEof ? (long?)null : positionEvent.LogPosition, progress, source: GetType(), preTagged: CheckpointTag.FromByStreamPosition( 0, _catalogStreamName, _catalogCurrentSequenceNumber, positionEvent.EventStreamId, positionEvent.EventNumber, _limitingCommitPosition.Value))); //TODO: consider passing phase from outside instead of using 0 (above) }
private void TakeNextStreamIfRequired() { if (_dataNextSequenceNumber == int.MaxValue || _dataStreamName == null) { if (_dataStreamName != null) { SendPartitionEof( _dataStreamName, CheckpointTag.FromByStreamPosition( 0, "", _catalogCurrentSequenceNumber, _dataStreamName, int.MaxValue, _limitingCommitPosition.Value)); } _dataStreamName = null; if (_catalogEof && _pendingStreams.Count == 0) { SendEof(); return; } if (_pendingStreams.Count == 0) { SendIdle(); return; } var nextDataStream = _pendingStreams.Dequeue(); _dataStreamName = nextDataStream.Item1; _catalogCurrentSequenceNumber = nextDataStream.Item2; _dataNextSequenceNumber = 0; } }
private void DeliverEvent(EventRecord @event, EventRecord link, float progress) { _deliveredEvents++; EventRecord positionEvent = (link ?? @event); if (positionEvent.LogPosition > _limitingCommitPosition) { return; } var resolvedLinkTo = positionEvent.EventStreamId != @event.EventStreamId || positionEvent.EventNumber != @event.EventNumber; _publisher.Publish( //TODO: publish both link and event data new ReaderSubscriptionMessage.CommittedEventDistributed( EventReaderCorrelationId, new ResolvedEvent( positionEvent.EventStreamId, positionEvent.EventNumber, @event.EventStreamId, @event.EventNumber, resolvedLinkTo, new TFPos(-1, positionEvent.LogPosition), new TFPos(-1, @event.LogPosition), @event.EventId, @event.EventType, (@event.Flags & PrepareFlags.IsJson) != 0, @event.Data, @event.Metadata, link == null ? null : link.Metadata, positionEvent.TimeStamp), _stopOnEof ? (long?)null : positionEvent.LogPosition, progress, source: GetType(), preTagged: CheckpointTag.FromByStreamPosition( 0, _catalogStreamName, _catalogCurrentSequenceNumber, positionEvent.EventStreamId, positionEvent.EventNumber, _limitingCommitPosition.Value))); //TODO: consider passing phase from outside instead of using 0 (above) }
private void TakeNextStreamIfRequired() { if (_dataNextSequenceNumber == EventNumber.DeletedStream || _dataStreamName == null) { if (_dataStreamName != null) { SendPartitionEof( _dataStreamName, CheckpointTag.FromByStreamPosition( 0, _catalogStreamName, _catalogCurrentSequenceNumber, _dataStreamName, EventNumber.DeletedStream, _limitingCommitPosition.Value)); } if (_catalogEof && _pendingStreams.Count == 0) { SendEof(); return; } _dataStreamName = _pendingStreams.Dequeue(); _catalogCurrentSequenceNumber++; _dataNextSequenceNumber = 0; } }
public ExternallyFedReaderStrategy( int phase, IPrincipal runAs, ITimeProvider timeProvider, long limitingCommitPosition) { _phase = phase; _runAs = runAs; _timeProvider = timeProvider; _eventFilter = new BypassingEventFilter(); _positionTagger = new PreTaggedPositionTagger( phase, CheckpointTag.FromByStreamPosition(phase, "", -1, null, -1, limitingCommitPosition)); }
public ExternallyFedReaderStrategy( string tag, int phase, ITimeProvider timeProvider, long limitingCommitPosition) { _tag = tag; _timeProvider = timeProvider; _eventFilter = new BypassingEventFilter(); _positionTagger = new PreTaggedPositionTagger( phase, CheckpointTag.FromByStreamPosition(phase, "", -1, null, -1, limitingCommitPosition)); }
public override CheckpointTag MakeCheckpointTag( CheckpointTag previous, ReaderSubscriptionMessage.CommittedEventDistributed committedEvent) { if (previous.Phase != Phase) { throw new ArgumentException( string.Format("Invalid checkpoint tag phase. Expected: {0} Was: {1}", Phase, previous.Phase)); } if (committedEvent.Data.PositionStreamId != _catalogStream) { throw new InvalidOperationException( string.Format( "Invalid catalog stream '{0}'. Expected catalog stream is '{1}'", committedEvent.Data.EventStreamId, _catalogStream)); } return(CheckpointTag.FromByStreamPosition( previous.Phase, "", committedEvent.Data.PositionSequenceNumber, null, -1, previous.CommitPosition.GetValueOrDefault())); }
private PositionTagger CreatePositionTagger() { if (_allStreams && _events != null && _events.Count >= 1) { return(new EventByTypeIndexPositionTagger(_phase, _events.ToArray(), _includeStreamDeletedNotification)); } if (_allStreams && _reorderEvents) { return(new PreparePositionTagger(_phase)); } if (_allStreams) { return(new TransactionFilePositionTagger(_phase)); } if (_categories != null && _categories.Count == 1) { //TODO: '-' is a hardcoded separator return(new StreamPositionTagger(_phase, "$ce-" + _categories.First())); } if (_categories != null) { throw new NotSupportedException(); } if (_streams != null && _streams.Count == 1) { return(new StreamPositionTagger(_phase, _streams.First())); } if (_streams != null && _streams.Count > 1) { return(new MultiStreamPositionTagger(_phase, _streams.ToArray())); } if (!string.IsNullOrEmpty(_catalogStream)) { return(new PreTaggedPositionTagger( _phase, CheckpointTag.FromByStreamPosition(0, _catalogStream, -1, null, -1, long.MinValue))); } //TODO: consider passing projection phase from outside (above) throw new NotSupportedException(); }
public override CheckpointTag MakeZeroCheckpointTag() { return(CheckpointTag.FromByStreamPosition( Phase, "", -1, null, -1, int.MinValue)); }