Package org.apache.storm.hdfs.spout
Class DirLock
java.lang.Object
org.apache.storm.hdfs.spout.DirLock
Facility to synchronize access to HDFS directory. The lock itself is represented
as a file in the same directory. Relies on atomic file creation.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.fs.Path
void
release()
Release lock on dir by deleting the lock file.static DirLock
takeOwnershipIfStale
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dirToLock, int lockTimeoutSec) if the lock on the directory is stale, take ownership.static DirLock
tryLock
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir) Get a lock on file if not already locked.
-
Field Details
-
DIR_LOCK_FILE
- See Also:
-
-
Method Details
-
tryLock
public static DirLock tryLock(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dir) throws IOException Get a lock on file if not already locked.- Parameters:
dir
- the dir on which to get a lock- Returns:
- The lock object if it the lock was acquired. Returns null if the dir is already locked.
- Throws:
IOException
- if there were errors
-
takeOwnershipIfStale
public static DirLock takeOwnershipIfStale(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path dirToLock, int lockTimeoutSec) if the lock on the directory is stale, take ownership. -
release
Release lock on dir by deleting the lock file.- Throws:
IOException
-
getLockFile
public org.apache.hadoop.fs.Path getLockFile()
-