Class AbstractHistorian<S extends HistorianSettings>
java.lang.Object
com.inductiveautomation.historian.gateway.api.storage.AbstractHistorian<S>
- All Implemented Interfaces:
Historian<S>
public abstract class AbstractHistorian<S extends HistorianSettings>
extends Object
implements Historian<S>
Base class for historian implementations. Owns the lifecycle state, the logger, the gateway
context and the
QualifiedPathAdapter, and provides path transformation and system-rename
handling for subclasses.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AvailabilityStateCurrent availability.protected final GatewayContextprotected StringThe canonical (PathFolding.canonical(String)) system name the stored nodes carry.protected Stringprotected Sprotected final @NonNull LoggerExprotected final QualifiedPathAdapterPath adapter that reads the gateway system name live, so paths without asys:component follow a rename.protected booleanprotected static final AvailabilityStatePublished bystartup()untilonStartup()reports a real availability.protected static final AvailabilityStatePublished byshutdown()beforeonShutdown()begins tearing down. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractHistorian(GatewayContext context, String historianName) protectedAbstractHistorian(GatewayContext context, String historianName, @Nullable LoggerEx logger) -
Method Summary
Modifier and TypeMethodDescriptionReturns whether this historian and its engines are usable.protected Supplier<AvailabilityState> Returns aSupplierbacked by this historian's volatile availability field.protected voidApplies a rename that happened while the listener was detached; re-registering does not replay it.getName()Returns the historian's name.Returns the adapter used to normalize paths;QualifiedPathAdapter.DEFAULTby default.Returns the historian's settings.MapsavailabilityState()to a status:ProfileStatus.STARTINGandProfileStatus.STOPPINGfor the transient lifecycle states, so the Historians page shows them as neutral rather than as faults; running when available; errored with the cause otherwise.protected voidprotected voidprotected voidStarts forwarding gateway system renames to the storage engine's rename hook.protected QualifiedPathreversePath(QualifiedPath path) Returns the original, plainQualifiedPathbehind a path fromtransformPath(QualifiedPath).final voidshutdown()Stops the historian and releases its resources.final voidstartup()Starts the historian: allocates resources, connects to backends and schedules maintenance.protected QualifiedPathtransformPath(QualifiedPath path) Normalizes a path with the historian's path adapter.protected voidStops forwarding system renames.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Historian
getQueryEngine, getStorageEngine, handleNameChange, handleResourceDeleted, handleSettingsChange
-
Field Details
-
logger
-
context
-
pathAdapter
Path adapter that reads the gateway system name live, so paths without asys:component follow a rename. -
historianName
-
historianSettings
-
started
protected boolean started -
STARTING
Published bystartup()untilonStartup()reports a real availability. -
STOPPING
Published byshutdown()beforeonShutdown()begins tearing down. -
availabilityState
Current availability.startup()andshutdown()publishSTARTINGandSTOPPING; subclasses publish all other states. -
currentSystemName
The canonical (PathFolding.canonical(String)) system name the stored nodes carry. Subclasses set it inonStartup()and callregisterSystemRenameListener(); the listener advances it only after the storage engine's rename hook succeeds, so a failed rename is retried on the next system-properties change. This can differ from the gateway's own name during or after a failed rename: read this for what the stored data says, andgetPathAdapter()for how an incoming path without asys:component resolves now.
-
-
Constructor Details
-
AbstractHistorian
-
AbstractHistorian
protected AbstractHistorian(GatewayContext context, String historianName, @Nullable LoggerEx logger)
-
-
Method Details
-
getPathAdapter
Description copied from interface:HistorianReturns the adapter used to normalize paths;QualifiedPathAdapter.DEFAULTby default.- Specified by:
getPathAdapterin interfaceHistorian<S extends HistorianSettings>
-
getName
-
getSettings
Description copied from interface:HistorianReturns the historian's settings.- Specified by:
getSettingsin interfaceHistorian<S extends HistorianSettings>
-
availabilityState
Returns whether this historian and its engines are usable. A non-blocking volatile read, safe from any thread.- Returns:
- the current availability; never null.
-
availabilitySupplier
Returns aSupplierbacked by this historian's volatile availability field. -
getStatus
MapsavailabilityState()to a status:ProfileStatus.STARTINGandProfileStatus.STOPPINGfor the transient lifecycle states, so the Historians page shows them as neutral rather than as faults; running when available; errored with the cause otherwise.- Specified by:
getStatusin interfaceHistorian<S extends HistorianSettings>
-
startup
Description copied from interface:HistorianStarts the historian: allocates resources, connects to backends and schedules maintenance. May throwIllegalStateExceptionif already started.- Specified by:
startupin interfaceHistorian<S extends HistorianSettings>- Throws:
Exception- if startup fails.
-
onStartup
-
shutdown
public final void shutdown()Description copied from interface:HistorianStops the historian and releases its resources. It must not accept new requests afterwards. Overrides should callsuper.- Specified by:
shutdownin interfaceHistorian<S extends HistorianSettings>
-
onShutdown
protected void onShutdown() -
transformPath
Normalizes a path with the historian's path adapter. An already-adapted input is nested, keeping the transformation history;AdaptedQualifiedPath.getDeepestOriginalPath()recovers the original.- Parameters:
path- the path to transform.- Returns:
- the normalized path, as an
AdaptedQualifiedPath.
-
reversePath
Returns the original, plainQualifiedPathbehind a path fromtransformPath(QualifiedPath).- Parameters:
path- the path to reverse.- Returns:
- the original path.
- See Also:
-
registerSystemRenameListener
protected void registerSystemRenameListener()Starts forwarding gateway system renames to the storage engine's rename hook. Call fromonStartup()after initializingcurrentSystemName. -
unregisterSystemRenameListener
protected void unregisterSystemRenameListener()Stops forwarding system renames. Call fromonShutdown()before tearing down the storage engine. -
catchUpSystemRename
protected void catchUpSystemRename()Applies a rename that happened while the listener was detached; re-registering does not replay it. No-op when the stored nodes already carry the gateway's name. The caller must hold no lock the storage engine's rename hook takes.
-