是否可以在不使用 DateTime 类的情况下测量可以跨越多次计算机重新启动的时间跨度?

发布于 2024-08-05 22:04:00 字数 598 浏览 1 评论 0原文

我有一个有点奇怪的问题。

我希望能够独立于系统日期时间来测量时间跨度。

我们基本上有一个由一台中央服务器和多个本地服务器组成的系统,这些服务器不断与中央服务器同步。

中央服务器上的对象仅在指定的时间段内有效,例如2009年10月1日09:00 -> 10:00。 2009 年 10 月 1 日 17:00。

对象可能会在其有效时间段之前几个月下载到本地服务器。

当一个对象被下载到本地服务器时,它有一个属性,该属性定义了它变得有效之前的时间长度。

目前,我只是计算从该时间跨度开始它将在本地服务器上生效的日期时间,然后在此时在本地激活该对象。

然而,整个设计存在缺陷,因为有人可以将本地服务器上的时钟提前以过早激活他们下载的对象。

是否没有固定的参考点可以在本地服务器上使用来测量时间跨度,这是无法更改的???类似于“ticksSinceProcessorInstallation”属性或类似的东西???

我知道我可以想出一些解决方案来轮询中央服务器以不断获取那里的时间,但理想情况下,本地服务器应该能够在最初从中央服务器下载对象后始终保持离线状态。

如果有人有任何有用的建议,我将非常感激,

谢谢

I have a bit of a strange problem.

I'd like to be able to measure a timespan independently of the system datetime.

We basically have a system with one central server and multiple local servers which are constantly synchronising with the central server.

Objects on the central server are only valid for a specified time period, e.g. 01 October 2009 09:00 -> 01 October 2009 17:00.

An object might be downloaded to a local server months in advance of the time period in which it is valid.

When an object is downloaded to the local server it has a property on it which defines the length of time before it becomes valid.

Currently I just calculate the datetime that it will become valid on the local server from this timespan and then activate the object locally at this time.

This whole design though is flawed by the fact that someone could just put their clock forward on their local server to prematurely activate their downloaded object.

Is there no fixed point of reference that I could use on local servers to measure timespans, something that couldn't be changed??? Something like a "ticksSinceProcessorInstallation" property or something similar???

I know that I could come up with some solution that polls the central server to constantly get the time on there, but ideally the local server should be able to remain offline the whole time after initially downloading the object from the central server.

If anyone has any helpful suggestions then I'd be very appreciative,

Thanks

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

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

发布评论

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

评论(1

陈独秀 2024-08-12 22:04:00

将其集中化。如果您无法将其集中到您自己的一台服务器上,请查询公共时间服务器;您的服务器管理员无法更改这些时间。

这里的基本原则是您无法控制用户定义的设置(时钟),因此如果它如此关键,那么它就不是一个可靠的测量点。任何测量“自那时以来的持续时间”的内容都需要对当前日期/时间进行一些参考,因此如果您必须考虑本地时间无效,您将不得不询问另一台服务器以获得“真正的交易” 。

Centralize it. If you can't centralize it with one of your own servers, query a public time server; your server admins can't change the times on those.

The fundamental principle here is that you can't control a user defined setting (the clock), so if it's this critical, it's not a reliable point of measure. Anything that measures a "duration-since-then" would need some reference to the current date/time, so you're going to have to go ask another server to get the "real deal" if you have to consider the local time invalid.

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