Class RocksDbStore
java.lang.Object
org.tasktide.itemstore.AbstractItemStore
org.tasktide.itemstore.RocksDbStore
- All Implemented Interfaces:
ItemStore
Use
RocksDB as storage backend-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.rocksdb.RocksDBprotected org.rocksdb.RocksDBFields inherited from class AbstractItemStore
dbDirectory, lockStrategy, masterDB, protoDB, storeName -
Constructor Summary
ConstructorsConstructorDescriptionRocksDbStore(String storeName, String dbDirectory) Connect to DBRocksDbStore(String storeName, String dbDirectory, String masterDB, String protoDB) Connect to DB -
Method Summary
Modifier and TypeMethodDescriptionbooleanCloses connection against master DBbooleanCloses connection against prototype DBbooleanDeleteItemfrom prototype<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 anItemStoreSessionorg.rocksdb.RocksIteratorfetchIter(org.rocksdb.RocksDB db) Fetch iterator from dbfetchIteratorValue(org.rocksdb.RocksIterator iter) Fetch active value fromRocksIteratoras anItemFetch all records from either Master (true), or Cache (False)Fetch theItemwith provided Id from cacheprotected <T> TgetConnection(DbTarget target, Class<T> type) GetRocksDBget connectiongetItemsByState(DbTarget target, String state) Fetch item by state from mastergetPayloadById(DbTarget target, String id) Fetch payload for queriedItemfrom cachebooleanChecks if Master/Prototype are openbooleanChecks if Master/Prototype are openbooleanOpen connection master connectionbooleanOpen connection prototype connectionvoidputItem(org.rocksdb.RocksDB db, byte[] key, byte[] value) Put data in target DBvoidSave item to cached RocksDB, connection and lock lifecycles orchestrated byAbstractItemStorevoidImportItemlist to cached DBbooleanUpdate by dropping and insertingMethods inherited from class AbstractItemStore
cacheMaster, clearPrototype, closeConn, getDbDirectory, getFilePath, getMasterFilePath, getStoreName, openConn, syncToMaster, syncToMaster, syncToMaster, withLockedConnection, withLockedConnectionUnchecked
-
Field Details
-
master
protected org.rocksdb.RocksDB master -
proto
protected org.rocksdb.RocksDB proto
-
-
Constructor Details
-
RocksDbStore
-
RocksDbStore
-
-
Method Details
-
getConnection
GetRocksDBget connection- Specified by:
getConnectionin classAbstractItemStore- Type Parameters:
T-- Parameters:
target-type- SqliteStore | RocksDbStore- Returns:
RocksDB
-
fetchIteratorValue
-
fetchIter
public org.rocksdb.RocksIterator fetchIter(org.rocksdb.RocksDB db) Fetch iterator from db- Parameters:
db-- Returns:
- RocksIterator
-
putItem
public void putItem(org.rocksdb.RocksDB db, byte[] key, byte[] value) throws ItemStoreCheckedException Put data in target DB- Parameters:
db-key-value-- Throws:
ItemStoreCheckedException
-
getAll
Fetch all records from either Master (true), or Cache (False)- Parameters:
target-- Returns:
- List-
Item - Throws:
ItemStoreUncheckedException
-
saveItem
Save item to cached RocksDB, connection and lock lifecycles orchestrated byAbstractItemStore- Parameters:
target-item-- Throws:
ItemStoreCheckedException
-
update
-
saveItems
ImportItemlist to cached DB- Parameters:
target-items-- Throws:
ItemStoreCheckedException
-
getById
Fetch theItemwith provided Id from cache- Parameters:
target-id-- Returns:
- Throws:
ExceptionItemStoreCheckedException
-
getItemsByState
Fetch item by state from master- Parameters:
target-state-- Returns:
- List-
Item - Throws:
ItemStoreCheckedException
-
getPayloadById
-
delete
DeleteItemfrom prototype- 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
-