Esempio n. 1
0
 internal new Task UnregisterReminder(IGrainReminder reminder)
 {
     return base.UnregisterReminder(reminder);
 }
Esempio n. 2
0
 public Task UnregisterReminder(IGrainReminder reminder)
 {
     return RuntimeClient.Current.UnregisterReminder(reminder);
 }
Esempio n. 3
0
 public async Task StopReminder(IGrainReminder reminder)
 {
     logger.Info("Stoping reminder (using ref) {0}.", reminder);
     // we dont reset counter as we want the test methods to be able to read it even after stopping the reminder
     await UnregisterReminder(reminder);
 }
Esempio n. 4
0
 Task IActorEndpointReminderService.UnregisterReminder(IGrainReminder reminder)
 {
     return UnregisterReminder(reminder);
 }
Esempio n. 5
0
 public Task UnregisterReminder(IGrainReminder reminder)
 {
     return(this.GrainService.UnregisterReminder(reminder));
 }
Esempio n. 6
0
 public Task UnregisterReminder(IGrainReminder reminder)
 {
     return(RuntimeClient.Current.UnregisterReminder(reminder));
 }
Esempio n. 7
0
 public Task UnregisterReminder(IGrainReminder reminder)
 {
     this.EnsureReminderServiceRegistered();
     return(GrainService.UnregisterReminder(reminder));
 }
        public async Task Stop()
        {
            await UnregisterReminder(_reminder);

            _reminder = null;
        }
Esempio n. 9
0
 protected Task UnregisterReminder(IGrainReminder reminder)
 {
     return(Runtime.ReminderRegistry.UnregisterReminder(reminder));
 }
