Example #1
0
        /// <summary>
        /// Attempt to retrieve reminders from the global reminder table
        /// </summary>
        private async Task ReadAndUpdateReminders()
        {
            // try to retrieve reminder from all my subranges
            myRange = ring.GetMyRange();
            if (logger.IsVerbose2)
            {
                logger.Verbose2("My range= {0}", myRange);
            }
            var acks = new List <Task>();

            foreach (SingleRange range in RangeFactory.GetSubRanges(myRange))
            {
                if (logger.IsVerbose2)
                {
                    logger.Verbose2("Reading rows for range {0}", range);
                }
                acks.Add(ReadTableAndStartTimers(range));
            }
            await Task.WhenAll(acks);

            if (logger.IsVerbose3)
            {
                PrintReminders();
            }
        }
Example #2
0
        /// <summary>
        /// Attempt to retrieve reminders from the global reminder table
        /// </summary>
        private async Task ReadAndUpdateReminders()
        {
            if (StoppedCancellationTokenSource.IsCancellationRequested)
            {
                return;
            }

            RemoveOutOfRangeReminders();

            // try to retrieve reminders from all my subranges
            var rangeSerialNumberCopy = RangeSerialNumber;

            if (Logger.IsVerbose2)
            {
                Logger.Verbose2($"My range= {RingRange}, RangeSerialNumber {RangeSerialNumber}. Local reminders count {localReminders.Count}");
            }
            var acks = new List <Task>();

            foreach (SingleRange range in RangeFactory.GetSubRanges(RingRange))
            {
                acks.Add(ReadTableAndStartTimers(range, rangeSerialNumberCopy));
            }
            await Task.WhenAll(acks);

            if (Logger.IsVerbose3)
            {
                PrintReminders();
            }
        }
Example #3
0
        public bool Remove(IRingRange range)
        {
            bool wholerange = true;

            foreach (SingleRange s in RangeFactory.GetSubRanges(range))
            {
                bool found = false;
                foreach (SingleRange m in ranges)
                {
                    if (m.Begin == m.End) // treat full range as special case
                    {
                        found = true;
                        ranges.Remove(m);
                        if (s.Begin != s.End) // if s is full range as well, then end of story ... whole range is covered
                        {
                            ranges.Add(new SingleRange(s.End, s.Begin));
                        }
                        break;
                    }

                    if (m.InRange(s.Begin + 1) && m.InRange(s.End)) // s cant overlap two singleranges
                    {
                        found = true;
                        ranges.Remove(m);
                        if (s.Begin != m.Begin)
                        {
                            ranges.Add(new SingleRange(m.Begin, s.Begin));
                        }
                        if (s.End != m.End)
                        {
                            ranges.Add(new SingleRange(s.End, m.End));
                        }
                        break;
                    }
                }
                wholerange = wholerange && found;
            }
            return(wholerange);
        }