com.hazelcast.crdt.pncounter

## Class PNCounterService

- java.lang.Object
- - com.hazelcast.crdt.pncounter.PNCounterService

- All Implemented Interfaces:
    CRDTReplicationAwareService<PNCounterImpl>, ManagedService, QuorumAwareService, RemoteService, StatisticsAwareService<LocalPNCounterStats>

      public class PNCounterService
      extends Object
      implements ManagedService, RemoteService, CRDTReplicationAwareService<PNCounterImpl>, QuorumAwareService, StatisticsAwareService<LocalPNCounterStats>

  Service responsible for `PNCounter` proxies and replication operation.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `SERVICE_NAME` The name under which this service is registered

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PNCounterService()`

  - ### Method Summary

    All Methods Instance Methods Concrete 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.
    `boolean` | `containsCounter(String name)` Returns `true` if the CRDT state for the PN counter with the given `name` is present on this node.
    `PNCounterProxy` | `createDistributedObject(String objectName)` Creates a distributed object.
    `void` | `destroyDistributedObject(String objectName)` Destroys a distributed object.
    `PNCounterImpl` | `getCounter(String name)` Returns the counter with the given `name`.
    `com.hazelcast.monitor.impl.LocalPNCounterStatsImpl` | `getLocalPNCounterStats(String name)` Returns the PN counter statistics for the counter with the given `name`
    `String` | `getName()` Returns the name of the service
    `String` | `getQuorumName(String name)` Gets the name of the quorum associated with specified operation name.
    `Map<String,LocalPNCounterStats>` | `getStats()` Return the service statistics for the local instance.
    `void` | `init(NodeEngine nodeEngine, Properties properties)` Initializes this service.
    `void` | `merge(String name, PNCounterImpl 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> previouslyReplicatedVectorClocks, int targetIndex)` Returns a replication operation for the provided vector clocks.
    `void` | `prepareToSafeShutdown()` Prepares the service for replication and shutdown.
    `void` | `reset()` Resets this service back to its initial state.
    `void` | `shutdown(boolean terminate)` Shuts down this service.

    - ### 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 under which this service is registered
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PNCounterService

          public PNCounterService()

  - ### Method Detail

    - #### getCounter

          public PNCounterImpl getCounter(String name)

      Returns the counter with the given `name`.

    - #### containsCounter

          public boolean containsCounter(String name)

      Returns `true` if the CRDT state for the PN counter with the given `name` is present on this node.
      Parameters:
        `name` - the PN counter name

    - #### getLocalPNCounterStats

          public com.hazelcast.monitor.impl.LocalPNCounterStatsImpl getLocalPNCounterStats(String name)

      Returns the PN counter statistics for the counter with the given `name`

    - #### 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

    - #### createDistributedObject

          public PNCounterProxy createDistributedObject(String objectName)

      Description copied from interface: `RemoteService`
      Creates a distributed object.
      Specified by:
        `createDistributedObject` in interface `RemoteService`
      Parameters:
        `objectName` - the name for the created distributed object
      Returns:
        the created distributed object

    - #### destroyDistributedObject

          public void destroyDistributedObject(String objectName)

      Description copied from interface: `RemoteService`
      Destroys a distributed object.
      Specified by:
        `destroyDistributedObject` in interface `RemoteService`
      Parameters:
        `objectName` - the name of the distributed object to destroy

    - #### prepareReplicationOperation

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

      Description copied from interface: `CRDTReplicationAwareService`
      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.
      Specified by:
        `prepareReplicationOperation` in interface `CRDTReplicationAwareService<PNCounterImpl>`
      Parameters:
        `previouslyReplicatedVectorClocks` - 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

          public String getName()

      Description copied from interface: `CRDTReplicationAwareService`
      Returns the name of the service
      Specified by:
        `getName` in interface `CRDTReplicationAwareService<PNCounterImpl>`

    - #### merge

          public void merge(String name,
                            PNCounterImpl value)

      Description copied from interface: `CRDTReplicationAwareService`
      Performs a merge of the local `name` CRDT with the provided state.
      Specified by:
        `merge` in interface `CRDTReplicationAwareService<PNCounterImpl>`
      Parameters:
        `name` - the CRDT name
        `value` - the CRDT state to merge into the local state

    - #### prepareMigrationOperation

          public CRDTReplicationContainer prepareMigrationOperation(int maxConfiguredReplicaCount)

      Description copied from interface: `CRDTReplicationAwareService`
      Returns a migration operation for all of the CRDT states not owned by this member.
      Specified by:
        `prepareMigrationOperation` in interface `CRDTReplicationAwareService<PNCounterImpl>`
      Parameters:
        `maxConfiguredReplicaCount` - the maximum configured replica count for the CRDTs to be migrated (excluding)
      Returns:
        the migration operation and the current vector clocks

    - #### clearCRDTState

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

      Description copied from interface: `CRDTReplicationAwareService`
      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.
      Specified by:
        `clearCRDTState` in interface `CRDTReplicationAwareService<PNCounterImpl>`
      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

          public void prepareToSafeShutdown()

      Description copied from interface: `CRDTReplicationAwareService`
      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.
      Specified by:
        `prepareToSafeShutdown` in interface `CRDTReplicationAwareService<PNCounterImpl>`

    - #### getQuorumName

          public String getQuorumName(String name)

      Description copied from interface: `QuorumAwareService`
      Gets the name of the quorum associated with specified operation name.
      Specified by:
        `getQuorumName` in interface `QuorumAwareService`
      Parameters:
        `name` - the operation name for which the quorum name is retured
      Returns:
        name of the associated quorum, null if there is no associated quorum

    - #### getStats

          public Map<String,LocalPNCounterStats> getStats()

      Description copied from interface: `StatisticsAwareService`
      Return the service statistics for the local instance.
      Specified by:
        `getStats` in interface `StatisticsAwareService<LocalPNCounterStats>`
      Returns:
        the statistics, grouped by distributed object name

Copyright © 2018. All rights reserved.