com.hazelcast.concurrent.lock

## Class LockServiceImpl

- java.lang.Object
- - com.hazelcast.concurrent.lock.LockServiceImpl

- All Implemented Interfaces:
    LockService, ClientAwareService, FragmentedMigrationAwareService, ManagedService, MembershipAwareService, MigrationAwareService, QuorumAwareService, RemoteService, SharedService

      public final class LockServiceImpl
      extends Object
      implements LockService, ManagedService, RemoteService, MembershipAwareService, FragmentedMigrationAwareService, ClientAwareService, QuorumAwareService

- - ### Field Summary

    - ### Fields inherited from interface com.hazelcast.concurrent.lock.LockService

      `SERVICE_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LockServiceImpl(NodeEngine nodeEngine)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `beforeMigration(PartitionMigrationEvent partitionMigrationEvent)` Called before migration process starts, on both source and destination members.
    `void` | `clearLockStore(int partitionId, ObjectNamespace namespace)`
    `void` | `clientDisconnected(String clientUuid)` Invoked when a client disconnects from a member.
    `void` | `commitMigration(PartitionMigrationEvent event)` Commits the migration process for this service, on both source and destination members.
    `DistributedObject` | `createDistributedObject(String objectId)` Creates a distributed object.
    `LockStore` | `createLockStore(int partitionId, ObjectNamespace namespace)`
    `void` | `destroyDistributedObject(String objectId)` Destroys a distributed object.
    `Collection<LockResource>` | `getAllLocks()`
    `Collection<ServiceNamespace>` | `getAllServiceNamespaces(PartitionReplicationEvent event)` Returns all known namespaces for given replication event.
    `LockStoreContainer` | `getLockContainer(int partitionId)`
    `LockStoreImpl` | `getLockStore(int partitionId, ObjectNamespace namespace)`
    `long` | `getMaxLeaseTimeInMillis()`
    `static long` | `getMaxLeaseTimeInMillis(HazelcastProperties hazelcastProperties)`
    `String` | `getQuorumName(String name)` Gets the name of the quorum associated with specified operation name.
    `void` | `init(NodeEngine nodeEngine, Properties properties)` Initializes this service.
    `boolean` | `isKnownServiceNamespace(ServiceNamespace namespace)` Returns true if namespace is known by this service, false otherwise
    `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.
    `Operation` | `prepareReplicationOperation(PartitionReplicationEvent event)` Returns an operation to replicate service data and/or state for a specific partition replica on another cluster member.
    `Operation` | `prepareReplicationOperation(PartitionReplicationEvent event, Collection<ServiceNamespace> namespaces)` Returns an operation to replicate service data and/or state for a specific partition replica and namespaces on another cluster member.
    `void` | `registerLockStoreConstructor(String serviceName, ConstructorFunction<ObjectNamespace,LockStoreInfo> constructorFunction)`
    `void` | `reset()` Resets this service back to its initial state.
    `void` | `rollbackMigration(PartitionMigrationEvent event)` Rollback the migration process for this service, on both source and destination members.
    `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`

