Class HazelcastLockProvider

java.lang.Object
net.javacrumbs.shedlock.provider.hazelcast4.HazelcastLockProvider
All Implemented Interfaces:
LockProvider

public class HazelcastLockProvider extends Object implements LockProvider
HazelcastLockProvider.

Implementation of LockProvider using Hazelcast for storing and sharing lock information and mechanisms between a cluster's members

Below, the mechanisms : - The Lock, an instance of HazelcastLock, is obtained / created when : -- the lock is not already locked by other process (lock - referenced by its name - is not present in the Hazelcast locks store OR unlockable) -- the lock is expired : Instant.now() > HazelcastLock.timeToLive where unlockTime have by default the same value of HazelcastLock.lockAtMostUntil and can have the value of HazelcastLock.lockAtLeastUntil if unlock action is used --- expired object is removed -- the lock is owned by not available member of Hazelcast cluster member --- no owner object is removed - Unlock action : -- removes lock object when HazelcastLock.lockAtLeastUntil is not come -- override value of HazelcastLock.timeToLive with HazelcastLock.lockAtLeastUntil (its default value is the same of HazelcastLock.lockAtLeastUntil

  • Constructor Details

    • HazelcastLockProvider

      public HazelcastLockProvider(com.hazelcast.core.HazelcastInstance hazelcastInstance)
      Instantiate the provider.
      Parameters:
      hazelcastInstance - The Hazelcast engine used by the application.
    • HazelcastLockProvider

      public HazelcastLockProvider(com.hazelcast.core.HazelcastInstance hazelcastInstance, String lockStoreKey)
      Instantiate the provider.
      Parameters:
      hazelcastInstance - The Hazelcast engine used by the application
      lockStoreKey - The key where the locks are stored (by default LOCK_STORE_KEY_DEFAULT).
    • HazelcastLockProvider

      public HazelcastLockProvider(com.hazelcast.core.HazelcastInstance hazelcastInstance, String lockStoreKey, Duration lockLeaseTime)
      Instantiate the provider.
      Parameters:
      hazelcastInstance - The com.hazelcast.core.Hazelcast engine used by the application
      lockStoreKey - The key where the locks are stored (by default LOCK_STORE_KEY_DEFAULT).
      lockLeaseTime - When lock is being obtained there is a Hazelcast lock used to make it thread-safe. This lock should be released quite fast but if the process dies while holding the lock, it is held forever. lockLeaseTime is used as a safety-net for such situations.
  • Method Details