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 SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionorg.apache.hadoop.fs.Pathvoidrelease()Release lock on dir by deleting the lock file.static DirLocktakeOwnershipIfStale(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 DirLocktryLock(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- 
tryLockpublic 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
 
- 
takeOwnershipIfStalepublic 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.
- 
releaseRelease lock on dir by deleting the lock file.- Throws:
- IOException
 
- 
getLockFilepublic org.apache.hadoop.fs.Path getLockFile()
 
-