public void Send()
        {
            var allEndpoints = new ThreadSafeSet<Endpoint>();
            while (_continueSending)
            {
                if(!_choke.ShouldBeginSend())
                    continue;

                var endpoints = gatherEndpoints(allEndpoints.All()).ToArray();
                if (!endpoints.Any())
                {
                    _choke.NoMessagesToSend();
                    continue;
                }
                allEndpoints.Add(endpoints);

                endpoints.Each(endpoint =>
                {
                    var messages = gatherMessagesToSend(endpoint);
                    if (!messages.Any())
                    {
                        allEndpoints.Remove(endpoint);
                        return;
                    }

                    _choke.StartSend();

                    sendMessages(endpoint, messages)
                        .ContinueWith(x => allEndpoints.Remove(endpoint));
                });
            }
        }
Ejemplo n.º 2
0
        public void Send()
        {
            var allEndpoints = new ThreadSafeSet <Endpoint>();

            while (_continueSending)
            {
                if (!_choke.ShouldBeginSend())
                {
                    continue;
                }

                var endpoints = gatherEndpoints(allEndpoints.All()).ToArray();
                if (!endpoints.Any())
                {
                    _choke.NoMessagesToSend();
                    continue;
                }
                allEndpoints.Add(endpoints);

                endpoints.Each(endpoint =>
                {
                    var messages = gatherMessagesToSend(endpoint);
                    if (!messages.Any())
                    {
                        allEndpoints.Remove(endpoint);
                        return;
                    }

                    _choke.StartSend();

                    sendMessages(endpoint, messages)
                    .ContinueWith(x => allEndpoints.Remove(endpoint));
                });
            }
        }
Ejemplo n.º 3
0
 public void RemoveCells(IEnumerable <AbsoluteEntityCell> cells)
 {
     foreach (AbsoluteEntityCell cell in cells)
     {
         visibleCells.Remove(cell);
     }
 }
Ejemplo n.º 4
0
        public void EqualityComparer()
        {
            var hs = new ThreadSafeSet <string>(StringComparer.InvariantCultureIgnoreCase);

            hs.Add("Weißbier");
            Assert.IsTrue(hs.Contains("WEISSBIER"));
            Assert.IsTrue(hs.Contains("weissbier"));
            hs.Add("Δίος");
            Assert.AreEqual(2, hs.Count);
            Assert.IsTrue(hs.Contains("ΔΊΟΣ"));
            Assert.IsTrue(hs.Contains("δίος"));
            Assert.IsFalse(hs.Contains("δίοςδίος"));
            Assert.IsFalse(hs.Contains("Eggplant"));
            Assert.IsFalse(hs.Remove("aubergine"));
            Assert.IsTrue(hs.Remove("Δίος"));
            Assert.IsTrue(hs.Remove("WEISSBIER"));
            Assert.IsFalse(hs.Contains("WEISSBIER"));
            Assert.IsFalse(hs.Remove("WEISSBIER"));
            Assert.AreEqual(hs.Count, 0);
        }
Ejemplo n.º 5
0
        private void PurgeOldData(object ignored)
        {
            logger.DebugFormat("Starting to purge old data");
            try
            {
                queueStorage.Global(actions =>
                {
                    foreach (var queue in Queues)
                    {
                        var queueActions = actions.GetQueue(queue);
                        var messages     = queueActions.GetAllProcessedMessages();
                        if (NumberOfMessagesToKeepInProcessedQueues != null)
                        {
                            messages = messages.Skip(NumberOfMessagesToKeepInProcessedQueues.Value);
                        }
                        if (OldestMessageInProcessedQueues != null)
                        {
                            messages = messages.Where(x => (DateTime.Now - x.SentAt) > OldestMessageInProcessedQueues.Value);
                        }

                        foreach (var message in messages)
                        {
                            logger.DebugFormat("Purging message {0} from queue {0}/{1}", message.Id, message.Queue, message.SubQueue);
                            queueActions.DeleteHistoric(message.Bookmark);
                        }
                    }
                    var sentMessages = actions.GetSentMessages();

                    if (NumberOfMessagesToKeepOutgoingQueues != null)
                    {
                        sentMessages = sentMessages.Skip(NumberOfMessagesToKeepOutgoingQueues.Value);
                    }
                    if (OldestMessageInOutgoingQueues != null)
                    {
                        sentMessages = sentMessages.Where(x => (DateTime.Now - x.SentAt) > OldestMessageInOutgoingQueues.Value);
                    }

                    foreach (var sentMessage in sentMessages)
                    {
                        logger.DebugFormat("Purging sent message {0} to {1}/{2}/{3}", sentMessage.Id, sentMessage.Endpoint,
                                           sentMessage.Queue, sentMessage.SubQueue);
                        actions.DeleteMessageToSendHistoric(sentMessage.Bookmark);
                    }

                    receivedMsgs.Remove(actions.DeleteOldestReceivedMessages(NumberOfReceivedMessagesToKeep));

                    actions.Commit();
                });
            }
            catch (Exception exception)
            {
                logger.Warn("Failed to purge old data from the system", exception);
            }
        }
