一个调度问题

发布于 2024-09-14 07:45:49 字数 493 浏览 4 评论 0原文

我有以下情况:我有几百个资源可供使用(PC/手机/智能设备)。我想用这些设备建立一个网络实验室,用户可以在特定时间请求访问部分或全部这些设备。我正在为此目的编写一个调度程序。在请求的时间,我希望通知用户请求已被批准,然后自动对设备进行一些测试。我只是想知道编写调度程序的有效方法是什么。到目前为止,我想到了以下内容:

  1. 每当有请求传入时,我都会将其放入 SQL 数据库表中。我编写了一个程序来不断检查该表中是否有到期的作业并运行它们。这是周期性的(比如每 5 分钟一次),所以我无法安排立即测试。

  2. 为每个作业保留一个作业对象,并附加一个在指定时间触发的计时器(似乎可扩展性最差)。

  3. (1) 和 (2) 的混合体。我通过以较大的时间间隔(例如 30 分钟)查询数据库来创建带有计时器的作业对象。在查询中,我获取在接下来 30 分钟左右到期的所有作业。

有没有更好/更干净的方法来做到这一点?

非常感谢您的提前回复!

I have the following situation: I have a few hundred resources at my disposal (PCs/mobiles/smart devices). I would like to make a networked lab out of these where users can request access to some or all of these devices starting at a particular time. I'm writing a scheduler for this purpose. At the requested time, I wish to inform the user that the request has been granted, and then do some tests on the devices automatically. I'm just wondering what would be an efficient way to write the scheduler. As of now, I thought of the following:

  1. Whenever a request comes in, I put it in an SQL database table. I write a program to keep checking this table for jobs that are due and run them. This would be periodic (say every 5 minutes), so I cannot schedule immediate tests.

  2. Keep a job object for each job, and attach a timer that fires at the specified time (seems to be the least scalable).

  3. A hybrid of (1) and (2). I create job objects with timers by querying the database at a larger interval (say 30 minutes). In the query, I fetch all jobs that are due in the next 30 minutes or so.

Is there a better/cleaner way to do this?

Thanks a lot for the responses in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夕色琉璃 2024-09-21 07:45:49

你有没有尝试过 Quartz.net...我已经使用 Quartz java 风格相当长一段时间了,它对我的​​作用给我留下了深刻的印象。

Have you tried Quartz.net...i have used Quartz java flavour for quite some time and am impressed with what it does for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文