Class ItemStoreUtils
java.lang.Object
org.tasktide.itemstore.utils.ItemStoreUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidDeleteItemfrom RocksDB encasingstatic voiddeleteRecursively(Path path) Recursively delete all contents of folder and itstatic StringFetch random label for prototypestatic byte[]Fetch record for Idstatic ItemStoregetStore(ItemStoreType storeType, String storeName) Create requiredItemStoreCreate a mockItem, Id field is random UUIDmakeMockItem(String label) Create a mockItem, Id field is random UUIDmakeMockItemCollection(int amount) Make a collection of mockItemof required sizemakeMockItemCollection(int amount, String label) Make a collection of mockItemof required sizestatic booleanmakeTargetLockFile(Path targetLock) Creates target lock filestatic ItemmarshallItemFromByteArray(com.fasterxml.jackson.databind.ObjectMapper mapper, byte[] data) MarshallItemfrom byte arraystatic byte[]serializeItemToByteArray(com.fasterxml.jackson.databind.ObjectMapper MAPPER, Item item) SerializesItemto byte array with provided ObjectMapperstatic booleanverifyDirectories(Path dbDirectory, Path masterDB, Path prototype) static booleanverifyDirectory(Path dbDirectory) Checks whether configured directory is writablestatic voidwriteBatch(org.rocksdb.RocksDB db, org.rocksdb.WriteBatch batch, org.rocksdb.WriteOptions writeOptions) Batch write records
-
Constructor Details
-
ItemStoreUtils
public ItemStoreUtils()
-
-
Method Details
-
fetchNewProtoTypeLabel
-
verifyDirectory
Checks whether configured directory is writable- Returns:
- boolean
-
verifyDirectories
-
getStore
-
makeMockItem
-
makeMockItem
-
makeMockItemCollection
-
makeMockItemCollection
-
deleteRecursively
Recursively delete all contents of folder and it- Parameters:
path-- Throws:
IOException
-
makeTargetLockFile
-
serializeItemToByteArray
public static byte[] serializeItemToByteArray(com.fasterxml.jackson.databind.ObjectMapper MAPPER, Item item) throws ItemStoreCheckedException SerializesItemto byte array with provided ObjectMapper- Parameters:
MAPPER-item-- Returns:
- Throws:
ItemStoreCheckedException
-
writeBatch
public static void writeBatch(org.rocksdb.RocksDB db, org.rocksdb.WriteBatch batch, org.rocksdb.WriteOptions writeOptions) throws ItemStoreCheckedException Batch write records- Parameters:
db-batch-writeOptions-- Throws:
ItemStoreCheckedException
-
getId
Fetch record for Id- Parameters:
db-id-- Returns:
- byte[]
- Throws:
ItemStoreCheckedException
-
marshallItemFromByteArray
public static Item marshallItemFromByteArray(com.fasterxml.jackson.databind.ObjectMapper mapper, byte[] data) throws ItemStoreCheckedException MarshallItemfrom byte array- Parameters:
mapper-data-- Returns:
Item- Throws:
ItemStoreCheckedException
-
delete
DeleteItemfrom RocksDB encasing- Parameters:
db-item-- Throws:
ItemStoreCheckedException
-