Class 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 Detail

      • LockFileManager

        public LockFileManager()
    • 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:
        true if the lock was obtained successfully, or false if 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:
        true if the lock was obtained successfully, or false if 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:
        true if the lock was found and released successfully, or false if 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.