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