清理Azure Service Fabric中的休眠角色 [英] Cleaning up dormant actors in Azure Service Fabric

查看:53
本文介绍了清理Azure Service Fabric中的休眠角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下模型评估IoT风格应用程序的Service Fabric:每个设备都有其自己的角色,以及系统中的其他角色.我知道不活动的参与者会自动被垃圾收集,但是当它们重新激活时,它们的状态将保持不变.我还看到有一种方法可以显式删除actor及其状态.

I'm evaluating Service Fabric for an IoT-style application using the model that each device has its own actor, along with other actors in the system. I understand that inactive actors will be garbage-collected automatically but their state will persist for when they are reactivated. I also see there is a way to explicitly delete an actor and its state.

在我的场景中,我想知道是否有任何模式或建议来处理处于休眠,故障或消失"且从不发送其他消息的设备.如果没有显式删除,则它们的状态将永远存在,我想自动清除它,例如:六个月后.

In my scenario I'm wondering if there are any patterns or recommendations on how to handle devices that go dormant, fail or "disappear" and never send another message. Without an explicit delete their state will persist forever and I would like to clean it up automatically, e.g.: after six months.

推荐答案

Actor具有一个OnPostActorMethodAsync方法,该方法在调用每个actor方法后都会被调用(除非该方法引发异常,但我认为这是一个错误).您可以使用这种方法安排杀死我"提醒,以在X个时间段后触发.每次调用actor方法时,时间都会被推迟.当杀死我"提醒最终触发时,只需删除所有参与者的状态,然后取消注册任何提醒.最终,SF会将其踢出内存,在那一点上,我认为该actor本质上已被删除(不在内存中,没有持久状态.)

Actors have a method OnPostActorMethodAsync which is called after every actor method is invoked (unless the method throws an exception, but I believe that's a bug). You could schedule a "kill me" reminder in that method to fire after X period of time. Every time an actor method is called that time will get pushed back. When the "kill me" reminder finally does fire, simply delete all the actor's state, and unregister any reminders. Eventually SF will kick it out of memory, and at that point, I believe the actor has essentially been deleted(not in memory, no persisted state.)

这篇关于清理Azure Service Fabric中的休眠角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