Class AbstractMaintenanceScheduler<T,P>

java.lang.Object
com.inductiveautomation.historian.gateway.api.maintenance.AbstractMaintenanceScheduler<T,P>
Type Parameters:
T - the backend's table-identifier type
P - the backend's partition-info type

public abstract class AbstractMaintenanceScheduler<T,P> extends Object
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 Details

    • logger

      protected final LoggerEx logger
  • Constructor Details

    • AbstractMaintenanceScheduler

      protected AbstractMaintenanceScheduler(LoggerEx logger, String name)
  • Method Details

    • start

      public final void start(MaintenanceStrategy strategy, MaintenancePartitionUnit partitionUnit, List<T> maintenanceTargets)
      Starts the periodic maintenance task; does nothing when strategy is NONE. The first run is aligned to the next partition boundary (next hour for HOUR, next day otherwise), then repeats every hour or day by cadence.
    • isReady

      protected boolean isReady()
      Whether maintenance may run, for backends to hold it until preconditions are met (for example, tables verified). The default is true.
    • runOneCycleSync

      protected final void runOneCycleSync()
      Runs one full maintenance cycle synchronously on the calling thread with the strategy and targets given to start(MaintenanceStrategy, MaintenancePartitionUnit, List), for conformance tests. Does nothing if start(MaintenanceStrategy, MaintenancePartitionUnit, List) was not called, was called with NONE, or shutdown() has returned (until start(MaintenanceStrategy, MaintenancePartitionUnit, List) is called again).
    • scheduleDelayed

      protected final void scheduleDelayed(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). Ignored if the scheduler is not running.
    • isRunning

      protected final boolean isRunning()
      Whether start(MaintenanceStrategy, MaintenancePartitionUnit, List) armed the scheduler and shutdown() 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 later start(MaintenanceStrategy, MaintenancePartitionUnit, List) re-arms the scheduler with fresh state.
    • getPartitionsToMaintain

      protected abstract List<P> getPartitionsToMaintain(T target)
      Returns partitions of target that are currently eligible for maintenance.
    • prunePartitions

      protected abstract void prunePartitions(T target, List<P> partitions)
      Drops the given partitions.
    • archivePartitions

      protected abstract void archivePartitions(T target, List<P> partitions)
      Detaches and archives the given partitions.