- - ### Constructor Detail

    - #### LockServiceImpl

          public LockServiceImpl(NodeEngine nodeEngine)

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

    - #### getMaxLeaseTimeInMillis

          public long getMaxLeaseTimeInMillis()

      Specified by:
        `getMaxLeaseTimeInMillis` in interface `LockService`

    - #### registerLockStoreConstructor

          public void registerLockStoreConstructor(String serviceName,
                                                   ConstructorFunction<ObjectNamespace,LockStoreInfo> constructorFunction)

      Specified by:
        `registerLockStoreConstructor` in interface `LockService`

    - #### createLockStore

          public LockStore createLockStore(int partitionId,
                                           ObjectNamespace namespace)

      Specified by:
        `createLockStore` in interface `LockService`

    - #### clearLockStore

          public void clearLockStore(int partitionId,
                                     ObjectNamespace namespace)

      Specified by:
        `clearLockStore` in interface `LockService`

    - #### getLockContainer

          public LockStoreContainer getLockContainer(int partitionId)

    - #### getLockStore

          public LockStoreImpl getLockStore(int partitionId,
                                            ObjectNamespace namespace)

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

    - #### getAllLocks

          public Collection<LockResource> getAllLocks()

      Specified by:
        `getAllLocks` in interface `LockService`

    - #### getAllServiceNamespaces

          public Collection<ServiceNamespace> getAllServiceNamespaces(PartitionReplicationEvent event)

      Description copied from interface: `FragmentedMigrationAwareService`
      Returns all known namespaces for given replication event.
      Specified by:
        `getAllServiceNamespaces` in interface `FragmentedMigrationAwareService`
      Parameters:
        `event` - replication event
      Returns:
        all known service namespaces for the replication

    - #### isKnownServiceNamespace

          public boolean isKnownServiceNamespace(ServiceNamespace namespace)

      Description copied from interface: `FragmentedMigrationAwareService`
      Returns true if namespace is known by this service, false otherwise
      Specified by:
        `isKnownServiceNamespace` in interface `FragmentedMigrationAwareService`
      Parameters:
        `namespace` - namespace
      Returns:
        true if namespace is known by this service, false otherwise

    - #### beforeMigration

          public void beforeMigration(PartitionMigrationEvent partitionMigrationEvent)

      Description copied from interface: `MigrationAwareService`
      Called before migration process starts, on both source and destination members.

      Service can take actions required before migration. Migration process will block until this method returns. If this method fails by throwing an exception, migration process for specific partition will fail and will be rolled back.

      Specified by:
        `beforeMigration` in interface `MigrationAwareService`
      Parameters:
        `partitionMigrationEvent` - migration event

    - #### prepareReplicationOperation

          public Operation prepareReplicationOperation(PartitionReplicationEvent event)

      Description copied from interface: `MigrationAwareService`
      Returns an operation to replicate service data and/or state for a specific partition replica on another cluster member.

      This method will be called on source member whenever partitioning system requires to copy/replicate a partition replica. Returned operation will be executed on destination member. If operation fails by throwing exception, migration process will fail and will be rolled back.

      Returning null is allowed and means service does not have anything to replicate.

      Specified by:
        `prepareReplicationOperation` in interface `MigrationAwareService`
      Parameters:
        `event` - replication
      Returns:
        replication operation or null if nothing will be replicated

    - #### prepareReplicationOperation

          public Operation prepareReplicationOperation(PartitionReplicationEvent event,
                                                       Collection<ServiceNamespace> namespaces)

      Description copied from interface: `FragmentedMigrationAwareService`
      Returns an operation to replicate service data and/or state for a specific partition replica and namespaces on another cluster member. This method is very similar to `MigrationAwareService.prepareReplicationOperation(PartitionReplicationEvent)`, instead of copying whole partition replica, allows copying only some portion of replica, specified by given namespaces.

      This method will be called on source member whenever partitioning system requires to copy/replicate a partition replica. Returned operation will be executed on destination member. If operation fails by throwing exception, migration process will fail and will be rolled back.

      Returning null is allowed and means service does not have anything to replicate.

      Specified by:
        `prepareReplicationOperation` in interface `FragmentedMigrationAwareService`
      Parameters:
        `event` - replication event
        `namespaces` - replica fragment namespaces to replicate
      Returns:
        replication operation or null if nothing will be replicated
      See Also:
        `MigrationAwareService.prepareReplicationOperation(PartitionReplicationEvent)`

    - #### commitMigration

          public void commitMigration(PartitionMigrationEvent event)

      Description copied from interface: `MigrationAwareService`
      Commits the migration process for this service, on both source and destination members. This method will be called after all replication operations are executed successfully on destination and master member receives success response from all participants.

      Commit is not expected to fail at this point, all exceptions will be suppressed and logged. Implementations of this method must be thread safe as this method may be called concurrently for different migrations on different partitions.

      Specified by:
        `commitMigration` in interface `MigrationAwareService`
      Parameters:
        `event` - migration event

    - #### rollbackMigration

          public void rollbackMigration(PartitionMigrationEvent event)

      Description copied from interface: `MigrationAwareService`
      Rollback the migration process for this service, on both source and destination members. This method will be called when migration process fails at any moment. Reasons for failure may be an exception thrown on any migration step or failure(s) of any of the migration participants; either master or source or destination.

      Rollback is not expected to fail at this point, all exceptions will be suppressed and logged. Implementations of this method must be thread safe as this method may be called concurrently for different migrations on different partitions.

      Specified by:
        `rollbackMigration` in interface `MigrationAwareService`
      Parameters:
        `event` - migration event

    - #### createDistributedObject

          public DistributedObject createDistributedObject(String objectId)

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

    - #### destroyDistributedObject

          public void destroyDistributedObject(String objectId)

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

    - #### clientDisconnected

          public void clientDisconnected(String clientUuid)

      Description copied from interface: `ClientAwareService`
      Invoked when a client disconnects from a member.
      Specified by:
        `clientDisconnected` in interface `ClientAwareService`
      Parameters:
        `clientUuid` - the UUID of the client that disconnected from a member

    - #### getMaxLeaseTimeInMillis

          public static long getMaxLeaseTimeInMillis(HazelcastProperties hazelcastProperties)

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

Copyright © 2020. All rights reserved.