Class TransactionalNodeStore<USERKEY,STOREKEY,VALUE>
- java.lang.Object
-
- com.github.basking2.sdsai.dsds.node.tx.TransactionalNodeStore<USERKEY,STOREKEY,VALUE>
-
- Type Parameters:
USERKEY- The user key type.STOREKEY- The data store key type.VALUE- The value being stored.
- All Implemented Interfaces:
NodeStore<USERKEY,STOREKEY,VALUE>
public class TransactionalNodeStore<USERKEY,STOREKEY,VALUE> extends java.lang.Object implements NodeStore<USERKEY,STOREKEY,VALUE>
This represents a transaction against aNodeStore. Operations are stored cached internally untilcommit()is called orrollback()causes the data to be abandoned. A transaction. This is implemented as a NodeStore in which methods not related to the transaction are directly proxied to theNodeStoreused to initialize this object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTransactionalNodeStore.SubTx<USERKEY,STOREKEY,VALUE>An interface to provide a callback for doing operations on sub-TransactionalNodeStores.
-
Constructor Summary
Constructors Constructor Description TransactionalNodeStore(NodeStore<USERKEY,STOREKEY,VALUE> nodeStore)TransactionalNodeStore(NodeStore<USERKEY,STOREKEY,VALUE> nodeStore, TransactionalNodeStore<USERKEY,STOREKEY,VALUE> parentTransaction)Create a new transaction that operates against the givenNodeStore.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommit()Execute all operations in this transaction.STOREKEYconvert(USERKEY key)Convert user keys to store keys.STOREKEYgenerateKey(Node<USERKEY,STOREKEY> node, VALUE value)Generate a key to store a node or data element.VALUEloadData(STOREKEY key)Load the user's data.Node<USERKEY,STOREKEY>loadNode(STOREKEY key)Load a node object fromNodeStore.voidremoveData(STOREKEY key)Remove the given data key.voidremoveNode(STOREKEY key)Remove the given node key.voidrollback()Rollback and clear all internal structures of this transaction.voidstore(STOREKEY key, Node<USERKEY,STOREKEY> node)Store the given node.voidstore(STOREKEY key, VALUE value)Store user data.voidsubTransaction(TransactionalNodeStore.SubTx<USERKEY,STOREKEY,VALUE> subTx)Give the user a sub-transaction which is merged into this transaction whenTransactionalNodeStore.SubTx.buildTx(TransactionalNodeStore)returns.
-
-
-
Method Detail
-
subTransaction
public void subTransaction(TransactionalNodeStore.SubTx<USERKEY,STOREKEY,VALUE> subTx)
Give the user a sub-transaction which is merged into this transaction whenTransactionalNodeStore.SubTx.buildTx(TransactionalNodeStore)returns.
-
rollback
public void rollback()
Rollback and clear all internal structures of this transaction.
-
commit
public void commit()
Execute all operations in this transaction.
-
convert
public STOREKEY convert(USERKEY key)
Convert user keys to store keys. This method, given a user's key, must always produce the same store key.
-
generateKey
public STOREKEY generateKey(Node<USERKEY,STOREKEY> node, VALUE value)
Generate a key to store a node or data element. This key must be unique.- Specified by:
generateKeyin interfaceNodeStore<USERKEY,STOREKEY,VALUE>- Parameters:
node- This is provided to implementations for some context. If generateKey is being called for the purposes of storing a user key, this will be null.value- If a key is being generated for a user key value, it will be passed along. This is most useful when things like aPagedListare adding a value, but the List API does not provide a way to specify a key.
-
removeNode
public void removeNode(STOREKEY key)
Remove the given node key. If the key does not exist, this should return without error.- Specified by:
removeNodein interfaceNodeStore<USERKEY,STOREKEY,VALUE>
-
removeData
public void removeData(STOREKEY key)
Remove the given data key. If the key does not exist, this should return without error.- Specified by:
removeDatain interfaceNodeStore<USERKEY,STOREKEY,VALUE>
-
store
public void store(STOREKEY key, Node<USERKEY,STOREKEY> node)
Store the given node. If an object already exists at the key, it should be replaced.
-
-