-
Notifications
You must be signed in to change notification settings - Fork 434
Shared Lock
oldratlee edited this page Apr 8, 2013
·
3 revisions
Fully distributed locks that are globally synchronous, meaning at any snapshot in time no two clients think they hold the same lock. Note: unlike InterProcessMutex this lock is not reentrant.
- InterProcessSemaphoreMutex
public InterProcessSemaphoreMutex(CuratorFramework client,
String path)
Parameters:
client - client
path - the path to lock
To acquire the lock, use one of the acquire methods:
public void acquire()
Acquire the mutex - blocking until it's available. Must be balanced by a call to release().
public boolean acquire(long time,
TimeUnit unit)
Acquire the mutex - blocks until it's available or the given time expires. Must be balanced by a call to release().
Parameters:
time - time to wait
unit - time unit
Returns:
true if the mutex was acquired, false if not
To release the mutex, call:
public void release()
Perform one release of the mutex if the calling thread is the same thread that acquired it.
It is strongly recommended that you add a ConnectionStateListener
and watch for SUSPENDED
and LOST
state changes. If a SUSPENDED
state is reported you cannot be certain that you still hold the lock unless you subsequently receive a RECONNECTED
state. If a LOST
state is reported it is certain that you no longer hold the lock.
- Curator
- Javadoc
- Coverage Report
- Getting Started
- Examples
- FAQ
- Client
- Framework
-
Recipes
- Leader Latch
- Leader Election
- Shared Reentrant Lock
- Shared Lock
- Shared Reentrant Read Write Lock
- Shared Semaphore
- Multi Shared Lock
- Distributed Queue
- Distributed Id Queue
- Distributed Priority Queue
- Distributed Delay Queue
- Simple Distributed Queue
- Barrier
- Double Barrier
- Shared counter
- Distributed Atomic Long
- Path Cache
- Node Cache
- Utilities – Test Server, Test Cluster, ZKPaths, EnsurePath, QueueSharder, Reaper, ChildReaper
- Tech Notes
- Errors
- Exhibitor Integration
- Extensions
- Logging and Tracing