g-Eclipse
Release 1.0.0

eu.geclipse.core.util
Class TimeChecker

java.lang.Object
  extended by eu.geclipse.core.util.TimeChecker

public class TimeChecker
extends java.lang.Object

A time checker using the TIME protocol (RFC 868), also known as rdate protocol.


Constructor Summary
TimeChecker()
          The constructor.
 
Method Summary
 void checkSysTime(IProgressMonitor monitor)
          Gets the time from some rdate time servers and compares it to the system time.
 long getOffset()
          Gets the system clock offset.
 java.lang.String getReferenceDate()
          Gets the reference date/time.
 java.lang.String getSystemDate()
          Gets the system date/time.
 boolean getTimeCheckStatus()
          Gets the system clock status.
 int getTolerance()
          Gets the tolerance for the system clock offset.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeChecker

public TimeChecker()
The constructor. Each instance stores the system and reference time at the time of calling checkSysTime(IProgressMonitor).

Method Detail

getTimeCheckStatus

public boolean getTimeCheckStatus()
Gets the system clock status. The method checkSysTime(IProgressMonitor) must be called first to initialize the TimeChecker instance.

Returns:
true if the system time is OK, false otherwise

checkSysTime

public void checkSysTime(IProgressMonitor monitor)
                  throws ProblemException,
                         java.lang.InterruptedException
Gets the time from some rdate time servers and compares it to the system time. In the worst case, this method can take up to TIMEOUT * SERVERS.length seconds (currently 15s) to return. DNS timeouts would add to this delay, but they should be a pathological case only. The method getTimeCheckStatus() must be called afterwards to get the result of the system time check.

Parameters:
monitor - a progress monitor used to monitor the time-check operation
Throws:
GridException - if no servers could be contacted or they yielded inconsistent results
java.lang.InterruptedException - if the operation was canceled by the user
ProblemException

getSystemDate

public java.lang.String getSystemDate()
Gets the system date/time. The method checkSysTime(IProgressMonitor) must be called first to initialize the TimeChecker instance.

Returns:
a string representation of the system date/time

getReferenceDate

public java.lang.String getReferenceDate()
Gets the reference date/time. The method checkSysTime(IProgressMonitor) must be called first to initialize the TimeChecker instance.

Returns:
a string representation of the reference date/time

getOffset

public long getOffset()
Gets the system clock offset. The method checkSysTime(IProgressMonitor) must be called first to initialize the TimeChecker instance.

Returns:
the system clock offset in seconds

getTolerance

public int getTolerance()
Gets the tolerance for the system clock offset.

Returns:
the maximum allowed system clock offset

g-Eclipse
Release 1.0.0