Ejemplo n.º 1
0
        private async Task DoResponsibilitySanityCheck(GrainReference grainRef, string debugInfo)
        {
            switch (Status)
            {
            case GrainServiceStatus.Booting:
                // if service didn't finish the initial load, it could still be loading normally or it might have already
                // failed a few attempts and callers should not be hold waiting for it to complete
                var task = this.startedTask.Task;
                if (task.IsCompleted)
                {
                    // task at this point is already Faulted
                    await task;
                }
                else
                {
                    try
                    {
                        // wait for the initial load task to complete (with a timeout)
                        await task.WithTimeout(InitialReadMaxWaitTimeForUpdates);
                    }
                    catch (TimeoutException ex)
                    {
                        throw new OrleansException("Reminder Service is still initializing and it is taking a long time. Please retry again later.", ex);
                    }
                }
                break;

            case GrainServiceStatus.Started:
                break;

            case GrainServiceStatus.Stopped:
                throw new OperationCanceledException("ReminderService has been stopped.");

            default:
                throw new InvalidOperationException("status");
            }

            if (!RingRange.InRange(grainRef))
            {
                Logger.Warn(ErrorCode.RS_NotResponsible, "I shouldn't have received request '{0}' for {1}. It is not in my responsibility range: {2}",
                            debugInfo, grainRef.ToDetailedString(), RingRange);
                // For now, we still let the caller proceed without throwing an exception... the periodical mechanism will take care of reminders being registered at the wrong silo
                // otherwise, we can either reject the request, or re-route the request
            }
        }
Ejemplo n.º 2
0
        private void RemoveOutOfRangeReminders()
        {
            var remindersOutOfRange = localReminders.Where(r => !RingRange.InRange(r.Key.GrainRef)).Select(r => r.Value).ToArray();

            foreach (var reminder in remindersOutOfRange)
            {
                if (Logger.IsVerbose2)
                {
                    Logger.Verbose2("Not in my range anymore, so removing. {0}", reminder);
                }
                // remove locally
                reminder.StopReminder(Logger);
                localReminders.Remove(reminder.Identity);
            }

            if (Logger.IsInfo && remindersOutOfRange.Length > 0)
            {
                Logger.Info($"Removed {remindersOutOfRange.Length} local reminders that are now out of my range.");
            }
        }