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.
  • Constructor Details

    • AbstractSynchronizedStateProvider

      public AbstractSynchronizedStateProvider(GatewayContext context, String id)
  • Method Details

    • getId

      public String getId()
      Description copied from interface: SynchronizedStateProvider
      A simple and unique identifier for this state subsystem.
      Specified by:
      getId in interface SynchronizedStateProvider<P,F>
    • isBidirectional

      public boolean isBidirectional()
      Description copied from interface: SynchronizedStateProvider
      Indicates the state can be synchronized bi-directionally.
      Specified by:
      isBidirectional in interface SynchronizedStateProvider<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 interface SynchronizedStateProvider<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 interface SynchronizedStateProvider<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 interface SynchronizedStateProvider<P,F>
    • setVersion

      protected void setVersion(VersionToken version)
    • requestSync

      protected void requestSync()
    • requestForcedSync

      protected void requestForcedSync()
    • setRestoreInProgress

      public void setRestoreInProgress(boolean inProgress)
      Specified by:
      setRestoreInProgress in interface RestoreAware
      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 interface RestoreAware