ReqL - RequestList typeResL - ResultList typepublic abstract class AbstractTransaction<ReqL extends RequestList,ResL extends ResultList> extends Object
Transaction and TransactionSingleOp.| Constructor and Description |
|---|
AbstractTransaction()
Constructor, uses the default connection returned by
ConnectionFactory.createConnection(). |
AbstractTransaction(Connection conn)
Constructor, uses the given connection to an erlang node.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDelOnList(OtpErlangString key,
OtpErlangList toAdd,
OtpErlangList toRemove)
Changes the list stored at the given key, i.e.
|
<T> void |
addDelOnList(String key,
List<T> toAdd,
List<T> toRemove)
Changes the list stored at the given key, i.e.
|
void |
addOnNr(OtpErlangString key,
OtpErlangDouble toAdd)
Changes the number stored at the given key, i.e.
|
void |
addOnNr(OtpErlangString key,
OtpErlangLong toAdd)
Changes the number stored at the given key, i.e.
|
<T> void |
addOnNr(String key,
T toAdd)
Changes the number stored at the given key, i.e.
|
void |
closeConnection()
Closes the transaction's connection to a scalaris node.
|
boolean |
isCompressed()
Checks whether the transfer of values is compressed or not.
|
ErlangValue |
read(OtpErlangString key)
Gets the value stored under the given
key. |
ErlangValue |
read(String key)
Gets the value stored under the given
key. |
abstract ResL |
req_list(ReqL req)
Executes all requests in
req. |
void |
setCompressed(boolean compressed)
Sets whether to compress the transfer of values or not.
|
void |
testAndSet(OtpErlangString key,
OtpErlangObject oldValue,
OtpErlangObject newValue)
Stores the given key/new_value pair if the old value at
key is old_value (atomic test_and_set).
|
<OldT,NewT> |
testAndSet(String key,
OldT oldValue,
NewT newValue)
Stores the given key/new_value pair if the old value at
key is old_value (atomic test_and_set).
|
void |
write(OtpErlangString key,
OtpErlangObject value)
Stores the given
key/value pair. |
<T> void |
write(String key,
T value)
Stores the given
key/value pair. |
public AbstractTransaction()
throws ConnectionException
ConnectionFactory.createConnection().ConnectionException - if the connection failspublic AbstractTransaction(Connection conn)
conn - connection to use for the transactionpublic abstract ResL req_list(ReqL req) throws ConnectionException, AbortException, UnknownException
req.
The transaction's log is reset if a commit in the request list was successful, otherwise it still retains in the transaction which must be successfully committed, aborted or reset in order to be (re-)used for another request.
req - the requests to issuereqConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieAbortException - if a commit failed (if there was one)UnknownException - if any other error occurspublic ErlangValue read(OtpErlangString key) throws ConnectionException, NotFoundException, UnknownException
key.key - the key to look upkeyConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieNotFoundException - if the requested key does not existUnknownException - if any other error occurspublic ErlangValue read(String key) throws ConnectionException, NotFoundException, UnknownException
key.key - the key to look upkeyConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieNotFoundException - if the requested key does not existUnknownException - if any other error occursread(OtpErlangString)public void write(OtpErlangString key, OtpErlangObject value) throws ConnectionException, AbortException, UnknownException
key/value pair.key - the key to store the value forvalue - the value to storeConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieAbortException - if the commit failed (if there was one)UnknownException - if any other error occurspublic <T> void write(String key, T value) throws ConnectionException, AbortException, UnknownException
key/value pair.T - the type of the valuekey - the key to store the value forvalue - the value to storeConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieAbortException - if the commit failed (if there was one)UnknownException - if any other error occurswrite(OtpErlangString, OtpErlangObject)public void addDelOnList(OtpErlangString key, OtpErlangList toAdd, OtpErlangList toRemove) throws ConnectionException, NotAListException, AbortException, UnknownException
key - the key to write the value totoAdd - a list of values to add to a listtoRemove - a list of values to remove from a listConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieNotAListException - if the previously stored value was no listAbortException - if the commit failed (if there was one)UnknownException - if any other error occurspublic <T> void addDelOnList(String key, List<T> toAdd, List<T> toRemove) throws ConnectionException, NotAListException, AbortException, UnknownException
key - the key to write the value totoAdd - a list of values to add to a listtoRemove - a list of values to remove from a listConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieNotAListException - if the previously stored value was no listAbortException - if the commit failed (if there was one)UnknownException - if any other error occursaddDelOnList(OtpErlangString, OtpErlangList, OtpErlangList)public void addOnNr(OtpErlangString key, OtpErlangLong toAdd) throws ConnectionException, NotANumberException, AbortException, UnknownException
key - the key to write the value totoAdd - the number to add to the number stored at key (may also be
negative)ConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieNotANumberException - if the previously stored value was no numberAbortException - if the commit failed (if there was one)UnknownException - if any other error occursaddOnNr_(AddOnNrOp)public void addOnNr(OtpErlangString key, OtpErlangDouble toAdd) throws ConnectionException, NotANumberException, AbortException, UnknownException
key - the key to write the value totoAdd - the number to add to the number stored at key (may also be
negative)ConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieNotANumberException - if the previously stored value was no numberAbortException - if the commit failed (if there was one)UnknownException - if any other error occursaddOnNr_(AddOnNrOp)public <T> void addOnNr(String key, T toAdd) throws ConnectionException, NotANumberException, AbortException, UnknownException
key - the key to write the value totoAdd - the number to add to the number stored at key (may also be
negative)ConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieNotANumberException - if the previously stored value was no numberAbortException - if the commit failed (if there was one)UnknownException - if any other error occursaddOnNr(OtpErlangString, OtpErlangLong),
addOnNr(OtpErlangString, OtpErlangDouble)public void testAndSet(OtpErlangString key, OtpErlangObject oldValue, OtpErlangObject newValue) throws ConnectionException, NotFoundException, KeyChangedException, AbortException, UnknownException
key - the key to store the value foroldValue - the old value to checknewValue - the value to storeConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieNotFoundException - if the requested key does not existKeyChangedException - if the key did not match old_valueAbortException - if the commit failed (if there was one)UnknownException - if any other error occurspublic <OldT,NewT> void testAndSet(String key, OldT oldValue, NewT newValue) throws ConnectionException, NotFoundException, KeyChangedException, AbortException, UnknownException
key - the key to store the value foroldValue - the old value to checknewValue - the value to storeConnectionException - if the connection is not active or a communication error
occurs or an exit signal was received or the remote node
sends a message containing an invalid cookieNotFoundException - if the requested key does not existKeyChangedException - if the key did not match old_valueAbortException - if the commit failed (if there was one)UnknownException - if any other error occurstestAndSet(OtpErlangString, OtpErlangObject, OtpErlangObject)public void closeConnection()
ConnectionExceptions!public boolean isCompressed()
public void setCompressed(boolean compressed)
compressed - true if compressed, otherwise false