Package org.opends.server.core
Class LockFileManager
- java.lang.Object
-
- org.opends.server.core.LockFileManager
-
public class LockFileManager extends Object
This class provides a mechanism for allowing the Directory Server to utilize file locks as provided by the underlying OS. File locks may be exclusive or shared, and will be visible between different processes on the same system.
-
-
Constructor Summary
Constructors Constructor Description LockFileManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanacquireExclusiveLock(String lockFile, StringBuilder failureReason)Attempts to acquire an exclusive lock on the specified file.static booleanacquireSharedLock(String lockFile, StringBuilder failureReason)Attempts to acquire a shared lock on the specified file.static StringgetBackendLockFileName(Backend backend)Retrieves the filename that should be used for the lock file for the specified backend.static StringgetLockDirectoryPath()Retrieves the path to the directory that should be used to hold the lock files.static StringgetServerLockFileName()Retrieves the filename that should be used for the lock file for the Directory Server instance.static booleanreleaseLock(String lockFile, StringBuilder failureReason)Attempts to release the lock on the specified file.
-
-
-
Method Detail
-
acquireSharedLock
public static boolean acquireSharedLock(String lockFile, StringBuilder failureReason)
Attempts to acquire a shared lock on the specified file.- Parameters:
lockFile- The file for which to obtain the shared lock.failureReason- A buffer that can be used to hold a reason that the lock could not be acquired.- Returns:
trueif the lock was obtained successfully, orfalseif it could not be obtained.
-
acquireExclusiveLock
public static boolean acquireExclusiveLock(String lockFile, StringBuilder failureReason)
Attempts to acquire an exclusive lock on the specified file.- Parameters:
lockFile- The file for which to obtain the exclusive lock.failureReason- A buffer that can be used to hold a reason that the lock could not be acquired.- Returns:
trueif the lock was obtained successfully, orfalseif it could not be obtained.
-
releaseLock
public static boolean releaseLock(String lockFile, StringBuilder failureReason)
Attempts to release the lock on the specified file. If an exclusive lock is held, then it will be released. If a shared lock is held, then its reference count will be reduced, and the lock will be released if the resulting reference count is zero. If we don't know anything about the requested file, then don't do anything.- Parameters:
lockFile- The file for which to release the associated lock.failureReason- A buffer that can be used to hold information about a problem that occurred preventing the successful release.- Returns:
trueif the lock was found and released successfully, orfalseif a problem occurred that might have prevented the lock from being released.
-
getLockDirectoryPath
public static String getLockDirectoryPath()
Retrieves the path to the directory that should be used to hold the lock files.- Returns:
- The path to the directory that should be used to hold the lock files.
-
getServerLockFileName
public static String getServerLockFileName()
Retrieves the filename that should be used for the lock file for the Directory Server instance.- Returns:
- The filename that should be used for the lock file for the Directory Server instance.
-
getBackendLockFileName
public static String getBackendLockFileName(Backend backend)
Retrieves the filename that should be used for the lock file for the specified backend.- Parameters:
backend- The backend for which to retrieve the filename for the lock file.- Returns:
- The filename that should be used for the lock file for the specified backend.
-
-