Class AutomaticUpdater
java.lang.Object
org.eblocker.server.common.update.AutomaticUpdater
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 Summary
ConstructorsConstructorDescriptionAutomaticUpdater(ScheduledExecutorService executorService, SystemUpdater updater, DataSource datasource, com.fasterxml.jackson.databind.ObjectMapper objectMapper, String configJSON, java.time.Clock clock, Random random, RegistrationService registrationService, ProductInfoService productInfoService) -
Method Summary
Modifier and TypeMethodDescriptionstatic java.time.LocalDateTimecalculateNextUpdate(java.time.LocalDateTime now, java.time.LocalTime notBefore, java.time.LocalTime notAfter, double random0to1) Calculate date and time for the next update.java.time.LocalDateTimevoidinit()booleanvoidsetActivated(boolean activated) voidUpdate the time frame for automatic updatesvoidstart()Start the update process; change this logic to control when updates are performed
-
Constructor Details
-
AutomaticUpdater
@Inject public AutomaticUpdater(ScheduledExecutorService executorService, SystemUpdater updater, DataSource datasource, com.fasterxml.jackson.databind.ObjectMapper objectMapper, String configJSON, java.time.Clock clock, Random random, RegistrationService registrationService, ProductInfoService productInfoService)
-
-
Method Details
-
init
public void init() -
start
public void start()Start the update process; change this logic to control when updates are performed -
setNewConfiguration
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 timenotBefore- start time of the windownotAfter- end time of the windowrandom0to1- 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
-