public void given()
 {
     //given
     _cache = new PartitionStateCache(CheckpointTag.FromPosition(0, -1));
     _cachedAtCheckpointTag = CheckpointTag.FromPosition(1000, 900);
     _cache.CacheAndLockPartitionState("partition", new PartitionState("data", null, _cachedAtCheckpointTag), _cachedAtCheckpointTag);
 }
 public void when()
 {
     _cache = new PartitionStateCache();
     _cachedAtCheckpointTag = CheckpointTag.FromPosition(0, 1000, 900);
     _cache.CacheAndLockPartitionState("partition", new PartitionState("data", null, _cachedAtCheckpointTag),
                                       _cachedAtCheckpointTag);
 }
 public void when()
 {
     _cache = new PartitionStateCache(CheckpointTag.FromPosition(0, -1));
     _cachedAtCheckpointTag = CheckpointTag.FromPosition(1000, 900);
     _cache.CachePartitionState(
         "partition", new PartitionState("data", null, _cachedAtCheckpointTag));
 }
 public void given()
 {
     //given
     _cache = new PartitionStateCache();
     _cachedAtCheckpointTag = CheckpointTag.FromPosition(1000, 900);
     _cache.CacheAndLockPartitionState("partition", new PartitionStateCache.State("data", _cachedAtCheckpointTag), _cachedAtCheckpointTag);
     _relockedData = _cache.TryGetAndLockPartitionState("partition", CheckpointTag.FromPosition(2000, 1900));
 }
Beispiel #5
0
 public override IProjectionProcessingPhase[] CreateProcessingPhases(
     IPublisher publisher, Guid projectionCorrelationId, PartitionStateCache partitionStateCache,
     Action updateStatistics, CoreProjection coreProjection, ProjectionNamesBuilder namingBuilder,
     ITimeProvider timeProvider, IODispatcher ioDispatcher,
     CoreProjectionCheckpointWriter coreProjectionCheckpointWriter)
 {
     return(new IProjectionProcessingPhase[] { _phase1, _phase2 });
 }
 public void when()
 {
     try {
         _cache = new PartitionStateCache();
     } catch (Exception ex) {
         _exception = ex;
     }
 }
 public EventProcessedResult(
     string partition, CheckpointTag checkpointTag, PartitionStateCache.State oldState,
     PartitionStateCache.State newState, EmittedEvent[] emittedEvents)
 {
     _emittedEvents = emittedEvents;
     _oldState = oldState;
     _newState = newState;
     _partition = partition;
     _checkpointTag = checkpointTag;
 }
Beispiel #8
0
 public void it_can_be_created()
 {
     var coreProjection        = new FakeCoreProjection();
     var stateCache            = new PartitionStateCache();
     var bus                   = new InMemoryBus("test");
     var fakeCheckpointManager = new specification_with_multi_phase_core_projection.FakeCheckpointManager(bus, Guid.NewGuid());
     var it = new WriteQueryResultProjectionProcessingPhase(
         1, "result-stream", coreProjection, stateCache,
         fakeCheckpointManager, fakeCheckpointManager);
 }
Beispiel #9
0
 public void when()
 {
     try
     {
         _cache = new PartitionStateCache(CheckpointTag.FromPosition(0, -1));
     }
     catch (Exception ex)
     {
         _exception = ex;
     }
 }
Beispiel #10
0
            protected virtual PartitionStateCache GivenStateCache()
            {
                var stateCache = new PartitionStateCache();

                stateCache.CachePartitionState(
                    "a", new PartitionState("{}", null, CheckpointTag.FromPhase(0, completed: false)));
                stateCache.CachePartitionState(
                    "b", new PartitionState("{}", null, CheckpointTag.FromPhase(0, completed: false)));
                stateCache.CachePartitionState(
                    "c", new PartitionState("{}", null, CheckpointTag.FromPhase(0, completed: false)));
                return(stateCache);
            }
