Class AbstractBrowseExecutor<N extends HistoricalNode>

java.lang.Object
com.inductiveautomation.historian.gateway.api.query.browsing.AbstractBrowseExecutor<N>
Type Parameters:
N - the node type produced by the backend's tree.

public abstract class AbstractBrowseExecutor<N extends HistoricalNode> extends Object
Drives a BrowsePublisher from a HistoricalNodeTree. It walks the tree from the root, applies the BrowseFilter (honoring HistorianBrowseTraits.INCLUDE_RETIRED, HistorianBrowseTraits.INCLUDE_METADATA and HistorianBrowseTraits.LEAF_SEARCH), and recurses into children when filter.isRecursive(). When filter.getMaxResults() is reached, the executor is parked in a static continuation cache (10 minutes, 100 entries), and backends resume it with resumeFromContinuation(String, BrowseFilter, BrowsePublisher).

Backends supply newChild(QualifiedPath, BrowseFilter, BrowsePublisher, LoggerEx) and may override getMetadata(N).

Not thread-safe: callers must serialize calls on one instance, including a cached executor. The cache itself is thread-safe.

  • Constructor Details

    • AbstractBrowseExecutor

      protected AbstractBrowseExecutor(HistoricalNodeTree<N> nodeTree, QualifiedPath root, BrowseFilter filter, BrowsePublisher publisher, LoggerEx parentLogger)
      Creates an executor rooted at root.
      Parameters:
      nodeTree - the backend's node tree.
      root - the path to browse from.
      filter - the browse filter.
      publisher - receives the results.
      parentLogger - the logger from which a "browse" sub-logger is derived.
  • Method Details

    • resumeFromContinuation

      public static AbstractBrowseExecutor<?> resumeFromContinuation(String continuationId, BrowseFilter filter, BrowsePublisher publisher)
      Resumes a cached browse where it stopped, rebinding the filter and publisher.
      Parameters:
      continuationId - the id previously published via BrowsePublisher.setContinuationPoint(String).
      filter - the filter for this resumption.
      publisher - the publisher for this resumption.
      Returns:
      the executor, or null if the continuation expired or never existed.
    • execute

      public final void execute()
      Runs the browse to completion or to the next continuation point.
    • getMetadata

      protected Optional<MetadataPoint> getMetadata(N node)
      Returns the metadata to attach to a published node when HistorianBrowseTraits.INCLUDE_METADATA is set. Empty by default; backends that carry metadata override.
      Parameters:
      node - the node being processed.
      Returns:
      the metadata, or empty if none.
    • nodePassesRetirementFilter

      protected boolean nodePassesRetirementFilter(N node, BrowseFilter filter, Instant now)
      Returns whether a node should be emitted. The default passes active nodes and passes retired nodes only when HistorianBrowseTraits.INCLUDE_RETIRED is set. Backends with a tri-state retirement selector override this, usually by delegating to nodePassesRetirementState(N, RetirementState, Instant).
      Parameters:
      node - the candidate node.
      filter - the browse filter.
      now - the instant for this sweep; recursive child sweeps capture their own.
      Returns:
      true to emit the node.
    • nodePassesRetirementState

      protected final boolean nodePassesRetirementState(N node, RetirementState state, Instant now)
      Applies a RetirementState selector to a node: ACTIVE passes nodes with no retired time or one after now, RETIRED passes nodes retired at or before now, and ALL passes every node.
      Parameters:
      node - the candidate node.
      state - the selector.
      now - the instant for the enclosing sweep.
      Returns:
      true to emit the node.
    • newChild

      protected abstract AbstractBrowseExecutor<N> newChild(QualifiedPath root, BrowseFilter filter, BrowsePublisher publisher, LoggerEx parentLogger)
      Creates the executor for a recursive browse. Return an instance of the subclass's own type.
      Parameters:
      root - the child root path.
      filter - the filter, typically inherited.
      publisher - the recursive publisher.
      parentLogger - the logger from which the child's sub-logger is derived.
      Returns:
      a child executor of the same concrete type.