public class DirLock extends Object
Facility to synchronize access to HDFS directory. The lock itself is represented as a file in the same directory. Relies on atomic file creation.
Modifier and Type | Field and Description |
---|---|
static String |
DIR_LOCK_FILE |
Modifier and Type | Method and Description |
---|---|
org.apache.hadoop.fs.Path |
getLockFile() |
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
|
public static final String DIR_LOCK_FILE
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
fs
- dir
- the dir on which to get a lockIOException
- if there were errorspublic 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
public void release() throws IOException
Release lock on dir by deleting the lock file
IOException
public org.apache.hadoop.fs.Path getLockFile()
Copyright © 2019 The Apache Software Foundation. All rights reserved.