Class SurveySchedule
java.lang.Object
org.odpi.openmetadata.adapters.connectors.liskov.SurveySchedule
Decides whether a survey of a data store is due.
A data store that has never been surveyed is surveyed straight away. After that, the interval between surveys starts at the minimum interval and grows by a day each time a survey finds no change since the survey before it, up to the maximum interval. As soon as a survey finds a change, the interval drops back to the minimum and the cycle repeats. With the default limits, a data store that keeps changing is surveyed daily, and one that has stopped changing is surveyed after 1 day, then 2, then 3 and so on up to once a week.
Nothing about the schedule is stored. It is worked out from the survey history each time it is needed, so it survives a restart of the integration daemon. The history is only consulted when the answer depends on it - never before the minimum interval has passed, never once the maximum has, and otherwise only as far back as the time since the latest survey requires.
A data store that has never been surveyed is surveyed straight away. After that, the interval between surveys starts at the minimum interval and grows by a day each time a survey finds no change since the survey before it, up to the maximum interval. As soon as a survey finds a change, the interval drops back to the minimum and the cycle repeats. With the default limits, a data store that keeps changing is surveyed daily, and one that has stopped changing is surveyed after 1 day, then 2, then 3 and so on up to once a week.
Nothing about the schedule is stored. It is worked out from the survey history each time it is needed, so it survives a restart of the integration daemon. The history is only consulted when the answer depends on it - never before the minimum interval has passed, never once the maximum has, and otherwise only as far back as the time since the latest survey requires.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCompares one survey with the survey before it.static final recordThe outcome ofdecide(java.util.Date, int, org.odpi.openmetadata.adapters.connectors.liskov.SurveySchedule.ChangeDetector, long): whether a survey is due, and why. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default maximum number of days between surveys.static final intThe default minimum number of days between surveys. -
Constructor Summary
ConstructorsConstructorDescriptionSurveySchedule(int minimumIntervalDays, int maximumIntervalDays) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondecide(Date latestSurveyTime, int completedSurveyCount, SurveySchedule.ChangeDetector changeDetector, long now) Determine whether a survey is due, and why - seeisSurveyDue(java.util.Date, int, org.odpi.openmetadata.adapters.connectors.liskov.SurveySchedule.ChangeDetector, long).intReturn the largest number of completed surveys, most recent first, thatisSurveyDue(java.util.Date, int, org.odpi.openmetadata.adapters.connectors.liskov.SurveySchedule.ChangeDetector, long)can need to look at.intReturn the most days between surveys.intReturn the fewest days between surveys.booleanisSurveyDue(Date latestSurveyTime, int completedSurveyCount, SurveySchedule.ChangeDetector changeDetector, long now) Determine whether a survey is due.
-
Field Details
-
DEFAULT_MINIMUM_INTERVAL_DAYS
public static final int DEFAULT_MINIMUM_INTERVAL_DAYSThe default minimum number of days between surveys.- See Also:
-
DEFAULT_MAXIMUM_INTERVAL_DAYS
public static final int DEFAULT_MAXIMUM_INTERVAL_DAYSThe default maximum number of days between surveys.- See Also:
-
-
Constructor Details
-
SurveySchedule
public SurveySchedule(int minimumIntervalDays, int maximumIntervalDays) Constructor. A negative minimum is treated as zero, and a maximum below the minimum as the minimum.- Parameters:
minimumIntervalDays- fewest days between surveysmaximumIntervalDays- most days between surveys
-
-
Method Details
-
getMinimumIntervalDays
public int getMinimumIntervalDays()Return the fewest days between surveys.- Returns:
- number of days
-
getMaximumIntervalDays
public int getMaximumIntervalDays()Return the most days between surveys.- Returns:
- number of days
-
getCompletedSurveysNeeded
public int getCompletedSurveysNeeded()Return the largest number of completed surveys, most recent first, thatisSurveyDue(java.util.Date, int, org.odpi.openmetadata.adapters.connectors.liskov.SurveySchedule.ChangeDetector, long)can need to look at. A caller retrieving the survey history need not retrieve any more than this.- Returns:
- number of completed surveys
-
isSurveyDue
public boolean isSurveyDue(Date latestSurveyTime, int completedSurveyCount, SurveySchedule.ChangeDetector changeDetector, long now) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException Determine whether a survey is due.
The interval is the minimum plus a day for each of the most recent surveys in a row that found no change, up to the maximum. So with d whole days since the latest survey, the survey is due unless each of the latest (d - minimum + 1) completed surveys found no change since the one before it. The comparisons stop at the first change. A completed survey with no completed survey before it to compare with counts as a change, because there is no evidence yet that the data store is stable.- Parameters:
latestSurveyTime- when the latest survey started - completed or not - or null if there has never been one. Measuring from the latest attempt means a survey that keeps failing is retried at the minimum interval rather than on every refresh.completedSurveyCount- number of completed surveys available to the change detectorchangeDetector- compares a completed survey with the one before itnow- the current time in milliseconds- Returns:
- true if a survey should be requested
- Throws:
InvalidParameterException- the parameters are invalidPropertyServerException- problem accessing the property serverUserNotAuthorizedException- user is not authorized to issue this request
-
decide
public SurveySchedule.Decision decide(Date latestSurveyTime, int completedSurveyCount, SurveySchedule.ChangeDetector changeDetector, long now) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException Determine whether a survey is due, and why - seeisSurveyDue(java.util.Date, int, org.odpi.openmetadata.adapters.connectors.liskov.SurveySchedule.ChangeDetector, long).- Parameters:
latestSurveyTime- when the latest survey started - completed or not - or null if there has never been onecompletedSurveyCount- number of completed surveys available to the change detectorchangeDetector- compares a completed survey with the one before itnow- the current time in milliseconds- Returns:
- decision and the reason for it
- Throws:
InvalidParameterException- the parameters are invalidPropertyServerException- problem accessing the property serverUserNotAuthorizedException- user is not authorized to issue this request
-