Class ReactorSherlockStub

    • Constructor Detail

      • ReactorSherlockStub

        public ReactorSherlockStub()
    • Method Detail

      • withReleasedLocks

        public static ReactorSherlockStub withReleasedLocks()
        Make the stub produce released locks by default
        Returns:
        the instance
      • withAcquiredLocks

        public static ReactorSherlockStub withAcquiredLocks()
        Make the stub produce acquired locks by default
        Returns:
        the instance
      • withLock

        public ReactorSherlockStub withLock​(ReactorDistributedLock lock)
        Make the stub produce return a predefined lock.
        Parameters:
        lock - returned when creating a lock with the same id
        Returns:
        the instance
      • initialize

        public reactor.core.publisher.Mono<com.coditory.sherlock.connector.InitializationResult> initialize()
        Description copied from interface: ReactorSherlock
        Initializes underlying infrastructure. If this method is not invoked explicitly then it can be invoked implicitly when acquiring or releasing a lock for the first time.

        Most often initialization is related with creating indexes and tables.

        Specified by:
        initialize in interface ReactorSherlock
        Returns:
        InitializationResult.SUCCESS if initialization was successful, otherwise InitializationResult.FAILURE is returned
      • createLock

        public com.coditory.sherlock.DistributedLockBuilder<ReactorDistributedLock> createLock()
        Description copied from interface: ReactorSherlock
        Creates a distributed lock. Created lock may be acquired only once by the same owner:
        
         assert lock.acquire() == true
         assert lock.acquire() == false
         
        Specified by:
        createLock in interface ReactorSherlock
        Returns:
        the lock builder
      • createReentrantLock

        public com.coditory.sherlock.DistributedLockBuilder<ReactorDistributedLock> createReentrantLock()
        Description copied from interface: ReactorSherlock
        Creates a distributed reentrant lock. Reentrant lock may be acquired multiple times by the same owner:
        
         assert reentrantLock.acquire() == true
         assert reentrantLock.acquire() == true
         
        Specified by:
        createReentrantLock in interface ReactorSherlock
        Returns:
        the reentrant lock builder
      • createOverridingLock

        public com.coditory.sherlock.DistributedLockBuilder<ReactorDistributedLock> createOverridingLock()
        Description copied from interface: ReactorSherlock
        Create a distributed overriding lock. Returned lock may acquire or release any other lock without checking its state:
        
         assert someLock.acquire() == true
         assert overridingLock.acquire() == true
         

        It could be used for administrative actions.

        Specified by:
        createOverridingLock in interface ReactorSherlock
        Returns:
        the overriding lock builder
      • forceReleaseAllLocks

        public reactor.core.publisher.Mono<com.coditory.sherlock.connector.ReleaseResult> forceReleaseAllLocks()
        Description copied from interface: ReactorSherlock
        Force releases all acquired locks.

        It could be used for administrative actions.

        Specified by:
        forceReleaseAllLocks in interface ReactorSherlock
        Returns:
        ReleaseResult.SUCCESS if lock was released, otherwise ReleaseResult.FAILURE is returned