Class AbstractItemStore
java.lang.Object
org.tasktide.itemstore.AbstractItemStore
- All Implemented Interfaces:
ItemStore
- Direct Known Subclasses:
RocksDbStore, SqliteStore
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Pathprotected final ItemStoreLockStrategyprotected final Pathprotected final Pathprotected final String -
Constructor Summary
ConstructorsConstructorDescriptionAbstractItemStore(String storeName, String dbDirectory) Preferred constructor moving forwardAbstractItemStore(String storeName, String dbDirectory, String masterDB, String protoDB) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCache master DB to prototypebooleanRemove prototypeDBbooleanStandardizes how concreteItemStoreclose connections, using the evaluation logic fromItemStoreConnectionStrategy, and targetedAbstractItemStoremethods.protected abstract <T> TgetConnection(DbTarget target, Class<T> type) Get connectionReturn directory of where DB is storedReturn file path prototype DBReturn full file path for masterReturn store namebooleanStandardizes how concreteItemStoreopen connections, using the evaluation logic fromItemStoreConnectionStrategy, and targetedAbstractItemStoremethods.voidSync all records from cache to mastervoidsyncToMaster(List<Item> items) Syncs Item list to mastervoidsyncToMaster(Item item) Sync anItemto the master.protected <R> RwithLockedConnection(String label, DbTarget target, ThrowableItemStoreOperation operation) Synchronizes lock and connection lifecycles under one operation.protected <R> RwithLockedConnectionUnchecked(String label, DbTarget target, ItemStoreOperation operation) Synchronizes lock and connection lifecycles under one operation.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ItemStore
closeMaster, closePrototoype, delete, execute, execute, execute, getAll, getById, getItemsByState, getPayloadById, isClosed, isOpen, openMaster, openPrototoype, saveItem, saveItems, update
-
Field Details
-
storeName
-
dbDirectory
-
masterDB
-
protoDB
-
lockStrategy
-
-
Constructor Details
-
AbstractItemStore
@Deprecated public AbstractItemStore(String storeName, String dbDirectory, String masterDB, String protoDB) Deprecated.Construct with all attributes. Throws IllegalArgument RunTime exception if not writable.- Parameters:
storeName-dbDirectory-masterDB-protoDB-
-
AbstractItemStore
-
-
Method Details
-
getConnection
-
withLockedConnection
protected <R> R withLockedConnection(String label, DbTarget target, ThrowableItemStoreOperation operation) throws ItemStoreCheckedException Synchronizes lock and connection lifecycles under one operation. Allowing callers to solely own the required operation, without having to know about these distinct strategies- Type Parameters:
R-- Parameters:
label-target-operation-- Returns:
- R Operation Result
- Throws:
ItemStoreCheckedException
-
withLockedConnectionUnchecked
protected <R> R withLockedConnectionUnchecked(String label, DbTarget target, ItemStoreOperation operation) throws ItemStoreUncheckedException Synchronizes lock and connection lifecycles under one operation. Allowing callers to solely own the required operation, without having to know about these distinct strategies- Type Parameters:
R-- Parameters:
label-target-operation-- Returns:
- R Operation Result
- Throws:
ItemStoreUncheckedException
-
openConn
Standardizes how concreteItemStoreopen connections, using the evaluation logic fromItemStoreConnectionStrategy, and targetedAbstractItemStoremethods. Allowing concrete classes to only own opening appropriateDbTarget -
closeConn
Standardizes how concreteItemStoreclose connections, using the evaluation logic fromItemStoreConnectionStrategy, and targetedAbstractItemStoremethods. Allowing concrete classes to only own opening appropriateDbTarget -
syncToMaster
Sync anItemto the master. Assumes with lock handle by the interface method, to prevent request duplication- Specified by:
syncToMasterin interfaceItemStore- Parameters:
item-- Throws:
ItemStoreCheckedException
-
syncToMaster
Syncs Item list to master- Specified by:
syncToMasterin interfaceItemStore- Parameters:
items-- Throws:
ItemStoreCheckedException
-
syncToMaster
Sync all records from cache to master- Specified by:
syncToMasterin interfaceItemStore- Throws:
ItemStoreCheckedException
-
cacheMaster
public boolean cacheMaster()Cache master DB to prototype- Specified by:
cacheMasterin interfaceItemStore- Returns:
- boolean
-
clearPrototype
public boolean clearPrototype()Remove prototypeDB- Specified by:
clearPrototypein interfaceItemStore- Returns:
- boolean
-
getStoreName
Return store name- Specified by:
getStoreNamein interfaceItemStore- Returns:
- String
-
getMasterFilePath
Return full file path for master- Specified by:
getMasterFilePathin interfaceItemStore- Returns:
- String
-
getFilePath
Return file path prototype DB- Specified by:
getFilePathin interfaceItemStore- Returns:
- String
-
getDbDirectory
Return directory of where DB is stored- Specified by:
getDbDirectoryin interfaceItemStore- Returns:
- String
-