예제 #1
0
        public void insert_30_peers_with_8000_subscriptions_each()
        {
            Diagnostics.CassandraTraceSwitch.Level = TraceLevel.Off;
            const int numberOfPeersToInsert = 30;
            var       repo = new CqlPeerRepository(DataContext);
            var       subscriptionForTypes = Get10MessageTypesWith800BindingKeysEach();

            for (var i = 0; i < numberOfPeersToInsert; i++)
            {
                var stopwatch = Stopwatch.StartNew();
                repo.AddOrUpdatePeer(new PeerDescriptor(new PeerId("Abc.Peer." + i), "tcp://toto:123", true, true, true, DateTime.UtcNow));
                repo.AddDynamicSubscriptionsForTypes(new PeerId("Abc.Peer." + i), DateTime.UtcNow, subscriptionForTypes);
                Console.WriteLine("Batch: " + i + " Elapsed: " + stopwatch.Elapsed);
            }

            var sw    = Stopwatch.StartNew();
            var peers = repo.GetPeers().ToList();

            Console.WriteLine("GetPeers() took " + sw.Elapsed);
            peers.Count.ShouldEqual(30);
            foreach (var peer in peers)
            {
                peer.Subscriptions.Length.ShouldEqual(8000);
            }
        }
예제 #2
0
        public void insert_1_peer_with_100_000_subscriptions()
        {
            Diagnostics.CassandraTraceSwitch.Level = TraceLevel.Info;
            var repo = new CqlPeerRepository(DataContext);
            var subscriptionForTypes = Get1MessageTypesWith100000BindingKeys();


            var stopwatch = Stopwatch.StartNew();

            repo.AddOrUpdatePeer(new PeerDescriptor(new PeerId("Abc.Peer.0"), "tcp://toto:123", true, true, true, DateTime.UtcNow));
            repo.AddDynamicSubscriptionsForTypes(new PeerId("Abc.Peer.0"), DateTime.UtcNow, subscriptionForTypes);
            Console.WriteLine("Elapsed: " + stopwatch.Elapsed);

            Measure.Execution(100, () => repo.GetPeers(loadDynamicSubscriptions: false).ToList());
            var peers = repo.GetPeers(loadDynamicSubscriptions: false).ToList();

            peers.ExpectedSingle().Subscriptions.Length.ShouldEqual(0);
        }
예제 #3
0
        public void should_get_all_peers()
        {
            var peerDescriptor1 = _peer1.ToPeerDescriptorWithRoundedTime(true, typeof(string));

            peerDescriptor1.HasDebuggerAttached = true;
            _repository.AddOrUpdatePeer(peerDescriptor1);

            var peerDescriptor2 = _peer2.ToPeerDescriptorWithRoundedTime(true, typeof(int));

            _repository.AddOrUpdatePeer(peerDescriptor2);

            var fetchedPeers = _repository.GetPeers().ToList();

            var fetchedPeer1 = fetchedPeers.Single(x => x.Peer.Id == peerDescriptor1.Peer.Id);

            fetchedPeer1.ShouldHaveSamePropertiesAs(peerDescriptor1);
            var fetchedPeer2 = fetchedPeers.Single(x => x.Peer.Id == peerDescriptor2.Peer.Id);

            fetchedPeer2.ShouldHaveSamePropertiesAs(peerDescriptor2);
        }