Class AbstractSynchronizedStateProvider<P,F>
java.lang.Object
com.inductiveautomation.ignition.gateway.redundancy.types.AbstractSynchronizedStateProvider<P,F>
- All Implemented Interfaces:
RestoreAware
,SynchronizedStateProvider<P,
F>
public abstract class AbstractSynchronizedStateProvider<P,F>
extends Object
implements SynchronizedStateProvider<P,F>, RestoreAware
A simple base definition for SynchronizedStateProvider.
Does the following by default:
- Returns FALSE for isBidirectional()
- Returns a random uuid for default initial version.
- Returns FALSE for isBidirectional()
- Returns a random uuid for default initial version.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract LoggerEx
protected GatewayContext
protected SyncController
getId()
A simple and unique identifier for this state subsystem.protected LoggerEx
This represents the current version of the state.protected boolean
Returns whether we have partial changes we expect to sync.protected void
Helper function - Updates the version revision and requests sync.void
init
(SyncController controller) "Starts" the provider.protected VersionToken
Called when starting up, should generate a version that represents the current state.protected boolean
isActive()
boolean
Indicates the state can be synchronized bi-directionally.protected boolean
isMaster()
boolean
If true, this indicates that the backup is in the midst of a gateway restore.protected boolean
protected void
protected void
void
setRestoreInProgress
(boolean inProgress) protected void
setVersion
(VersionToken version) void
shutdown()
Called when the system is being shut down or the gateway has changed role.protected void
updateBiDirectionalVersion
(VersionToken incoming) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.inductiveautomation.ignition.gateway.redundancy.types.SynchronizedStateProvider
appendMetrics, applyFullState, applyPartialState, fullRequiresRestart, getFriendlyName, pullFull, pullPartial
-
Constructor Details
-
AbstractSynchronizedStateProvider
-
-
Method Details
-
getId
Description copied from interface:SynchronizedStateProvider
A simple and unique identifier for this state subsystem.- Specified by:
getId
in interfaceSynchronizedStateProvider<P,
F>
-
isBidirectional
public boolean isBidirectional()Description copied from interface:SynchronizedStateProvider
Indicates the state can be synchronized bi-directionally.- Specified by:
isBidirectional
in interfaceSynchronizedStateProvider<P,
F>
-
getContext
-
getController
-
getLogger
-
createLogger
-
isStarted
protected boolean isStarted() -
isMaster
protected boolean isMaster() -
isActive
protected boolean isActive() -
init
Description copied from interface:SynchronizedStateProvider
"Starts" the provider. The controller can be used to request sync whenever the provider thinks there has been a change. It can be called freely, the parent system will coalesce calls into single operations that happen periodically.- Specified by:
init
in interfaceSynchronizedStateProvider<P,
F>
-
shutdown
public void shutdown()Description copied from interface:SynchronizedStateProvider
Called when the system is being shut down or the gateway has changed role. It should be expected that startup may be called again on the same instance.- Specified by:
shutdown
in interfaceSynchronizedStateProvider<P,
F>
-
initializeVersion
Called when starting up, should generate a version that represents the current state. -
incrementVersion
protected void incrementVersion()Helper function - Updates the version revision and requests sync. -
hasChanges
protected boolean hasChanges()Returns whether we have partial changes we expect to sync. Should be overridden for bi-directional providers, especially if using updateBiDirectionalVersion. -
updateBiDirectionalVersion
-
getVersion
Description copied from interface:SynchronizedStateProvider
This represents the current version of the state. It is a *little* tricky, however, when it comes to bi-directional states. Bi-directional states mean that changes can happen on both sides and are merged when synchronized. How this works: 1) Utimately the goal is to have the version be the same on both sides. 2) The state synchronizer will keep track of the last version seen, both locally and remotely. 3) When a partial state is applied here, this provider determines if it still has changes. If so, it requests a sync. 4) When the partial pull comes in, it will be for an older revision- this revision is relative to this side. At this point, the provider returns the outstanding changes with an id equal to what was last received. If in the mean time the other side has modified the state again, it the cycle would continue- except in step 3 there shouldn't be any more outstanding changes. This logic is handled by the AbstractSynchronizedStateProvider.- Specified by:
getVersion
in interfaceSynchronizedStateProvider<P,
F>
-
setVersion
-
requestSync
protected void requestSync() -
requestForcedSync
protected void requestForcedSync() -
setRestoreInProgress
public void setRestoreInProgress(boolean inProgress) - Specified by:
setRestoreInProgress
in interfaceRestoreAware
- Parameters:
inProgress
- Set to true to indicate that the backup is currently processing a gateway restore
-
isRestoreInProgress
public boolean isRestoreInProgress()Description copied from interface:RestoreAware
If true, this indicates that the backup is in the midst of a gateway restore. This can indicate that partial updates do not need to be accumulated if a full sync will be performed later when the other side reconnects. Each redundant provider can use this information as it sees fit.- Specified by:
isRestoreInProgress
in interfaceRestoreAware
-