Class AbstractMaintenanceScheduler<T,P>
java.lang.Object
com.inductiveautomation.historian.gateway.api.maintenance.AbstractMaintenanceScheduler<T,P>
- Type Parameters:
T- the backend's table-identifier typeP- the backend's partition-info type
Skeleton of a periodic maintenance scheduler for a historian backend. It owns the single-thread
executor, the partition-aligned start, the periodic cadence, and the dispatch between
PRUNE and ARCHIVE.
A backend implements getPartitionsToMaintain(T), prunePartitions(T, List) and archivePartitions(T, List), and may override isReady() to hold maintenance until its tables are
verified.
Thread-safety: call start(MaintenanceStrategy, MaintenancePartitionUnit, List) and shutdown() only from the historian's
onStartup and onShutdown. runOneCycleSync() runs on the calling thread, and work
queued through scheduleDelayed(Runnable, long, TimeUnit) runs on the scheduler thread.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMaintenanceScheduler(LoggerEx logger, String name) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidarchivePartitions(T target, List<P> partitions) Detaches and archives the given partitions.getPartitionsToMaintain(T target) Returns partitions oftargetthat are currently eligible for maintenance.protected booleanisReady()Whether maintenance may run, for backends to hold it until preconditions are met (for example, tables verified).protected final booleanWhetherstart(MaintenanceStrategy, MaintenancePartitionUnit, List)armed the scheduler andshutdown()has not begun; follow-up work stands down once it is false.protected abstract voidprunePartitions(T target, List<P> partitions) Drops the given partitions.protected final voidRuns one full maintenance cycle synchronously on the calling thread with the strategy and targets given tostart(MaintenanceStrategy, MaintenancePartitionUnit, List), for conformance tests.protected final voidscheduleDelayed(Runnable task, long delay, TimeUnit unit) Schedules a follow-up task on the scheduler thread, for work that depends on the periodic cycle (for example, archiving once a partition detach has settled).final voidshutdown()Stops the periodic task and the executor.final voidstart(MaintenanceStrategy strategy, MaintenancePartitionUnit partitionUnit, List<T> maintenanceTargets) Starts the periodic maintenance task; does nothing whenstrategyisNONE.
-
Field Details
-
logger
-
-
Constructor Details
-
AbstractMaintenanceScheduler
-
-
Method Details
-
start
public final void start(MaintenanceStrategy strategy, MaintenancePartitionUnit partitionUnit, List<T> maintenanceTargets) -
isReady
protected boolean isReady()Whether maintenance may run, for backends to hold it until preconditions are met (for example, tables verified). The default istrue. -
runOneCycleSync
protected final void runOneCycleSync()Runs one full maintenance cycle synchronously on the calling thread with the strategy and targets given tostart(MaintenanceStrategy, MaintenancePartitionUnit, List), for conformance tests. Does nothing ifstart(MaintenanceStrategy, MaintenancePartitionUnit, List)was not called, was called withNONE, orshutdown()has returned (untilstart(MaintenanceStrategy, MaintenancePartitionUnit, List)is called again). -
scheduleDelayed
-
isRunning
protected final boolean isRunning()Whetherstart(MaintenanceStrategy, MaintenancePartitionUnit, List)armed the scheduler andshutdown()has not begun; follow-up work stands down once it is false. -
shutdown
public final void shutdown()Stops the periodic task and the executor. Safe to call when never started; a laterstart(MaintenanceStrategy, MaintenancePartitionUnit, List)re-arms the scheduler with fresh state. -
getPartitionsToMaintain
-
prunePartitions
-
archivePartitions
-