Java Clock Synchronization in a Distributed System
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian and Fedora Core in equal measure
Posts: 264
Rep:
Java Clock Synchronisation
First thing to do is to run NTP, Network Time Protocol, on each system in the network, and point the NTP daemon towards a network time source. This will ensure that all systems in your network have the same clock time. From this, if Java uses the system clock on the host upon which it runs, all Java processes will run to the same clock.
Thanks for your reply. Because I am not good in networking could you please explain me this a little more. In particular, can you please tell me how it is possible as you said to make each system to point to the NTP daemon towards a network time source using a Java program.
It's not a Java issue, it's not a network issue - it's a simple system configuration issue. Just go into your system management GUI (for example, Yast2 on Suse Linux) and configure "network time" (aka "NTP client").
Distribution: Debian and Fedora Core in equal measure
Posts: 264
Rep:
Beat me to it!
Thanks to PaulSM4, for a very complete answer...sorry I didn't get back before, but it snowed, and here in the UK, when it snows, our transport systems fail, so I didn't get near a PC for a couple of days
ntp is the "network time protocol." Various companies and government agencies run atomic clocks, and they publish a time-synchronization service.
For instance, my computers synchronize with time.nist.gov (or a couple of backup servers).
Now... let's say that you had several hundred servers to deal with. You might not want every one of them to be pinging time.nist.gov to get their time-of-day. (That would be a lot of traffic, and it would presuppose the existence of an open channel to the Internet.) What you'd probably prefer to do, instead, is to have one or two computers on your internal network which synchronize themselves with one of these known-good external sources; and then act as a time-synchronization service for the rest of the internal network.
In fact, this is very common. In a Windows network, say, the "domain controller" computer(s) act as an authoritative time-source for the internal sub-network that they control.
All computers provide this time-synchronization capability and they do it the same way.
A user-level program (in Java or what-have-you) not only doesn't maintain the system time-clock; it isn't allowed to do so.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.