Ejemplo n.º 6
0
        public void EqualityComparer()
        {
            if (!StringComparer.InvariantCultureIgnoreCase.Equals("Weißbier", "WEISSBIER"))
            {
                Assert.Ignore("Bugs in Mono make this test irrelevant. When the bug is fixed, this test will run.");
            }
            var hs = new ThreadSafeSet <string>(StringComparer.InvariantCultureIgnoreCase);

            hs.Add("Weißbier");
            Assert.IsTrue(hs.Contains("WEISSBIER"));
            Assert.IsTrue(hs.Contains("weissbier"));
            hs.Add("Δίος");
            Assert.AreEqual(2, hs.Count);
            Assert.IsTrue(hs.Contains("ΔΊΟΣ"));
            Assert.IsTrue(hs.Contains("δίος"));
            Assert.IsFalse(hs.Contains("δίοςδίος"));
            Assert.IsFalse(hs.Contains("Eggplant"));
            Assert.IsFalse(hs.Remove("aubergine"));
            Assert.IsTrue(hs.Remove("Δίος"));
            Assert.IsTrue(hs.Remove("WEISSBIER"));
            Assert.IsFalse(hs.Contains("WEISSBIER"));
            Assert.IsFalse(hs.Remove("WEISSBIER"));
            Assert.AreEqual(hs.Count, 0);
        }
Ejemplo n.º 7
0
        private void PurgeOldestReceivedMessageIds()
        {
            int totalCount = 0;
            List <MessageId> deletedMessageIds = null;

            do
            {
                queueStorage.Global(actions =>
                {
                    deletedMessageIds = actions.DeleteOldestReceivedMessageIds(
                        Configuration.NumberOfReceivedMessageIdsToKeep, numberOfItemsToDelete: 250)
                                        .ToList();
                    actions.Commit();
                });
                receivedMsgs.Remove(deletedMessageIds);
                totalCount += deletedMessageIds.Count;
            } while (deletedMessageIds.Count > 0);

            logger.InfoFormat("Purged {0} message ids", totalCount);
        }
Ejemplo n.º 8
0
        public void BackAgainDiff()
        {
            var hs = new ThreadSafeSet <string>();

            for (int i = 0; i < SourceDataLen; i += 2)
            {
                hs.Add(SourceData[i]);
            }
            int count = SourceDataLen / 2;

            while (count != 0)
            {
                --count;
                hs.Remove(SourceData[count * 2]);
            }
            for (int i = 1; i < SourceDataLen; i += 2)
            {
                hs.Add(SourceData[i]);
            }
            Assert.AreEqual(SourceDataLen / 2, hs.Count);
        }
Ejemplo n.º 9
0
        public void PurgeOldData()
        {
            var receivedIdsPurged = _queueStorage.PurgeHistory();

            _receivedMsgs.Remove(receivedIdsPurged);
        }
Ejemplo n.º 10
0
 /// <summary>Removes an item from the store.</summary>
 /// <param name="item">The item to remove.</param>
 /// <returns>True if an item was removed, false if no equivalent item was found.</returns>
 public bool Remove(T item)
 {
     return(_store.Remove(item));
 }