Package de.hybris.platform.core.system
Class InitializationLockHandler
- java.lang.Object
-
- de.hybris.platform.core.system.InitializationLockHandler
-
- All Implemented Interfaces:
java.io.Serializable
public class InitializationLockHandler extends java.lang.Object implements java.io.SerializableGlobal initialization locking handler.By now locking happens using one table inside the master tenant database containing one row that holds the current global initialization locking status.
This has some consequences:
- only one instance if able to acquire that lock
- only one tenant at a time may be initialized
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description InitializationLockHandler(InitializationLockDao initializationDao)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InitializationLockInfogetLockInfo()Gives detailed init lock information.booleanisLocked()Tells whether init lock is being taken or not.booleanlock(Tenant forTenant, java.lang.String message)Tries to acquires global lock.booleanperformLocked(Tenant forTenant, java.util.concurrent.Callable<java.lang.Boolean> operation, java.lang.String message)Allows to performs some operation while holding the init lock.voidunlock(Tenant forTenant)Releases acquired lock previously fetched vialock(Tenant, String).
-
-
-
Constructor Detail
-
InitializationLockHandler
public InitializationLockHandler(InitializationLockDao initializationDao)
-
-
Method Detail
-
getLockInfo
public InitializationLockInfo getLockInfo()
Gives detailed init lock information.
-
isLocked
public boolean isLocked()
Tells whether init lock is being taken or not.
-
performLocked
public boolean performLocked(Tenant forTenant, java.util.concurrent.Callable<java.lang.Boolean> operation, java.lang.String message) throws java.lang.Exception
Allows to performs some operation while holding the init lock. After successful acquiring of the lock the operation is being performed and finally the lock is being released.- Returns:
falseif lock could not be acquired and operation was not performed,trueif lock had been acquired and operation had been performed.- Throws:
java.lang.Exception- from givenoperationCallable- See Also:
lock(Tenant, String),unlock(Tenant)
-
lock
public boolean lock(Tenant forTenant, java.lang.String message)
Tries to acquires global lock. After this call no other cluster node will be able to acquire it untilunlock(Tenant)had been called.Given
messagewill be set as the purpose of lock it might be initialization/update of the platform.Please note that a lock can only be acquired once, so also no other thread on the same cluster node will be able to acquire it again!
- Returns:
trueif global lock had been taken,falseotherwise
-
unlock
public void unlock(Tenant forTenant)
Releases acquired lock previously fetched vialock(Tenant, String). Only the cluster node acquiring it is able to do that!
-
-