Class PointStorageStrategy
java.lang.Object
com.inductiveautomation.historian.gateway.api.storage.strategy.PointStorageStrategy
- Direct Known Subclasses:
DebounceStorageStrategy, FailureHandlingStorageStrategy, ImmediateStorageStrategy
Decides when and how points reach the storage engine: store immediately, buffer and batch, or
divert. The engine registers a
PointStorageStrategy.Listener and the strategy hands it ready batches.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceReceives batches that are ready to store. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final QualityCodeFailure code for points rejected because the strategy shut down.protected static final QualityCodeFailure code for a batch that left the queue but that no listener settled. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static <P extends TemporalPoint<?,?>>
voidcompleteAsFailure(TemporalPointBatch<P> batch, QualityCode code) Completesbatchas a failure withcode, unless something already settled it.protected static <P extends TemporalPoint<?,?>>
StorageResult<P> failureWithError(QualityCode code, List<P> points) Builds a failure result that carries an exception as well ascode.voidflushNow()Starts draining any buffered data without waiting for timers; best-effort, and the drain may not have completed on return.Returns batch size, dwell and downstream duration over a window of recent flushes.protected final booleanforwardPoints(TemporalPointBatch<?> batch) Hands a batch to the registered listener.protected static <P extends TemporalPoint<?,?>>
CompletableFuture<StorageResult<P>> joinSubBatchResults(List<CompletableFuture<StorageResult<P>>> subs) Merges sub-batch result futures into one, perStorageResult.join(StorageResult, StorageResult).metrics()Returns how much data is queued and how long the oldest has waited.voidonPointsReady(PointStorageStrategy.Listener pointsConsumer) Registers the listener for ready batches.voidSuspends forwarding for a transient pause, such as an engine restart, while buffering strategies keep accepting and retaining points untilresumeProcessing().abstract CompletionStage<StorageResult<AtomicPoint<?>>> processAtomic(List<AtomicPoint<?>> atomicPoints) Processes atomic points asynchronously.abstract <C extends ChangePoint<?>>
CompletionStage<StorageResult<C>> processChanges(List<C> changePoints) Processes change points asynchronously.abstract <C extends ComplexPoint<?>>
CompletionStage<StorageResult<C>> processComplex(List<C> complexPoints) Processes complex points asynchronously.abstract voidResumes processing afterpauseProcessing()orstopProcessing().abstract voidStops processing, rejects further points and releases resources.
-
Field Details
-
SHUTDOWN_FAILURE_CODE
Failure code for points rejected because the strategy shut down. An error-level code, sincefailureWithError(QualityCode, List)pairs it with an exception. -
UNHANDLED_FAILURE_CODE
Failure code for a batch that left the queue but that no listener settled.
-
-
Constructor Details
-
PointStorageStrategy
public PointStorageStrategy()
-
-
Method Details
-
failureWithError
protected static <P extends TemporalPoint<?,?>> StorageResult<P> failureWithError(QualityCode code, List<P> points) Builds a failure result that carries an exception as well ascode. The exception is what makes store-and-forward retain the data; a bare failure code would let the points be dropped.- Parameters:
code- the quality code describing the failure.points- the points that were not stored.- Returns:
- a result carrying
codeand a matching exception.
-
completeAsFailure
protected static <P extends TemporalPoint<?,?>> void completeAsFailure(TemporalPointBatch<P> batch, QualityCode code) Completesbatchas a failure withcode, unless something already settled it.- Parameters:
batch- the batch to fail.code- the quality code describing the failure.
-
processAtomic
public abstract CompletionStage<StorageResult<AtomicPoint<?>>> processAtomic(List<AtomicPoint<?>> atomicPoints) Processes atomic points asynchronously.- Parameters:
atomicPoints- the points to process.- Returns:
- a stage completing with the storage result.
-
processComplex
public abstract <C extends ComplexPoint<?>> CompletionStage<StorageResult<C>> processComplex(List<C> complexPoints) Processes complex points asynchronously.- Type Parameters:
C- the complex point type.- Parameters:
complexPoints- the points to process.- Returns:
- a stage completing with the storage result.
-
processChanges
public abstract <C extends ChangePoint<?>> CompletionStage<StorageResult<C>> processChanges(List<C> changePoints) Processes change points asynchronously.- Type Parameters:
C- the change point type.- Parameters:
changePoints- the points to process.- Returns:
- a stage completing with the storage result.
-
pauseProcessing
public void pauseProcessing()Suspends forwarding for a transient pause, such as an engine restart, while buffering strategies keep accepting and retaining points untilresumeProcessing(). UnlikestopProcessing(), nothing is rejected. The default delegates tostopProcessing(), for strategies that cannot buffer (e.g.ImmediateStorageStrategy). -
stopProcessing
public abstract void stopProcessing()Stops processing, rejects further points and releases resources. Call when the engine is shutting down. -
resumeProcessing
public abstract void resumeProcessing()Resumes processing afterpauseProcessing()orstopProcessing(). -
metrics
Returns how much data is queued and how long the oldest has waited. Buffering strategies override this; the default is empty, for strategies that hold no backlog.- Returns:
- the current metrics, or empty if the strategy accumulates no data.
-
flushTelemetry
Returns batch size, dwell and downstream duration over a window of recent flushes. Buffering strategies override this; the default is empty.- Returns:
- the current telemetry, or empty if the strategy does not flush in batches.
-
flushNow
public void flushNow()Starts draining any buffered data without waiting for timers; best-effort, and the drain may not have completed on return. The default does nothing, for strategies that hold no backlog. -
joinSubBatchResults
protected static <P extends TemporalPoint<?,?>> CompletableFuture<StorageResult<P>> joinSubBatchResults(List<CompletableFuture<StorageResult<P>>> subs) Merges sub-batch result futures into one, perStorageResult.join(StorageResult, StorageResult).- Type Parameters:
P- the point type.- Parameters:
subs- the per-sub-batch result futures.- Returns:
- a future completing with the merged result once every sub-batch settles.
-
forwardPoints
Hands a batch to the registered listener. A batch that reaches no listener is already out of its queue, so the caller must then complete its future.- Parameters:
batch- the batch to forward.- Returns:
trueif a listener was invoked;falseif the batch went nowhere.
-
onPointsReady
Registers the listener for ready batches. Composite strategies override this to pass the listener on to their delegates.- Parameters:
pointsConsumer- the listener to register.
-