Class DelegatingRoleAwareSynchronizedStateProvider<P,​F>

    • Constructor Detail

      • DelegatingRoleAwareSynchronizedStateProvider

        public DelegatingRoleAwareSynchronizedStateProvider​(java.lang.String id)
    • Method Detail

      • 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>
      • 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 interface SynchronizedStateProvider<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 interface SynchronizedStateProvider<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 interface SynchronizedStateProvider<P,​F>