private synchronized void checkTimeUpdate(long localTime, long utcTime) throws Exception {
    // broadcast
    _props.setProperty("utc", String.valueOf(utcTime));
    _props.setProperty("local", String.valueOf(localTime));

    TimeUpdateNotification notification =
        new TimeUpdateNotification(TimeUpdateNotification.UPDATE_UTC_TIME, _props);

    Notifier.getInstance().broadcast(notification);

    // wait
    try {
      wait(30000L); // 30 seconds
    } catch (Exception ex) {
    }

    // refreshTimeServer();
    // checkSuccess(_event, _sessions[0], _sm[0], IErrorCode.NO_ERROR);

    long offset = utcTime - localTime;
    Logger.debug("Input UTC Time = " + new Timestamp(utcTime));
    Logger.debug("Input Local Time = " + new Timestamp(localTime));
    Logger.debug("Expected offset: " + offset);

    // check local to utc
    Timestamp ts = TimeUtil.localToUtcTimestamp(_testDate);
    Logger.debug("Converted local to UTc timestamp: " + ts);
    assertEquals("LocalToUtc conversion fail", offset, ts.getTime() - _testDate.getTime());

    // check utc to local
    ts = TimeUtil.utcToLocalTimestamp(_testDate);
    Logger.debug("Converted utc to local timestamp: " + ts);
    assertEquals("UtcToLocal conversion fail", offset, _testDate.getTime() - ts.getTime());
  }
예제 #2
0
 /**
  * This method is initialize the meta info during sending. It calculates the total block size and
  * the last block size and initialize the block filenames and the block received status. It also
  * stores the UTC time that the meta info is created.
  */
 private synchronized void createMetaInfo() throws FileAccessException {
   initBlockReceived(_totalBlocks);
   _lastBlock = _totalBlocks;
   _timeCreated = TimeUtil.localToUtcTimestamp().toString();
 }