Class AutomaticUpdater

java.lang.Object
org.eblocker.server.common.update.AutomaticUpdater

public class AutomaticUpdater extends Object
This class is used to automatically run the system updates every day in a given time frame at a random time, so that the chance that all eBlocker devices try to request the server for updates at the same time is low. Therefore should the server load stay small, because it does not have to handle lots of parallel update requests.
  • Constructor Details

  • Method Details

    • init

      public void init()
    • start

      public void start()
      Start the update process; change this logic to control when updates are performed
    • setNewConfiguration

      public void setNewConfiguration(AutomaticUpdaterConfiguration config)
      Update the time frame for automatic updates
    • calculateNextUpdate

      public static java.time.LocalDateTime calculateNextUpdate(java.time.LocalDateTime now, java.time.LocalTime notBefore, java.time.LocalTime notAfter, double random0to1)
      Calculate date and time for the next update. If now is before the time window, the next update will be within the time window. If now is within or after the time window, the next update will be within the time window on the next day.
      Parameters:
      now - the current date and time
      notBefore - start time of the window
      notAfter - end time of the window
      random0to1 - a random number between 0.0 and 1.0
      Returns:
      date and time of the next update
    • getNextUpdate

      public java.time.LocalDateTime getNextUpdate()
    • setActivated

      public void setActivated(boolean activated)
    • isActivated

      public boolean isActivated()
    • getConfiguration

      public AutomaticUpdaterConfiguration getConfiguration()