Class DelegatingRoleAwareSynchronizedStateProvider<P,F>
- java.lang.Object
-
- com.inductiveautomation.ignition.gateway.redundancy.types.DelegatingRoleAwareSynchronizedStateProvider<P,F>
-
- All Implemented Interfaces:
SynchronizedStateProvider<P,F>
public abstract class DelegatingRoleAwareSynchronizedStateProvider<P,F> extends java.lang.Object implements SynchronizedStateProvider<P,F>
-
-
Constructor Summary
Constructors Constructor Description DelegatingRoleAwareSynchronizedStateProvider(java.lang.String id)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
applyFullState(State<F> state)
Applies the full state.void
applyPartialState(State<P> state)
Should apply the partial state.boolean
fullRequiresRestart()
This is used by the system to detect "major" changes.SynchronizedStateProvider<P,F>
getDelegate()
java.lang.String
getId()
A simple and unique identifier for this state subsystem.VersionToken
getVersion()
This represents the current version of the state.void
init(SyncController controller)
"Starts" the provider.protected abstract SynchronizedStateProvider<P,F>
intantiateForRole(NodeRole role)
boolean
isBidirectional()
Indicates the state can be synchronized bi-directionally.State<F>
pullFull()
Should return the full state.State<P>
pullPartial(VersionToken version)
Should return a set of partial changes going from the provided version.void
shutdown()
Called when the system is being shut down or the gateway has changed role.-
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
-
-
-
-
Method Detail
-
intantiateForRole
protected abstract SynchronizedStateProvider<P,F> intantiateForRole(NodeRole role)
-
getDelegate
public SynchronizedStateProvider<P,F> getDelegate()
-
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>
-
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>
-
fullRequiresRestart
public boolean fullRequiresRestart()
Description copied from interface:SynchronizedStateProvider
This is used by the system to detect "major" changes. When this is true, and a full sync is required, the system is marked as "Out of Date", and knows it will be restarted when an update arrives.- Specified by:
fullRequiresRestart
in interfaceSynchronizedStateProvider<P,F>
-
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>
-
pullPartial
public State<P> pullPartial(VersionToken version)
Description copied from interface:SynchronizedStateProvider
Should return a set of partial changes going from the provided version. If not available, should return State.outOfDate().- Specified by:
pullPartial
in interfaceSynchronizedStateProvider<P,F>
-
pullFull
public State<F> pullFull()
Description copied from interface:SynchronizedStateProvider
Should return the full state.- Specified by:
pullFull
in interfaceSynchronizedStateProvider<P,F>
-
applyPartialState
public void applyPartialState(State<P> state)
Description copied from interface:SynchronizedStateProvider
Should apply the partial state. If the process fails for some reason, the system should reset its internal version and request sync, so that the full state may be transferred.- Specified by:
applyPartialState
in interfaceSynchronizedStateProvider<P,F>
-
applyFullState
public void applyFullState(State<F> state)
Description copied from interface:SynchronizedStateProvider
Applies the full state. If the update fails, the system should reset its internal version and request sync in order to retry.- Specified by:
applyFullState
in interfaceSynchronizedStateProvider<P,F>
-
-