コード例 #1
0
        public void Add(ulong id, IList <LocalEventKeyInfo> localKeyInfo)
        {
            if (id < _maxKey)
            {
                _store = new ScaleoutStore(MaxMessages);
            }

            _store.Add(new ScaleoutMapping(id, localKeyInfo));

            _maxKey = id;
        }
コード例 #2
0
        public void BinarySearchNoOverwritemSmallerFail()
        {
            var store = new ScaleoutStore(10);

            for (int i = 1; i <= 5; i++)
            {
                store.Add(new ScaleoutMapping((ulong)i, new ScaleoutMessage()));
            }

            ScaleoutStore.Fragment fragment;
            bool result = store.TryGetFragmentFromMappingId(0, out fragment);

            Assert.False(result);
        }
コード例 #3
0
        public void BinarySearchNoOverwriteSuccess()
        {
            var store = new ScaleoutStore(10);

            for (int i = 0; i < 5; i++)
            {
                store.Add(new ScaleoutMapping((ulong)i, new List<LocalEventKeyInfo>()));
            }

            ScaleoutStore.Fragment fragment;
            bool result = store.TryGetFragmentFromMappingId(0, out fragment);

            Assert.True(result);
        }
コード例 #4
0
        public void BinarySearchOverwriteSmallerFail()
        {
            var store = new ScaleoutStore(10);

            int id = 0;
            for (int i = 0; i < store.FragmentSize + 1; i++)
            {
                for (int j = 0; j < store.FragmentCount; j++)
                {
                    store.Add(new ScaleoutMapping((ulong)id, new ScaleoutMessage()));
                    id++;
                }
            }

            ScaleoutStore.Fragment fragment;
            bool result = store.TryGetFragmentFromMappingId(0, out fragment);

            Assert.False(result);
        }
コード例 #5
0
        public void GettingMessagesWithCursorInbetweenOnElementRangeGetsAll()
        {
            var store = new ScaleoutStore(10);

            var message = new ScaleoutMessage();
            store.Add(new ScaleoutMapping((ulong)1, message));

            var result = store.GetMessagesByMappingId(2);
            Assert.Equal(0ul, result.FirstMessageId);
            Assert.Equal(0, result.Messages.Count);
        }
コード例 #6
0
        public void GettingMessagesWithCursorInbetweenFragmentsGetsEverythingAfterwards()
        {
            var store = new ScaleoutStore(10, 5);

            var frag1Values = new[] { 1, 2, 3, 4, 5 };
            // Purposely missing '6' between the fragments
            var frag2Values = new[] { 7, 8, 9, 10, 11 };

            foreach (var v in frag1Values.Concat(frag2Values))
            {
                store.Add(new ScaleoutMapping((ulong)v, new ScaleoutMessage()));
            }

            var result = store.GetMessagesByMappingId(6);
            
            Assert.Equal(7ul, result.FirstMessageId);
            Assert.Equal(5, result.Messages.Count);
        }
コード例 #7
0
        public void AssertMessagesWithCursorForRange(int[] values, ulong targetId, ulong firstId, int count)
        {
            var store = new ScaleoutStore(10);

            var message = new ScaleoutMessage();
            foreach (var v in values)
            {
                store.Add(new ScaleoutMapping((ulong)v, message));
            }

            var result = store.GetMessagesByMappingId(targetId);
            Assert.Equal(firstId, result.FirstMessageId);
            Assert.Equal(count, result.Messages.Count);
        }
コード例 #8
0
        public void GettingMessagesWithSentinelCursorReturnsEverything()
        {
            var store = new ScaleoutStore(10);

            var message = new ScaleoutMessage();
            store.Add(new ScaleoutMapping((ulong)0, message));

            var result = store.GetMessagesByMappingId(UInt64.MaxValue);
            Assert.Equal(0ul, result.FirstMessageId);
            Assert.Equal(1, result.Messages.Count);
        }
コード例 #9
0
        public void GettingMessagesWithCursorBiggerThanMaxReturnsNothingIfNewer()
        {
            var store = new ScaleoutStore(10);

            for (int i = 0; i < 5; i++)
            {
                var message = new ScaleoutMessage();
                store.Add(new ScaleoutMapping((ulong)i, message));
            }

            var result = store.GetMessagesByMappingId(6);
            Assert.Equal(0, result.Messages.Count);
        }
コード例 #10
0
        public void MinMappingIdMovesWhenOverflow()
        {
            var store = new ScaleoutStore(5);

            int id = 0;
            for (int i = 0; i < store.FragmentSize + 1; i++)
            {
                for (int j = 0; j < store.FragmentCount; j++)
                {
                    var message = new ScaleoutMessage();
                    store.Add(new ScaleoutMapping((ulong)id, message));
                    id++;
                }
            }

            Assert.Equal((ulong)store.FragmentSize - 1, store.MinMappingId);
        }
コード例 #11
0
        public void AccurateMappingIds()
        {
            var store = new ScaleoutStore(10);
            var message1 = new ScaleoutMessage();
            store.Add(new ScaleoutMapping(10ul, message1));
            var message2 = new ScaleoutMessage();
            store.Add(new ScaleoutMapping(15ul, message2));

            Assert.Equal(10ul, store.MinMappingId);
            Assert.Equal(15ul, store.MaxMapping.Id);
        }
コード例 #12
0
        public void SingleMessageOnlyVerifyIds()
        {
            var store = new ScaleoutStore(10);
            var message = new ScaleoutMessage();
            store.Add(new ScaleoutMapping(10ul, message));

            Assert.Equal(10ul, store.MinMappingId);
            Assert.Equal(10ul, store.MaxMapping.Id);
        }
コード例 #13
0
        public void BinarySearchOverwriteSuccess()
        {
            var store = new ScaleoutStore(10);

            int id = 0;
            for (int i = 0; i < store.FragmentSize + 1; i++)
            {
                for (int j = 0; j < store.FragmentCount; j++)
                {
                    store.Add(new ScaleoutMapping((ulong)id, new List<LocalEventKeyInfo>()));
                    id++;
                }
            }

            ScaleoutStore.Fragment fragment;
            bool result = store.TryGetFragmentFromMappingId(10, out fragment);

            Assert.True(result);
        }
 public ScaleoutMappingStore()
 {
     _store = new ScaleoutStore(MaxMessages);
 }
コード例 #15
0
        public void GettingMessagesWithCursorLowerThanMinReturnsAll()
        {
            var store = new ScaleoutStore(10);

            for (int i = 5; i < 10; i++)
            {
                var message = new ScaleoutMessage();
                store.Add(new ScaleoutMapping((ulong)i, message));
            }

            var result = store.GetMessagesByMappingId(4);
            Assert.Equal(0ul, result.FirstMessageId);
            Assert.Equal(5ul, store.MinMappingId);
            Assert.Equal(5, result.Messages.Count);
        }
 public ScaleoutStoreEnumerator(ScaleoutStore store, MessageStoreResult <ScaleoutMapping> result)
     : this()
 {
     _storeReference = new WeakReference(store);
     Initialize(result);
 }
コード例 #17
0
 public ScaleoutMappingStore(int maxMessages)
 {
     _maxMessages = (uint)maxMessages;
     _store       = new ScaleoutStore(_maxMessages);
 }