Example #1
0
        public override CheckpointTag AdjustTag(CheckpointTag tag)
        {
            if (tag.Mode_ == CheckpointTag.Mode.EventTypeIndex)
            {
                int p;
                return(CheckpointTag.FromEventTypeIndexPositions(
                           tag.Position, _eventTypes.ToDictionary(v => v, v => tag.Streams.TryGetValue(v, out p) ? p : -1)));
            }

            switch (tag.Mode_)
            {
            case CheckpointTag.Mode.MultiStream:
                throw new NotSupportedException("Conversion from MultiStream to EventTypeIndex position tag is not supported");

            case CheckpointTag.Mode.Stream:
                throw new NotSupportedException("Conversion from Stream to EventTypeIndex position tag is not supported");

            case CheckpointTag.Mode.PreparePosition:
                throw new NotSupportedException("Conversion from PreparePosition to EventTypeIndex position tag is not supported");

            case CheckpointTag.Mode.Position:
                return(CheckpointTag.FromEventTypeIndexPositions(
                           tag.Position, _eventTypes.ToDictionary(v => v, v => - 1)));

            default:
                throw new Exception();
            }
        }
        public override CheckpointTag AdjustTag(CheckpointTag tag)
        {
            if (tag.Phase < Phase)
            {
                return(tag);
            }
            if (tag.Phase > Phase)
            {
                throw new ArgumentException(
                          string.Format("Invalid checkpoint tag phase.  Expected less or equal to: {0} Was: {1}", Phase,
                                        tag.Phase), "tag");
            }

            if (tag.Mode_ == CheckpointTag.Mode.EventTypeIndex)
            {
                long p;
                return(CheckpointTag.FromEventTypeIndexPositions(
                           tag.Phase, tag.Position,
                           _eventTypes.ToDictionary(v => v, v => tag.Streams.TryGetValue(v, out p) ? p : -1)));
            }

            switch (tag.Mode_)
            {
            case CheckpointTag.Mode.MultiStream:
                throw new NotSupportedException(
                          "Conversion from MultiStream to EventTypeIndex position tag is not supported");

            case CheckpointTag.Mode.Stream:
                throw new NotSupportedException(
                          "Conversion from Stream to EventTypeIndex position tag is not supported");

            case CheckpointTag.Mode.PreparePosition:
                throw new NotSupportedException(
                          "Conversion from PreparePosition to EventTypeIndex position tag is not supported");

            case CheckpointTag.Mode.Position:
                return(CheckpointTag.FromEventTypeIndexPositions(
                           tag.Phase, tag.Position, _eventTypes.ToDictionary(v => v, v => (long)-1)));

            default:
                throw new NotSupportedException(string.Format(
                                                    "The given checkpoint is invalid. Possible causes might include having written an event to the projection's managed stream. The bad checkpoint: {0}",
                                                    tag.ToString()));
            }
        }
Example #3
0
        public override CheckpointTag AdjustTag(CheckpointTag tag)
        {
            if (tag.Phase < Phase)
            {
                return(tag);
            }
            if (tag.Phase > Phase)
            {
                throw new ArgumentException(
                          string.Format("Invalid checkpoint tag phase.  Expected less or equal to: {0} Was: {1}", Phase, tag.Phase), "tag");
            }

            if (tag.Mode_ == CheckpointTag.Mode.EventTypeIndex)
            {
                int p;
                return(CheckpointTag.FromEventTypeIndexPositions(
                           tag.Phase, tag.Position,
                           _eventTypes.ToDictionary(v => v, v => tag.Streams.TryGetValue(v, out p) ? p : -1)));
            }

            switch (tag.Mode_)
            {
            case CheckpointTag.Mode.MultiStream:
                throw new NotSupportedException(
                          "Conversion from MultiStream to EventTypeIndex position tag is not supported");

            case CheckpointTag.Mode.Stream:
                throw new NotSupportedException(
                          "Conversion from Stream to EventTypeIndex position tag is not supported");

            case CheckpointTag.Mode.PreparePosition:
                throw new NotSupportedException(
                          "Conversion from PreparePosition to EventTypeIndex position tag is not supported");

            case CheckpointTag.Mode.Position:
                return(CheckpointTag.FromEventTypeIndexPositions(
                           tag.Phase, tag.Position, _eventTypes.ToDictionary(v => v, v => - 1)));

            default:
                throw new Exception();
            }
        }
 public override CheckpointTag MakeZeroCheckpointTag()
 {
     return(CheckpointTag.FromEventTypeIndexPositions(
                Phase, new TFPos(0, -1), _eventTypes.ToDictionary(v => v, v => ExpectedVersion.NoStream)));
 }