@NotThreadSafe
public class WriteLock
extends java.lang.Object
implements java.lang.AutoCloseable
Modifier and Type | Field and Description |
---|---|
static int |
MAX_SLEEP_COUNT
Max attempts to obtain a lock.
|
static int |
SLEEP_DURATION
How long to sleep waiting for the lock.
|
Constructor and Description |
---|
WriteLock(Settings settings)
Constructs a new Write Lock object with the configured settings.
|
WriteLock(Settings settings,
boolean isLockable)
Constructs a new Write Lock object with the configured settings.
|
WriteLock(Settings settings,
boolean isLockable,
java.lang.String lockFileName)
Constructs a new Write Lock object with the configured settings.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Releases the lock on the resource.
|
void |
lock()
Obtains a lock on the resource.
|
public static final int SLEEP_DURATION
public static final int MAX_SLEEP_COUNT
public WriteLock(Settings settings) throws WriteLockException
settings
- the configured settingsWriteLockException
- thrown if a lock could not be obtainedpublic WriteLock(Settings settings, boolean isLockable) throws WriteLockException
settings
- the configured settingsisLockable
- a flag indicating if a lock can be obtained for the
resource; if false the lock does nothing. This is useful in the case of
ODC where we need to lock for updates against H2 but we do not need to
lock updates for other databases.WriteLockException
- thrown if a lock could not be obtainedpublic WriteLock(Settings settings, boolean isLockable, java.lang.String lockFileName) throws WriteLockException
settings
- the configured settingsisLockable
- a flag indicating if a lock can be obtained for the
resource; if false the lock does nothing. This is useful in the case of
ODC where we need to lock for updates against H2 but we do not need to
lock updates for other databases.lockFileName
- the name of the lock file; note the lock file will be
in the ODC data directory.WriteLockException
- thrown if a lock could not be obtainedpublic final void lock() throws WriteLockException
WriteLockException
- thrown if a lock could not be obtainedpublic void close()
close
in interface java.lang.AutoCloseable
Copyright© 2012-21 Jeremy Long. All Rights Reserved.