Beispiel #11
0
 public void SetUp()
 {
     _stateCache        = GivenStateCache();
     _publisher         = new InMemoryBus("test");
     _coreProjection    = new FakeCoreProjection();
     _checkpointManager = new specification_with_multi_phase_core_projection.FakeCheckpointManager(
         _publisher, Guid.NewGuid());
     _resultStreamName = "result-stream";
     _phase            = new WriteQueryResultProjectionProcessingPhase(
         1, _resultStreamName, _coreProjection, _stateCache, _checkpointManager, _checkpointManager);
     When();
 }
 public void setup()
 {
     //given
     _cache = new PartitionStateCache();
     _cachedAtCheckpointTag1 = CheckpointTag.FromPosition(1000, 900);
     _cachedAtCheckpointTag2 = CheckpointTag.FromPosition(1200, 1100);
     _cachedAtCheckpointTag3 = CheckpointTag.FromPosition(1400, 1300);
     _cache.CacheAndLockPartitionState("partition1", "data1", _cachedAtCheckpointTag1);
     _cache.CacheAndLockPartitionState("partition2", "data2", _cachedAtCheckpointTag2);
     _cache.CacheAndLockPartitionState("partition3", "data3", _cachedAtCheckpointTag3);
     // when
     _cache.Unlock(_cachedAtCheckpointTag2);
 }
 public void setup()
 {
     //given
     _cache = new PartitionStateCache();
     _cachedAtCheckpointTag1 = CheckpointTag.FromPosition(0, 1000, 900);
     _cachedAtCheckpointTag2 = CheckpointTag.FromPosition(0, 1200, 1100);
     _cachedAtCheckpointTag3 = CheckpointTag.FromPosition(0, 1400, 1300);
     _cache.CacheAndLockPartitionState(
         "partition1", new PartitionState("data1", null, _cachedAtCheckpointTag1), _cachedAtCheckpointTag1);
     _cache.CacheAndLockPartitionState(
         "partition2", new PartitionState("data2", null, _cachedAtCheckpointTag2), _cachedAtCheckpointTag2);
     _cache.CacheAndLockPartitionState(
         "partition3", new PartitionState("data3", null, _cachedAtCheckpointTag3), _cachedAtCheckpointTag3);
     // when
     _cache.Unlock(_cachedAtCheckpointTag2, forgetUnlocked: true);
 }
        public void setup()
        {
            //given
            _cache = new PartitionStateCache(10);
            _cachedAtCheckpointTag1 = CheckpointTag.FromPosition(1000, 900);
            for (var i = 0; i < 15; i++)
            {
                _cache.CacheAndLockPartitionState(
                    "partition1", "data1", CheckpointTag.FromPosition(1000 + (i * 100), 1000 + (i * 100) - 50));
            }

            _cachedAtCheckpointTag2 = CheckpointTag.FromPosition(20100, 20050);
            _cachedAtCheckpointTag3 = CheckpointTag.FromPosition(20200, 20150);
            _cache.CacheAndLockPartitionState("partition1", "data1", _cachedAtCheckpointTag1);
            _cache.CacheAndLockPartitionState("partition2", "data2", _cachedAtCheckpointTag2);
            _cache.CacheAndLockPartitionState("partition3", "data3", _cachedAtCheckpointTag3);
            // when
            _cache.Unlock(_cachedAtCheckpointTag2);
        }
Beispiel #15
0
            public void it_can_be_created()
            {
                var coreProjection        = new FakeCoreProjection();
                var stateCache            = new PartitionStateCache();
                var bus                   = new InMemoryBus("test");
                var fakeCheckpointManager =
                    new specification_with_multi_phase_core_projection <TLogFormat, TStreamId> .FakeCheckpointManager(bus, Guid.NewGuid());

                var fakeEmittedStreamsTracker =
                    new specification_with_multi_phase_core_projection <TLogFormat, TStreamId> .FakeEmittedStreamsTracker();

                TestHelper.Consume(
                    new WriteQueryResultProjectionProcessingPhase(
                        bus,
                        1,
                        "result-stream",
                        coreProjection,
                        stateCache,
                        fakeCheckpointManager,
                        fakeCheckpointManager,
                        fakeEmittedStreamsTracker));
            }
        public void setup()
        {
            //given
            _cache = new PartitionStateCache(CheckpointTag.FromPosition(0, -1), 10);
            _cachedAtCheckpointTag1 = CheckpointTag.FromPosition(1000, 900);
            for (var i = 0; i < 15; i++)
            {
                CheckpointTag at = CheckpointTag.FromPosition(1000 + (i * 100), 1000 + (i * 100) - 50);
                _cache.CacheAndLockPartitionState("partition1", new PartitionState("data1", null, at), at);
            }

            _cachedAtCheckpointTag2 = CheckpointTag.FromPosition(20100, 20050);
            _cachedAtCheckpointTag3 = CheckpointTag.FromPosition(20200, 20150);
            _cache.CacheAndLockPartitionState(
                "partition1", new PartitionState("data1", null, _cachedAtCheckpointTag1), _cachedAtCheckpointTag1);
            _cache.CacheAndLockPartitionState(
                "partition2", new PartitionState("data2", null, _cachedAtCheckpointTag2), _cachedAtCheckpointTag2);
            _cache.CacheAndLockPartitionState(
                "partition3", new PartitionState("data3", null, _cachedAtCheckpointTag3), _cachedAtCheckpointTag3);
            _cache.Unlock(_cachedAtCheckpointTag2);
            // when
            _cache.Initialize();
        }