org.apache.nutch.util
Class LockUtil
- java.lang.Object
- org.apache.nutch.util.LockUtil
public class LockUtil extends Object
Utility methods for handling application-level locking.
- Author:
- Andrzej Bialecki
Constructor Summary
Constructors Constructor and Description LockUtil()
Method Summary
Methods Modifier and Type Method and Description static void
createLockFile(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path lockFile,
boolean accept)
Create a lock file.
static boolean
removeLockFile(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path lockFile)
Remove lock file.
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
-
LockUtil
public LockUtil()
Method Detail
-
createLockFile
public static void createLockFile(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path lockFile, boolean accept) throws IOException
Create a lock file.
- Parameters:
- <code>fs</code> - filesystem
- <code>lockFile</code> - name of the lock file
- <code>accept</code> - if true, and the target file exists, consider it valid. If false and the target file exists, throw an IOException.
- Throws:
- <code>IOException</code> - if accept is false, and the target file already exists, or if it's a directory.
-
removeLockFile
public static boolean removeLockFile(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path lockFile) throws IOException
Remove lock file. NOTE: applications enforce the semantics of this file - this method simply removes any file with a given name.
- Parameters:
- <code>fs</code> - filesystem
- <code>lockFile</code> - lock file name
- Returns:
- false, if the lock file doesn't exist. True, if it existed and was successfully removed.
- Throws:
- <code>IOException</code> - if lock file exists but it is a directory.