Class SqliteStore
java.lang.Object
org.tasktide.itemstore.AbstractItemStore
org.tasktide.itemstore.SqliteStore
- All Implemented Interfaces:
ItemStore
Class to add support for SQLite
-
Field Summary
Fields inherited from class AbstractItemStore
dbDirectory, lockStrategy, masterDB, protoDB, storeName -
Constructor Summary
ConstructorsConstructorDescriptionSqliteStore(String storeName, String dbDirectory) Constructs SQLiteItemStoreSqliteStore(String storeName, String dbDirectory, boolean isLinked) Constructs SQLiteItemStoreSqliteStore(String storeName, String dbDirectory, String masterDB, String protoDB) Constructs SQLiteItemStoreSqliteStore(String storeName, String dbDirectory, String masterDB, String protoDB, boolean isLinked) Construct store with lazy master/proto connection -
Method Summary
Modifier and TypeMethodDescriptionbooleanCloses connection against master DBbooleanCloses connection against prototype DBbooleanDeletes providedItemusing its Id<T> TDonates activeItemStoremutex acquisition to provided recipients for provided operation set<T> Texecute(DbTarget target, ItemStore recipientStore, LinkedOperation<T> linkedOperations) Performs a set ofLinkedOperationover active, and recipientItemStore.<T> Texecute(DbTarget target, BulkOperation<T> operationSet) Performs a set of operations over anItemStoreSessionFetch all records from target databaseQuery on Item Idprotected <T> TgetConnection(DbTarget target, Class<T> type) GetConnectionget connectiongetItemsByState(DbTarget target, String state) Query on item stategetPayloadById(DbTarget target, String id) Fetch payload forItemby IdbooleanChecks if Master/Prototype are openbooleanChecks if Master/Prototype are openbooleanOpen connection master connectionbooleanOpen connection prototype connectionvoidSave record to target databasevoidsaveItemElm(DbTarget target, Item item) Save element under one commitvoidSave all records to target databasebooleanUpdate Item by dropping, then insertingMethods inherited from class AbstractItemStore
cacheMaster, clearPrototype, closeConn, getDbDirectory, getFilePath, getMasterFilePath, getStoreName, openConn, syncToMaster, syncToMaster, syncToMaster, withLockedConnection, withLockedConnectionUnchecked
-
Constructor Details
-
SqliteStore
-
SqliteStore
-
SqliteStore
-
SqliteStore
-
-
Method Details
-
getConnection
GetConnectionget connection- Specified by:
getConnectionin classAbstractItemStore- Type Parameters:
T-- Parameters:
target-type- SqliteStore | RocksDbStore- Returns:
Connection
-
saveItemElm
Save element under one commit- Parameters:
target-item-- Throws:
ItemStoreCheckedException
-
saveItem
Save record to target database- Parameters:
target-item-- Throws:
ItemStoreCheckedException
-
saveItems
Save all records to target database- Parameters:
target-items-- Throws:
ItemStoreCheckedException
-
getAll
Fetch all records from target database- Parameters:
target-- Returns:
- List-
Item - Throws:
ItemStoreCheckedException
-
getById
Query on Item Id- Parameters:
target-id-- Returns:
Item- Throws:
ItemStoreCheckedException
-
getItemsByState
Query on item state- Parameters:
target-state-- Returns:
- List-
Item - Throws:
ItemStoreCheckedException
-
getPayloadById
-
delete
Deletes providedItemusing its Id- Parameters:
target-item-- Returns:
- boolean
- Throws:
ItemStoreCheckedException
-
update
Update Item by dropping, then inserting- Parameters:
target-item-- Returns:
- boolean
- Throws:
ItemStoreCheckedException
-
isOpen
Checks if Master/Prototype are open- Parameters:
target-- Returns:
- boolean
-
isClosed
Checks if Master/Prototype are open- Parameters:
target-- Returns:
- boolean
-
openMaster
public boolean openMaster()Open connection master connection- Returns:
- boolean
-
closeMaster
public boolean closeMaster()Closes connection against master DB- Returns:
- boolean
-
openPrototoype
public boolean openPrototoype()Open connection prototype connection- Returns:
- boolean
-
closePrototoype
public boolean closePrototoype()Closes connection against prototype DB- Returns:
- boolean
-
execute
public <T> T execute(DbTarget target, BulkOperation<T> operationSet) throws ItemStoreCheckedException Performs a set of operations over anItemStoreSession- Type Parameters:
T-- Parameters:
target-operationSet-- Returns:
- T
- Throws:
ItemStoreCheckedException
-
execute
public <T> T execute(DbTarget target, ItemStore recipientStore, LinkedOperation<T> linkedOperations) throws ItemStoreCheckedException Performs a set ofLinkedOperationover active, and recipientItemStore. Under the mutex of the callingItemStore, hence providedItemStorereferred to as a recipient of the stores mutex- Type Parameters:
T-- Parameters:
target-recipientStore-linkedOperations-- Returns:
of T - Throws:
ItemStoreCheckedException
-
execute
public <T> T execute(DbTarget target, Map<String, ItemStore> recipients, LinkedOperationMap<T> operations) throws ItemStoreCheckedException Donates activeItemStoremutex acquisition to provided recipients for provided operation set- Type Parameters:
T-- Parameters:
target-recipients-operations-- Returns:
of T - Throws:
ItemStoreCheckedException
-