org.esbtools.eventhandler.lightblue.locking

Interface LockStrategy

  • All Known Implementing Classes:
    LightblueAutoPingLockStrategy


    public interface LockStrategy
    Abstracts an atomic exclusive locking mechanism which is used to coordinate concurrent work on logical "resources."
    • Method Detail

      • tryAcquire

        <T> LockedResource<T> tryAcquire(String resourceId,
                                         T resource)
                                  throws LockNotAvailableException
        Attempts to acquire a lock by the provided resourceId for the logical resource provided by resource.

        After a resource is locked, it is expected that nothing else can acquire it again until it is released (intentionally or not), no matter if it is the same thread, another thread, or across a network.

        Type Parameters:
        T - The type of the resource being acquired.
        Parameters:
        resourceId - A string which identifies the resource and only that resource.
        resource - A logically locked resource as a result of the id being locked. Participants must agree on a scheme of resourceIds to resources.
        Returns:
        A wrapper around the locked resource with methods to manage the acquired lock.
        Throws:
        LockNotAvailableException - If for whatever reason the lock could not be acquired. Generally this is simply because another client has the lock, but it could also be due to network failure, etc.

Copyright © 2017. All rights reserved.