java 时钟同步,是否有针对Java的现成时钟同步解决方案?

We have a large high-performance software system which consists of multiple interacting Java processes (not EJBs). Each process can be on the same machine or on a different machine.

Certain events are generated in one process, and are then propagated in different ways to other processes for further processing and so on.

For benchmarking purposes, we need to create a log of when each event passed through a "checkpoint", eventually combine these logs to obtain a timeline of how each event propagated through the system and with what latency (of course, process switching and IPC adds latency, which is ok).

The problem, of course, is clock synchronization. So here are my questions:

1) If all processes are on the same machine, is it guaranteed that currentTimeMilis would be accurate at the time of call? Is there some bound on the errors of ITP?

2) If some processes may be on different machines, is there an off-the-shelf solution (that is also free or open-source) for clock synchronization? I am preferably looking for a solution that may bypass the operating system (Windows or Linux) and work straight from Java. I am also ideally looking for something that can operate at microsecond accuracy. I've thought about NTP, but I'm not sure if it's available via Java rather than through the OS, and I am not sure about its complexity.

3) Is there a way to determine the margin of error in using NTP in a particular configuration (or of any solution I end up using) so that I can give a margin of error on our calculation of the latency?

Thanks!

解决方案

With distributed programming, clock synchronisation is often not enough. you might want to build a logical time framework (such as the Lamport or vector clocks or Singhal-Kshemkalyani methods ... and there are loads more to keep causality in sync across machines). Which you choose often depends on the application and required causality between events.

Clocks are sync'd to ensure concurrent events are kept in the right sequential order. There are other ways to do this than keeping the system clock synchronized ... which unless they share a common physical clock ... is quite tricky.

In terms of NTP error margin, there are solutions:

my recommendation:

Read:

Distributed Computing: Principles, Algorithms and Systems

Especially: Chapter 3, logical time

Edit

Further to Cheeso's post, I found

There maybe DCE Java bindings out there.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值