Class InitializationLockHandler

  • All Implemented Interfaces:
    java.io.Serializable

    public class InitializationLockHandler
    extends java.lang.Object
    implements java.io.Serializable
    Global 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 Detail

      • InitializationLockHandler

        public InitializationLockHandler​(InitializationLockDao initializationDao)
    • Method Detail

      • 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:
        false if lock could not be acquired and operation was not performed, true if lock had been acquired and operation had been performed.
        Throws:
        java.lang.Exception - from given operation Callable
        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 until unlock(Tenant) had been called.

        Given message will 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:
        true if global lock had been taken, false otherwise
      • unlock

        public void unlock​(Tenant forTenant)
        Releases acquired lock previously fetched via lock(Tenant, String). Only the cluster node acquiring it is able to do that!