com.hazelcast.crdt

## Interface CRDTReplicationAwareService<T>

- Type Parameters:
    `T` - CRDT implementation type
  All Known Implementing Classes:
    PNCounterService

      public interface CRDTReplicationAwareService<T>

  Represents a service implementing a CRDT that may be replicated and migrated to other replicas of the same CRDT. The service may optimize the replication operation contents depending on the provided vector clocks. The vector clock map contains mappings from CRDT name to the last successfully replicated CRDT state version. All CRDTs in this map should be of the same type.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `clearCRDTState(Map<String,com.hazelcast.cluster.impl.VectorClock> vectorClocks)` Removes all of the CRDTs with vector clocks equal to the provided vector clocks.
    `String` | `getName()` Returns the name of the service
    `void` | `merge(String name, T value)` Performs a merge of the local `name` CRDT with the provided state.
    `CRDTReplicationContainer` | `prepareMigrationOperation(int maxConfiguredReplicaCount)` Returns a migration operation for all of the CRDT states not owned by this member.
    `CRDTReplicationContainer` | `prepareReplicationOperation(Map<String,com.hazelcast.cluster.impl.VectorClock> lastReplicatedVectorClock, int targetIndex)` Returns a replication operation for the provided vector clocks.
    `void` | `prepareToSafeShutdown()` Prepares the service for replication and shutdown.

- - ### Method Detail

    - #### prepareReplicationOperation

          CRDTReplicationContainer prepareReplicationOperation(Map<String,com.hazelcast.cluster.impl.VectorClock> lastReplicatedVectorClock,
                                                               int targetIndex)

      Returns a replication operation for the provided vector clocks. The vector clock map contains mappings from CRDT name to the last successfully replicated CRDT vector clock. All CRDTs in this map should be of the same type. A return value of `null` means that there should not be any replication operation.
      Parameters:
        `lastReplicatedVectorClock` - last successfully replicated vector clock
        `targetIndex` - the index of the replication target in the membership list containing only data members
      Returns:
        the replication operation and the replicated vector clocks

    - #### getName

          String getName()

      Returns the name of the service

    - #### merge

          void merge(String name,
                     T value)

      Performs a merge of the local `name` CRDT with the provided state.
      Parameters:
        `name` - the CRDT name
        `value` - the CRDT state to merge into the local state

    - #### prepareMigrationOperation

          CRDTReplicationContainer prepareMigrationOperation(int maxConfiguredReplicaCount)

      Returns a migration operation for all of the CRDT states not owned by this member.
      Parameters:
        `maxConfiguredReplicaCount` - the maximum configured replica count for the CRDTs to be migrated (excluding)
      Returns:
        the migration operation and the current vector clocks

    - #### clearCRDTState

          boolean clearCRDTState(Map<String,com.hazelcast.cluster.impl.VectorClock> vectorClocks)

      Removes all of the CRDTs with vector clocks equal to the provided vector clocks. The vector clock map contains mappings from CRDT name to a vector clock. All CRDTs in this map should be of the same type.
      Parameters:
        `vectorClocks` - a map from CRDT name to a vector clock
      Returns:
        `true` if all of the CRDT states have been cleared, `false` otherwise

    - #### prepareToSafeShutdown

          void prepareToSafeShutdown()

      Prepares the service for replication and shutdown. After this method has returned, no mutations must be allowed to any existing CRDT state in this service and new CRDT states must be disallowed.

Copyright © 2018. All rights reserved.