com.hazelcast.crdt

## Class CRDTReplicationMigrationService

- java.lang.Object
- - com.hazelcast.crdt.CRDTReplicationMigrationService

- All Implemented Interfaces:
    ManagedService, MembershipAwareService

      public class CRDTReplicationMigrationService
      extends Object
      implements ManagedService, MembershipAwareService

  Service that handles replication and migration of CRDT data for all CRDT implementations. The CRDT implementations for which it performs replication and migration must implement `CRDTReplicationAwareService`.

  The replication is performed periodically on an executor with the name "hz:CRDTReplicationMigration". You may configure this executor accordingly. The migration mechanism uses the same executor but it is performed only on membership changes and on CRDT state merge. The migration checks are triggered on CRDT state merge because CRDT states can get merged when a replica is shutting down and it is trying to replicate any previously unreplicated state to any member in the cluster, regardless of the configured replica count.

  See Also:
    `CRDTReplicationConfig.getReplicationPeriodMillis()`, `CRDTReplicationConfig.getMaxConcurrentReplicationTargets()`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CRDT_REPLICATION_MIGRATION_EXECUTOR` The executor for the CRDT replication and migration tasks
    `static String` | `SERVICE_NAME` The name of this service

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CRDTReplicationMigrationService()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `init(NodeEngine nodeEngine, Properties properties)` Initializes this service.
    `void` | `memberAdded(MembershipServiceEvent event)` Invoked when a new member is added to the cluster.
    `void` | `memberAttributeChanged(MemberAttributeServiceEvent event)` Invoked when a member attribute is changed.
    `void` | `memberRemoved(MembershipServiceEvent event)` Invoked when an existing member leaves the cluster.
    `void` | `reset()` Resets this service back to its initial state.
    `void` | `shutdown(boolean terminate)` Shuts down this service.
    `void` | `syncReplicateDirtyCRDTs()` Attempts to replicate only the unreplicated CRDT state to any non-local member in the cluster.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SERVICE_NAME

          public static final String SERVICE_NAME

      The name of this service
      See Also:
        Constant Field Values

    - #### CRDT_REPLICATION_MIGRATION_EXECUTOR

          public static final String CRDT_REPLICATION_MIGRATION_EXECUTOR

      The executor for the CRDT replication and migration tasks
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CRDTReplicationMigrationService

          public CRDTReplicationMigrationService()

  - ### Method Detail

    - #### init

          public void init(NodeEngine nodeEngine,
                           Properties properties)

      Description copied from interface: `ManagedService`
      Initializes this service.
      Specified by:
        `init` in interface `ManagedService`
      Parameters:
        `nodeEngine` - the NodeEngine that this service belongs to
        `properties` - the Properties (can be used to pass settings to the service)

    - #### reset

          public void reset()

      Description copied from interface: `ManagedService`
      Resets this service back to its initial state.

      TODO: what is the purpose of reset

      Specified by:
        `reset` in interface `ManagedService`

    - #### shutdown

          public void shutdown(boolean terminate)

      Description copied from interface: `ManagedService`
      Shuts down this service.

      TODO: what is the purpose of the terminate variable

      Specified by:
        `shutdown` in interface `ManagedService`
      Parameters:
        `terminate` - `true` to shut down this service

    - #### syncReplicateDirtyCRDTs

          public void syncReplicateDirtyCRDTs()

      Attempts to replicate only the unreplicated CRDT state to any non-local member in the cluster. The state may be unreplicated because the CRDT state has been changed (via mutation or merge with an another CRDT) but has not yet been disseminated through the usual replication mechanism to any member. This method will iterate through the member list and try and replicate to at least one member. The method returns once all of the unreplicated state has been replicated successfully or when there are no more members to attempt processing. This method will replicate all of the unreplicated CRDT states to any data member in the cluster, regardless if that member is actually the replica for some CRDT (because of a configured replica count). It is the responsibility of that member to migrate the state for which it is not a replica. The configured replica count can therefore be broken during shutdown to increase the chance of survival of unreplicated CRDT data (if the actual replicas are unreachable).
      See Also:
        `CRDTReplicationTask`

    - #### memberAdded

          public void memberAdded(MembershipServiceEvent event)

      Description copied from interface: `MembershipAwareService`
      Invoked when a new member is added to the cluster. Should be non-blocking.
      Specified by:
        `memberAdded` in interface `MembershipAwareService`
      Parameters:
        `event` - the event for a new member added to the cluster

    - #### memberRemoved

          public void memberRemoved(MembershipServiceEvent event)

      Description copied from interface: `MembershipAwareService`
      Invoked when an existing member leaves the cluster. Should be non-blocking.
      Specified by:
        `memberRemoved` in interface `MembershipAwareService`
      Parameters:
        `event` - the event for an existing member leaving the cluster

    - #### memberAttributeChanged

          public void memberAttributeChanged(MemberAttributeServiceEvent event)

      Description copied from interface: `MembershipAwareService`
      Invoked when a member attribute is changed.
      Specified by:
        `memberAttributeChanged` in interface `MembershipAwareService`
      Parameters:
        `event` - the event for a member attribute being changed

Copyright © 2018. All rights reserved.