public class FileLock extends Object
Modifier and Type | Class and Description |
---|---|
static class |
FileLock.LogEntry |
Modifier and Type | Method and Description |
---|---|
static FileLock |
acquireOldestExpiredLock(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path lockFilesDir,
int locktimeoutSec,
String spoutId)
Finds a oldest expired lock file (using modification timestamp), then takes
ownership of the lock file.
|
static FileLock.LogEntry |
getLastEntry(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path lockFile)
returns the last log entry.
|
static FileLock.LogEntry |
getLastEntryIfStale(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path lockFile,
long olderThan)
checks if lockFile is older than 'olderThan' UTC time by examining the modification time
on file and (if necessary) the timestamp in last log entry in the file.
|
FileLock.LogEntry |
getLastLogEntry() |
org.apache.hadoop.fs.Path |
getLockFile() |
void |
heartbeat(String fileOffset) |
static HdfsUtils.Pair<org.apache.hadoop.fs.Path,FileLock.LogEntry> |
locateOldestExpiredLock(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path lockFilesDir,
int locktimeoutSec)
Finds oldest expired lock file (using modification timestamp), then takes
ownership of the lock file.
|
void |
release()
Release lock by deleting file.
|
static FileLock |
takeOwnership(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path lockFile,
FileLock.LogEntry lastEntry,
String spoutId)
Takes ownership of the lock file if possible.
|
static FileLock |
tryLock(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path fileToLock,
org.apache.hadoop.fs.Path lockDirPath,
String spoutId)
returns lock on file or null if file is already locked.
|
public static FileLock tryLock(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path fileToLock, org.apache.hadoop.fs.Path lockDirPath, String spoutId) throws IOException
IOException
public static FileLock.LogEntry getLastEntryIfStale(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path lockFile, long olderThan) throws IOException
olderThan
- time (millis) in UTC.IOException
public static FileLock.LogEntry getLastEntry(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path lockFile) throws IOException
IOException
public static FileLock takeOwnership(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path lockFile, FileLock.LogEntry lastEntry, String spoutId) throws IOException
lastEntry
- last entry in the lock file. this param is an optimization.
we dont scan the lock file again to find its last entry here since
its already been done once by the logic used to check if the lock
file is stale. so this value comes from that earlier scan.spoutId
- spout idIOException
- if unable to acquirepublic static FileLock acquireOldestExpiredLock(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path lockFilesDir, int locktimeoutSec, String spoutId) throws IOException
IOException
public static HdfsUtils.Pair<org.apache.hadoop.fs.Path,FileLock.LogEntry> locateOldestExpiredLock(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path lockFilesDir, int locktimeoutSec) throws IOException
IOException
public void heartbeat(String fileOffset) throws IOException
IOException
public void release() throws IOException
IOException
- if lock file could not be deletedpublic FileLock.LogEntry getLastLogEntry()
public org.apache.hadoop.fs.Path getLockFile()
Copyright © 2023 The Apache Software Foundation. All rights reserved.