Package org.opends.server.core
Class LockFileManager
- java.lang.Object
- 
- org.opends.server.core.LockFileManager
 
- 
 public final 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.
- 
- 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanacquireExclusiveLock(String lockFile, StringBuilder failureReason, DirectoryEnvironmentConfig environmentConfig)Attempts to acquire an exclusive lock on the specified file.static voidacquireExclusiveLockForBackend(String backendID, LocalizableMessageDescriptor.Arg2<Object,Object> failureMsg, DirectoryEnvironmentConfig environmentConfig)Attempts to acquire an exclusive lock on the specified backend ID.static booleanacquireSharedLock(String lockFile, StringBuilder failureReason, DirectoryEnvironmentConfig environmentConfig)Attempts to acquire a shared lock on the specified file.static voidacquireSharedLockForBackend(String backendID, LocalizableMessageDescriptor.Arg2<Object,Object> failureMsg, DirectoryEnvironmentConfig environmentConfig)Attempts to acquire an shared lock on the specified backend ID.static StringgetServerLockFileName(DirectoryEnvironmentConfig environmentConfig)Retrieves the filename that should be used for the lock file for the Directory Server instance.static voidreleaseBackendLock(String backendID, LocalizableMessageDescriptor.Arg2<Object,Object> failureMsg, DirectoryEnvironmentConfig environmentConfig)Attempts to release a lock on the backend id.static booleanreleaseLock(String lockFile, StringBuilder failureReason)Attempts to release the lock on the specified file.
 
- 
- 
- 
Method Detail- 
acquireSharedLockForBackendpublic static void acquireSharedLockForBackend(String backendID, LocalizableMessageDescriptor.Arg2<Object,Object> failureMsg, DirectoryEnvironmentConfig environmentConfig) throws LdapException Attempts to acquire an shared lock on the specified backend ID.- Parameters:
- backendID- The backend ID for which to obtain the shared lock.
- failureMsg- the message to use in case the backend lock cannot be obtained.
- environmentConfig- the environment config
- Throws:
- LdapException- if the shared lock could not be obtained.
 
 - 
acquireExclusiveLockForBackendpublic static void acquireExclusiveLockForBackend(String backendID, LocalizableMessageDescriptor.Arg2<Object,Object> failureMsg, DirectoryEnvironmentConfig environmentConfig) throws LdapException Attempts to acquire an exclusive lock on the specified backend ID.- Parameters:
- backendID- The backend ID for which to obtain the exclusive lock.
- failureMsg- the message to use in case the backend lock cannot be obtained.
- environmentConfig- the environment config
- Throws:
- LdapException- if the exclusive lock could not be obtained.
 
 - 
acquireSharedLockpublic static boolean acquireSharedLock(String lockFile, StringBuilder failureReason, DirectoryEnvironmentConfig environmentConfig) 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.
- environmentConfig- The environment config
- Returns:
- trueif the lock was obtained successfully, or- falseif it could not be obtained.
 
 - 
acquireExclusiveLockpublic static boolean acquireExclusiveLock(String lockFile, StringBuilder failureReason, DirectoryEnvironmentConfig environmentConfig) 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.
- environmentConfig- The environment config
- Returns:
- trueif the lock was obtained successfully, or- falseif it could not be obtained.
 
 - 
releaseBackendLockpublic static void releaseBackendLock(String backendID, LocalizableMessageDescriptor.Arg2<Object,Object> failureMsg, DirectoryEnvironmentConfig environmentConfig) throws LdapException Attempts to release a lock on the backend id. 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:
- backendID- The backend ID for which to release the associated lock.
- failureMsg- the message to use in case the backe3nd lock cannot be released.
- environmentConfig- the environment config
- Throws:
- LdapException- if a problem occurred that might have prevented the lock from being released.
 
 - 
releaseLockpublic 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, or- falseif a problem occurred that might have prevented the lock from being released.
 
 - 
getServerLockFileNamepublic static String getServerLockFileName(DirectoryEnvironmentConfig environmentConfig) Retrieves the filename that should be used for the lock file for the Directory Server instance.- Parameters:
- environmentConfig- the environment config
- Returns:
- The filename that should be used for the lock file for the Directory Server instance.
 
 
- 
 
-