Package org.apache.nutch.util
Class LockUtil
java.lang.Object
org.apache.nutch.util.LockUtil
Utility methods for handling application-level locking.
- Author:
- Andrzej Bialecki
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateLockFile(Configuration conf, Path lockFile, boolean accept) Create a lock file.static voidcreateLockFile(FileSystem fs, Path lockFile, boolean accept) Create a lock file.static booleanremoveLockFile(Configuration conf, Path lockFile) Remove lock file.static booleanremoveLockFile(FileSystem fs, Path lockFile) Remove lock file.
-
Constructor Details
-
LockUtil
public LockUtil()
-
-
Method Details
-
createLockFile
Create a lock file.- Parameters:
fs- filesystemlockFile- name of the lock fileaccept- if true, and the target file exists, consider it valid. If false and the target file exists, throw an IOException.- Throws:
IOException- if accept is false, and the target file already exists, or if it's a directory.
-
createLockFile
public static void createLockFile(Configuration conf, Path lockFile, boolean accept) throws IOException Create a lock file.- Parameters:
conf- configuration to find theFileSystemlockFile belongs tolockFile- name of the lock fileaccept- if true, and the target file exists, consider it valid. If false and the target file exists, throw an IOException.- Throws:
IOException- if accept is false, and the target file already exists, or if it's a directory.
-
removeLockFile
Remove lock file. NOTE: applications enforce the semantics of this file - this method simply removes any file with a given name.- Parameters:
fs- filesystemlockFile- lock file name- Returns:
- false, if the lock file doesn't exist. True, if it existed and was successfully removed.
- Throws:
IOException- if lock file exists but it is a directory.
-
removeLockFile
Remove lock file. NOTE: applications enforce the semantics of this file - this method simply removes any file with a given name.- Parameters:
conf- configuration to find theFileSystemlockFile belongs tolockFile- lock file name- Returns:
- false, if the lock file doesn't exist. True, if it existed and was successfully removed.
- Throws:
IOException- if lock file exists but it is a directory.
-