Esempio n. 10
0
        static void Main(string[] args)
        {
            //本服务开放端口
            int silePort = 11113;
            //主简仓网关端口
            int gatewayPort = 30000;
            //主简仓开放端口
            int mainSiloPort = 11111;

            ///定时器对象
            IGrainReminder grainReminder = null;
            //由于向网关添加一个服务处理需要多一些时间
            //所以在程序运行后马上获取服务可能会抛出获取不到的异常
            //详情请看5、常见问题
            var host   = StartHost(silePort, gatewayPort, mainSiloPort);
            var client = StartClient(gatewayPort);

            while (true)
            {
                string ReadLine = Console.ReadLine();
                if (ReadLine == "Exit")
                {
                    host.Result.StopAsync().Wait();
                    client.Result.Close();
                    break;
                }
                else if (ReadLine == "Goods")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        Console.WriteLine(goods.GetGoodsDescribe().Result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "GoodsList")
                {
                    try
                    {
                        IGoods.IGoods             goods     = client.Result.GetGrain <IGoods.IGoods>(0);
                        List <Entity.GoodsEntity> arrayList = goods.GetGoodsList().Result;
                        Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(arrayList));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "GoodsStartTimer")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        //grainReminder = goods.StartTimerTest().Result;
                        //goods.StartTimerTestString("Test");
                        goods.StartTimer();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "GoodsStopTimer")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        //goods.StopTimerTest(grainReminder).Wait();
                        goods.StopTimerTest("Test");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "ShoppingRecord")
                {
                    try
                    {
                        IShoppingRecord.IShoppingRecord shoppingRecord = client.Result.GetGrain <IShoppingRecord.IShoppingRecord>(0);
                        Console.WriteLine(shoppingRecord.GetShoppingRecordDescribe().Result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
            }
        }
Esempio n. 11
0
 public Task UnregisterReminder(IGrainReminder reminder)
 {
     GetRemindersFor(CallingGrainReference).TryRemove(reminder.ReminderName, out _);
     return(Task.CompletedTask);
 }
Esempio n. 12
0
        private async ValueTask <bool> RecalculateReminderAsync()
        {
            DateTime mintime = DateTime.MaxValue;
            var      lstTask = this.State;

            List <DispatchTask> lstbacktask = new List <DispatchTask>();

            for (int i = lstTask.Count - 1; i >= 0; i--)
            {
                bool bneddtimer = false;

                if (lstTask[i].Tasktype == (int)TaskType.TT_PERIODIC)
                {
                    if (lstTask[i].NewBegintime <= DateTime.Now.AddMinutes(_reminderTimerMinutes))
                    {
                        bneddtimer = true;
                    }
                    else if (lstTask[i].NewBegintime < mintime)
                    {
                        mintime = lstTask[i].NewBegintime;
                    }
                }
                else
                {
                    if (lstTask[i].Starttime <= DateTime.Now.AddMinutes(_reminderTimerMinutes))
                    {
                        bneddtimer = true;
                    }
                    else if (lstTask[i].Starttime < mintime)
                    {
                        mintime = lstTask[i].Starttime;
                    }
                }

                if (bneddtimer)
                {
                    lstbacktask.Add(lstTask[i]);
                    lock (this.State)
                    {
                        this.State.Remove(lstTask[i]);
                    }
                }
            }

            if (mintime != DateTime.MaxValue)
            {
                var      nowtime = DateTime.Now;
                TimeSpan minspan;
                if (nowtime < mintime.AddMinutes(-1 * _reminderTimerMinutes))
                {
                    minspan = mintime.AddMinutes(-1 * (_reminderTimerMinutes - 1)) - nowtime;
                    if (minspan != _reminderCurPeriod)
                    {
                        _grainReminder = await RegisterOrUpdateReminder(Cluster.TaskReminder, TimeSpan.FromSeconds(1), minspan);
                    }
                }
            }

            if (lstbacktask != null && lstbacktask.Count > 0)
            {
                var membership = await GrainFactory.GetGrain <IManagementGrain>(0).GetHosts(true);

                foreach (var item in lstbacktask)
                {
                    await GrainFactory.GetGrain <IScheduleTaskGrain>(item.Taskid % membership.Count).AddScheduleTaskAsync(item);
                }

                await WriteStateAsync();

                return(true);
            }
            return(false);
        }
Esempio n. 13
0
 public ReminderTaskGrain(IConfiguration configuration)
 {
     _reminderCurPeriod    = TimeSpan.MaxValue;
     _grainReminder        = null;
     _reminderTimerMinutes = configuration.GetSection("Task:TaskSchedulePreviousTimer").Get <int>();
 }
Esempio n. 14
0
        public async Task UnregisterReminder(IGrainReminder reminder)
        {
            await Mock.Object.UnregisterReminder(reminder);

            _reminders.Remove(reminder.ReminderName);
        }
Esempio n. 15
0
 Task IGrainReminderService.UnregisterReminder(IGrainReminder reminder)
 {
     return(UnregisterReminder(reminder));
 }
Esempio n. 16
0
 public Task UnregisterReminder(IGrainReminder reminder)
 {
     return(GetReminderService("UnregisterReminder", reminder.ReminderName)
            .UnregisterReminder(reminder));
 }
Esempio n. 17
0
 Task IActorEndpointReminderService.UnregisterReminder(IGrainReminder reminder)
 {
     return(UnregisterReminder(reminder));
 }
Esempio n. 18
0
 public async Task StopReminder(IGrainReminder reminder)
 {
     logger.Info("Stoping reminder (using ref) {0}.", reminder);
     // we dont reset counter as we want the test methods to be able to read it even after stopping the reminder
     await UnregisterReminder(reminder);
 }
Esempio n. 19
0
 public Task StopTimerTest(IGrainReminder grainReminder)
 {
     return(UnregisterReminder(grainReminder));
 }
Esempio n. 20
0
 protected virtual Task UnregisterReminder(IGrainReminder reminder)
 {
     EnsureRuntime();
     return(Runtime.ReminderRegistry.UnregisterReminder(reminder));
 }
Esempio n. 21
0
 public Task UnregisterReminder(GrainId callingGrainId, IGrainReminder reminder)
 {
     this.EnsureReminderServiceRegistered();
     return(GetGrainService(callingGrainId).UnregisterReminder(reminder));
 }
Esempio n. 22
0
 public Task UnregisterReminder(IGrainReminder reminder)
 {
     throw new InvalidOperationException("UnregisterReminder can only be called from inside a grain");
 }
Esempio n. 23
0
        private async Task RegisterReminderAsync()
        {
            var reminderTime = TimeSpan.FromMinutes(1);

            grainReminder = await RegisterOrUpdateReminder(ReminderName, reminderTime, reminderTime);
        }
Esempio n. 24
0
 protected virtual Task UnregisterReminder(IGrainReminder reminder)
 {
     return Runtime.ReminderRegistry.UnregisterReminder(reminder);
 }
Esempio n. 25
0
 public new Task UnregisterReminder(IGrainReminder reminder)
 {
     return(base.UnregisterReminder(reminder));
 }
Esempio n. 26
0
 public Task UnregisterReminder(IGrainReminder reminder)
 {
     GrainReference ignore;
     return GetReminderService("UnregisterReminder", reminder.ReminderName, out ignore)
         .UnregisterReminder(reminder);
 }
Esempio n. 27
0
 public Task UnregisterReminder(GrainId callingGrainId, IGrainReminder reminder)
 => GetGrainService(callingGrainId).UnregisterReminder(reminder);
Esempio n. 28
0
 public Task UnregisterReminder(IGrainReminder reminder)
 {
     throw new InvalidOperationException("UnregisterReminder can only be called from inside a grain");
 }
 public Task UnregisterReminder(IGrainReminder reminder)
 => UnregisterReminder(reminder.ReminderName);