Class MutexFilesUtils
java.lang.Object
org.tasktide.mutex.utils.MutexFilesUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanclearStaleLeader(Path targetFile) static booleandeleteFile(Path target) Delete target fliestatic booleanevaluateLeaderTimeToLive(Path leader) Evaluates time to live of leaderfetchFiles(Path dir) Retrieve list of files under target directory under targetfetchOldest(Path dir) Fetch the oldest pathstatic intfindPosition(Mutex mutex, MutexFileType fileType) Returns the full file path of the leaderstatic PathfindPredecessor(Mutex mutex, MutexFileType fileType, int pos) Find predecessor pathstatic PathFetch leaderreadMutexFromFile(Path mutexFile) Fetch nullableMutexfrom provided filestatic voidrecastBallot(Mutex mutex, boolean deleteFlag) static voidremoveConfirmatoryBallot(Mutex mutex) static booleanremoveHostFile(Mutex mutex) Remove host filestatic StringRepresents provided data as JSON stringstatic booleanwriteConfirmatoryBallot(Mutex mutex, Path confirmDir) static booleanwriteElectionFile(Mutex mutex) Write the election file ofMutexstatic booleanwriteHostFile(Mutex mutex) Enqueue lock requeststatic voidwriteMutex(Mutex mutex, MutexFileType fileType) Write mutex to requiredMutexFileTypestatic booleanwriteMutexFile(Mutex mutex, Path targetFile) WriteMutex
-
Constructor Details
-
MutexFilesUtils
public MutexFilesUtils()
-
-
Method Details
-
toJson
-
fetchFiles
-
findPosition
Returns the full file path of the leader- Parameters:
mutex-fileType-- Returns:
- int
-
findPredecessor
Find predecessor path- Parameters:
mutex-fileType-pos-- Returns:
- Path
-
fetchOldest
-
writeHostFile
Enqueue lock request- Parameters:
mutex-- Returns:
- boolean
-
writeElectionFile
-
readMutexFromFile
-
removeHostFile
Remove host file- Parameters:
mutex-- Returns:
- boolean
-
deleteFile
Delete target flie- Parameters:
target-- Returns:
- boolean
-
writeMutexFile
-
writeMutex
Write mutex to requiredMutexFileType- Parameters:
mutex-fileType-- Throws:
MutexCheckedException
-
getLeader
Fetch leader- Returns:
- Path
- Throws:
MutexCheckedException
-
evaluateLeaderTimeToLive
Evaluates time to live of leader- Parameters:
leader-- Returns:
- boolean
-
clearStaleLeader
- Parameters:
targetFile-- Returns:
-
writeConfirmatoryBallot
-
removeConfirmatoryBallot
-
recastBallot
-