Class DiagnosisKeyBundler
- java.lang.Object
-
- app.coronawarn.server.services.distribution.assembly.diagnosiskeys.DiagnosisKeyBundler
-
- Direct Known Subclasses:
DemoDiagnosisKeyBundler,ProdDiagnosisKeyBundler
public abstract class DiagnosisKeyBundler extends Object
An instance of this class contains a collection ofDiagnosisKeys.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<LocalDateTime,List<DiagnosisKey>>distributableDiagnosisKeysprotected LocalDateTimedistributionTimeprotected longexpiryPolicyMinutesprotected intminNumberOfKeysPerBundlestatic longONE_HOUR_INTERVAL_SECONDSThe submission timestamp is counted in 1 hour intervals since epoch.static longTEN_MINUTES_INTERVAL_SECONDSThe rolling start interval number is counted in 10 minute intervals since epoch.
-
Constructor Summary
Constructors Constructor Description DiagnosisKeyBundler(DistributionServiceConfig distributionServiceConfig)Constructs a DiagnosisKeyBundler based on the specified service configuration.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidcreateDiagnosisKeyDistributionMap(Collection<DiagnosisKey> diagnosisKeys)Initializes the internaldistributableDiagnosisKeysmap, which should contain all diagnosis keys, grouped by the LocalDateTime on which they may be distributed.List<DiagnosisKey>getAllDiagnosisKeys()Returns allDiagnosisKeyscontained by thisDiagnosisKeyBundler.Set<LocalDate>getDatesWithDistributableDiagnosisKeys()Returns a set of alldateson whichdiagnosis keysshall be distributed.List<DiagnosisKey>getDiagnosisKeysForDate(LocalDate date)Returns all diagnosis keys that should be distributed on a specific date.List<DiagnosisKey>getDiagnosisKeysForHour(LocalDateTime hour)Returns all diagnosis keys that should be distributed in a specific hour.LocalDateTimegetDistributionTime()Returns theLocalDateTimeat which the distribution runs.Set<LocalDateTime>getHoursWithDistributableDiagnosisKeys(LocalDate currentDate)static LocalDateTimegetLocalDateTimeFromHoursSinceEpoch(long timestamp)Creates aLocalDateTimebased on the specified epoch timestamp.protected LocalDateTimegetSubmissionDateTime(DiagnosisKey diagnosisKey)Returns the submission timestamp of aDiagnosisKeyas aLocalDateTime.booleannumberOfKeysForDateBelowMaximum(LocalDate date)voidsetDiagnosisKeys(Collection<DiagnosisKey> diagnosisKeys, LocalDateTime distributionTime)Sets theDiagnosisKeyscontained by thisDiagnosisKeyBundlerand the time at which the distribution runs and callscreateDiagnosisKeyDistributionMap(java.util.Collection<app.coronawarn.server.common.persistence.domain.DiagnosisKey>).
-
-
-
Field Detail
-
ONE_HOUR_INTERVAL_SECONDS
public static final long ONE_HOUR_INTERVAL_SECONDS
The submission timestamp is counted in 1 hour intervals since epoch.
-
TEN_MINUTES_INTERVAL_SECONDS
public static final long TEN_MINUTES_INTERVAL_SECONDS
The rolling start interval number is counted in 10 minute intervals since epoch.
-
expiryPolicyMinutes
protected final long expiryPolicyMinutes
-
minNumberOfKeysPerBundle
protected final int minNumberOfKeysPerBundle
-
distributionTime
protected LocalDateTime distributionTime
-
distributableDiagnosisKeys
protected final Map<LocalDateTime,List<DiagnosisKey>> distributableDiagnosisKeys
-
-
Constructor Detail
-
DiagnosisKeyBundler
public DiagnosisKeyBundler(DistributionServiceConfig distributionServiceConfig)
Constructs a DiagnosisKeyBundler based on the specified service configuration.
-
-
Method Detail
-
getLocalDateTimeFromHoursSinceEpoch
public static LocalDateTime getLocalDateTimeFromHoursSinceEpoch(long timestamp)
Creates aLocalDateTimebased on the specified epoch timestamp.
-
setDiagnosisKeys
public void setDiagnosisKeys(Collection<DiagnosisKey> diagnosisKeys, LocalDateTime distributionTime)
Sets theDiagnosisKeyscontained by thisDiagnosisKeyBundlerand the time at which the distribution runs and callscreateDiagnosisKeyDistributionMap(java.util.Collection<app.coronawarn.server.common.persistence.domain.DiagnosisKey>).- Parameters:
diagnosisKeys- TheDiagnosisKeyscontained by thisDiagnosisKeyBundler.distributionTime- TheLocalDateTimeat which the distribution runs.
-
getDistributionTime
public LocalDateTime getDistributionTime()
Returns theLocalDateTimeat which the distribution runs.
-
getAllDiagnosisKeys
public List<DiagnosisKey> getAllDiagnosisKeys()
Returns allDiagnosisKeyscontained by thisDiagnosisKeyBundler.
-
createDiagnosisKeyDistributionMap
protected abstract void createDiagnosisKeyDistributionMap(Collection<DiagnosisKey> diagnosisKeys)
Initializes the internaldistributableDiagnosisKeysmap, which should contain all diagnosis keys, grouped by the LocalDateTime on which they may be distributed.
-
getDatesWithDistributableDiagnosisKeys
public Set<LocalDate> getDatesWithDistributableDiagnosisKeys()
Returns a set of alldateson whichdiagnosis keysshall be distributed.
-
numberOfKeysForDateBelowMaximum
public boolean numberOfKeysForDateBelowMaximum(LocalDate date)
-
getHoursWithDistributableDiagnosisKeys
public Set<LocalDateTime> getHoursWithDistributableDiagnosisKeys(LocalDate currentDate)
-
getSubmissionDateTime
protected LocalDateTime getSubmissionDateTime(DiagnosisKey diagnosisKey)
Returns the submission timestamp of aDiagnosisKeyas aLocalDateTime.
-
getDiagnosisKeysForDate
public List<DiagnosisKey> getDiagnosisKeysForDate(LocalDate date)
Returns all diagnosis keys that should be distributed on a specific date.
-
getDiagnosisKeysForHour
public List<DiagnosisKey> getDiagnosisKeysForHour(LocalDateTime hour)
Returns all diagnosis keys that should be distributed in a specific hour.
-
-