Synchronizing clock times between two seperate machines?

Discussion in 'Java' started by Ken Adams, Feb 20, 2005.

  1. Ken Adams

    Ken Adams Guest

    How does one go about synchronizing clock times of two distributed computers
    in java. Basically I would imagine there would be potential for clock drift
    so this synchronization would have to be done at continuous intervals. Any
    suggestions.

    Thanks

    Ken
     
    Ken Adams, Feb 20, 2005
    #1
    1. Advertising

  2. Ken Adams

    Tom Dyess Guest

    "Ken Adams" <> wrote in message
    news:zu8Sd.26060$AO.21661@clgrps12...
    > How does one go about synchronizing clock times of two distributed
    > computers in java. Basically I would imagine there would be potential for
    > clock drift so this synchronization would have to be done at continuous
    > intervals. Any suggestions.
    >
    > Thanks
    >
    > Ken
    >


    If you want to do it at the network level, research NTPD (Network Time
    Protocol Daemon). This will probaby be the simplest way to synchronize..

    If you want to do this at the application level, you can do a few things.

    If you have some sort of centalized location (single ejb server, single
    database server, database cluster) you can pull the time from that single
    location in a predetermined interval (every hour or day or week). You can
    also pull it whenever you need it (when comparing, etc).

    If you are peer to peer, and you want the applicatoin level, it can get
    pretty tough, unless java has a library I'm not aware of (which is quite
    possible). It would involve designating a "master" timekeeper peer and have
    the other peers contact it at intervals, or have it broadcast to all it's
    connected peers. Probably don't want to do it this way. If this sounds like
    a customer NTPD, well, it is. Lol.

    --
    Tom Dyess
    OraclePower.com
     
    Tom Dyess, Feb 21, 2005
    #2
    1. Advertising

  3. Ken Adams

    Dotty Guest

    "Ken Adams" <> wrote in message
    news:zu8Sd.26060$AO.21661@clgrps12...
    > How does one go about synchronizing clock times of two distributed

    computers
    > in java. Basically I would imagine there would be potential for clock

    drift
    > so this synchronization would have to be done at continuous intervals. Any
    > suggestions.
    >
    > Thanks
    >
    > Ken


    The 'clock time' of the two distributed computers is not
    part of java, it is part of the operating system. You should
    be using "NTP: The Network Time Protocol" http://www.ntp.org/
    A tremendous amount of work has gone into the development of this product
    at the univ. Delaware and it works very well, much better than
    you could hope to achieve with a java program.
    Windows XP uses this to set the system time, but it only updates
    it once per week. Maybe you could look into having it update more
    frequently. Sun operating systems use it too as of about 3 years ago.
    It is also a standard that telecoms use.
     
    Dotty, Feb 21, 2005
    #3
  4. On 21-02-2005 08:14, Dotty wrote:
    > "Ken Adams" <> wrote in message
    > news:zu8Sd.26060$AO.21661@clgrps12...
    >
    >>How does one go about synchronizing clock times of two distributed

    >
    > computers
    >
    >>in java. Basically I would imagine there would be potential for clock

    >
    > drift
    >
    >>so this synchronization would have to be done at continuous intervals. Any
    >>suggestions.
    >>
    >>Thanks
    >>
    >>Ken

    >
    >
    > The 'clock time' of the two distributed computers is not
    > part of java, it is part of the operating system. You should
    > be using "NTP: The Network Time Protocol" http://www.ntp.org/
    > A tremendous amount of work has gone into the development of this product
    > at the univ. Delaware and it works very well, much better than
    > you could hope to achieve with a java program.
    > Windows XP uses this to set the system time, but it only updates
    > it once per week. Maybe you could look into having it update more
    > frequently. Sun operating systems use it too as of about 3 years ago.
    > It is also a standard that telecoms use.
    >
    >

    I agree, don't invent the wheel again. Use NTP on all computers in your
    network. In the date/time control panel (Internet tab), select a NTP
    service near to your own location. This makes it even more accurate than
    it already is. To update the system time in XP more frequently, you need
    to change a registry key as follows:
    * goto HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
    W32Time\TimeProviders\NtpClient
    * Select key "SpecialPollInterval"
    * The value shown is the value in seconds:
    o Default value: 604800 (one week)
    o Update every day = 86400 (seconds)
    o Update every hour = 3600 (seconds)

    Paul.
     
    Paul van Rossem, Feb 21, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john
    Replies:
    3
    Views:
    693
    backhus
    Jun 12, 2006
  2. Replies:
    1
    Views:
    360
    Juan T. Llibre
    Jul 20, 2006
  3. Replies:
    2
    Views:
    2,702
    homoalteraiensis
    Aug 5, 2006
  4. john
    Replies:
    11
    Views:
    1,375
  5. moondaddy
    Replies:
    2
    Views:
    590
    Steven Cheng[MSFT]
    Oct 16, 2006
Loading...

Share This Page