Package com.aerospike.client
Class Txn
java.lang.Object
com.aerospike.client.Txn
Multi-record transaction. Each command in the transaction must use the same namespace.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear transaction.booleanReturn if the transaction monitor record should be closed/deleted.intGet transaction deadline.longgetId()Return transaction ID.booleanReturn if transaction is inDoubt.Return transaction namespace.getReads()Get all read keys and their versions.getReadVersion(Key key) Get record version for a given key.getState()Return transaction state.intReturn transaction timeout in seconds.Get all write keys and their versions.booleanDoes transaction monitor record exist.voidProcess the results of a record read.voidProcess the results of a record write.voidonWriteInDoubt(Key key) Add key to write hash when write command is in doubt (usually caused by timeout).voidsetDeadline(int deadline) Set transaction deadline.voidsetInDoubt(boolean inDoubt) Set transaction inDoubt flag.voidsetNamespace(String ns) Set transaction namespace only if doesn't already exist.voidSet transaction state.voidsetTimeout(int timeout) Set transaction timeout in seconds.voidVerify that the transaction state allows future commands.
-
Constructor Details
-
Txn
public Txn()Create transaction, assign random transaction id and initialize reads/writes hashmaps with default capacities.The default client transaction timeout is zero. This means use the server configuration mrt-duration as the transaction timeout. The default mrt-duration is 10 seconds.
-
Txn
public Txn(int readsCapacity, int writesCapacity) Create transaction, assign random transaction id and initialize reads/writes hashmaps with given capacities.The default client transaction timeout is zero. This means use the server configuration mrt-duration as the transaction timeout. The default mrt-duration is 10 seconds.
- Parameters:
readsCapacity- expected number of record reads in the transaction. Minimum value is 16.writesCapacity- expected number of record writes in the transaction. Minimum value is 16.
-
-
Method Details
-
getId
public long getId()Return transaction ID. -
setTimeout
public void setTimeout(int timeout) Set transaction timeout in seconds. The timer starts when the transaction monitor record is created. This occurs when the first command in the transaction is executed. If the timeout is reached before a commit or abort is called, the server will expire and rollback the transaction.If the transaction timeout is zero, the server configuration mrt-duration is used. The default mrt-duration is 10 seconds.
-
getTimeout
public int getTimeout()Return transaction timeout in seconds. -
verifyCommand
public void verifyCommand()Verify that the transaction state allows future commands. -
onRead
Process the results of a record read. For internal use only. -
getReadVersion
Get record version for a given key. -
getReads
Get all read keys and their versions. -
onWrite
Process the results of a record write. For internal use only. -
onWriteInDoubt
Add key to write hash when write command is in doubt (usually caused by timeout). -
getWrites
Get all write keys and their versions. -
setNamespace
Set transaction namespace only if doesn't already exist. If namespace already exists, verify new namespace is the same. -
getNamespace
Return transaction namespace. -
setDeadline
public void setDeadline(int deadline) Set transaction deadline. The deadline is a wall clock time calculated by the server from the transaction timeout that is sent by the client when creating the transaction monitor record. This deadline is used to avoid client/server clock skew issues. For internal use only. -
getDeadline
public int getDeadline()Get transaction deadline. For internal use only. -
closeMonitor
public boolean closeMonitor()Return if the transaction monitor record should be closed/deleted. For internal use only. -
monitorExists
public boolean monitorExists()Does transaction monitor record exist. -
setState
Set transaction state. For internal use only. -
getState
Return transaction state. -
setInDoubt
public void setInDoubt(boolean inDoubt) Set transaction inDoubt flag. For internal use only. -
getInDoubt
public boolean getInDoubt()Return if transaction is inDoubt. -
clear
public void clear()Clear transaction. Remove all tracked keys.
-