Class ItemStoreLockStrategy
java.lang.Object
org.tasktide.itemstore.strategies.ItemStoreLockStrategy
Class responsible for flexibly owning the
Mutex lifecycle
for an ItemStore as required. Using the same
configured database, hence is tied but a child of
AbstractItemStore. Providing an withLock
method handle, and explicit lock/release methods-
Constructor Summary
ConstructorsConstructorDescriptionItemStoreLockStrategy(String storeName, Path dbDirectory) Targeted constructor using store name under provided directoryItemStoreLockStrategy(String storeName, Path dbDirectory, Path masterDB) AbstractItemStorecompatible constructor -
Method Summary
Modifier and TypeMethodDescriptionFetch configured DB directoryFetch active file channelFetch active OS file lockFetch configured master DB directoryFetch configured master lock directoryFetch configured store namebooleanreleaseLock(boolean releaseMutex) Release lock on mastervoidWaits until master is locked<R> RwithLock(String label, ThrowableItemStoreOperation<R> operation) InternalItemStoremethod to force database operations under standard lock release pipeline<R> RwithLockNonSynced(String label, ThrowableItemStoreOperation<R> operation) Non-synchronizedItemStoremethod to force database operations under standard lock release pipeline<R> RwithLockUnchecked(String label, ItemStoreOperation<R> operation) InternalItemStoremethod to force database operations under standard lock release pipeline
-
Constructor Details
-
ItemStoreLockStrategy
-
ItemStoreLockStrategy
AbstractItemStorecompatible constructor- Parameters:
storeName-dbDirectory-masterDB-
-
-
Method Details
-
waitForLock
Waits until master is locked- Throws:
InterruptedExceptionIOException
-
withLock
public <R> R withLock(String label, ThrowableItemStoreOperation<R> operation) throws ItemStoreCheckedException InternalItemStoremethod to force database operations under standard lock release pipeline- Type Parameters:
R-- Parameters:
label-operation-- Returns:
of operation result - Throws:
ItemStoreCheckedException
-
withLockUnchecked
public <R> R withLockUnchecked(String label, ItemStoreOperation<R> operation) throws ItemStoreUncheckedException InternalItemStoremethod to force database operations under standard lock release pipeline- Type Parameters:
R-- Parameters:
label-operation-- Returns:
of operation result - Throws:
ItemStoreUncheckedException
-
withLockNonSynced
public <R> R withLockNonSynced(String label, ThrowableItemStoreOperation<R> operation) throws ItemStoreCheckedException Non-synchronizedItemStoremethod to force database operations under standard lock release pipeline- Type Parameters:
R-- Parameters:
label-operation-- Returns:
of operation result - Throws:
ItemStoreCheckedException
-
releaseLock
public boolean releaseLock(boolean releaseMutex) Release lock on master- Parameters:
releaseMutex-- Returns:
- boolean
-
getStoreName
-
getDbDirectory
-
getMasterDB
-
getMasterLock
-
getFileChannel
-
getFileLock
-