public class HazelcastLockProvider extends java.lang.Object implements LockProvider
Implementation of LockProvider using Hazelcast for store and share locks informations and mechanisms between a cluster members
Below, the mechanims :
- The Lock, an instance of HazelcastLock, is obtained / created when :
-- the lock is not 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 objectis 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 and Description |
|---|
HazelcastLockProvider(com.hazelcast.core.HazelcastInstance hazelcastInstance)
Instantiate the provider.
|
HazelcastLockProvider(com.hazelcast.core.HazelcastInstance hazelcastInstance,
java.lang.String lockStoreKey)
Instantiate the provider.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Optional<SimpleLock> |
lock(LockConfiguration lockConfiguration) |
public HazelcastLockProvider(com.hazelcast.core.HazelcastInstance hazelcastInstance)
hazelcastInstance - The Hazelcast engine used by the application.public HazelcastLockProvider(com.hazelcast.core.HazelcastInstance hazelcastInstance,
java.lang.String lockStoreKey)
hazelcastInstance - The Hazelcast engine used by the applicationlockStoreKey - The key where the locks store is associate hazelcastInstance (by default LOCK_STORE_KEY_DEFAULT).public java.util.Optional<SimpleLock> lock(LockConfiguration lockConfiguration)
lock in interface LockProviderCopyright © 2018. All Rights Reserved.