Class AbstractSynchronizedStateProvider<P,F>
- java.lang.Object
-
- com.inductiveautomation.ignition.gateway.redundancy.types.AbstractSynchronizedStateProvider<P,F>
-
- All Implemented Interfaces:
SynchronizedStateProvider<P,F>
public abstract class AbstractSynchronizedStateProvider<P,F> extends java.lang.Object implements SynchronizedStateProvider<P,F>
A simple base definition for SynchronizedStateProvider. Does the following by default:
- Returns FALSE for isBidirectional()
- Returns a random uuid for default initial version.
-
-
Constructor Summary
Constructors Constructor Description AbstractSynchronizedStateProvider(GatewayContext context, java.lang.String id)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract LoggerEx
createLogger()
protected GatewayContext
getContext()
protected SyncController
getController()
java.lang.String
getId()
A simple and unique identifier for this state subsystem.protected LoggerEx
getLogger()
VersionToken
getVersion()
This represents the current version of the state.protected boolean
hasChanges()
Returns whether we have partial changes we expect to sync.protected void
incrementVersion()
Helper function - Updates the version revision and requests sync.void
init(SyncController controller)
"Starts" the provider.protected VersionToken
initializeVersion()
Called when starting up, should generate a version that represents the current state.protected boolean
isActive()
boolean
isBidirectional()
Indicates the state can be synchronized bi-directionally.protected boolean
isMaster()
protected boolean
isStarted()
protected void
requestForcedSync()
protected void
requestSync()
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, pullFull, pullPartial
-
-
-
-
Constructor Detail
-
AbstractSynchronizedStateProvider
public AbstractSynchronizedStateProvider(GatewayContext context, java.lang.String id)
-
-
Method Detail
-
getId
public java.lang.String 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
protected GatewayContext getContext()
-
getController
protected SyncController getController()
-
getLogger
protected LoggerEx getLogger()
-
createLogger
protected abstract LoggerEx createLogger()
-
isStarted
protected boolean isStarted()
-
isMaster
protected boolean isMaster()
-
isActive
protected boolean isActive()
-
init
public void init(SyncController controller)
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
protected VersionToken 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
protected void updateBiDirectionalVersion(VersionToken incoming)
-
getVersion
public VersionToken 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
protected void setVersion(VersionToken version)
-
requestSync
protected void requestSync()
-
requestForcedSync
protected void requestForcedSync()
-
-