public final class TransactionOptions extends Object implements DataSerializable
Modifier and Type | Class and Description |
---|---|
static class |
TransactionOptions.TransactionType
The type of transaction.
|
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_TIMEOUT_MILLIS
2 minutes as default timeout value
|
Constructor and Description |
---|
TransactionOptions()
Creates a new default configured TransactionsOptions.
|
Modifier and Type | Method and Description |
---|---|
static TransactionOptions |
getDefault()
Creates a new TransactionOptions configured with default settings.
|
int |
getDurability()
Gets the transaction durability.
|
long |
getTimeoutMillis()
Gets the timeout in milliseconds.
|
TransactionOptions.TransactionType |
getTransactionType()
Gets the
TransactionOptions.TransactionType . |
void |
readData(ObjectDataInput in)
Reads fields from the input stream
|
TransactionOptions |
setDurability(int durability)
Sets the transaction durability.
|
TransactionOptions |
setTimeout(long timeout,
TimeUnit timeUnit)
Sets the timeout.
|
TransactionOptions |
setTransactionType(TransactionOptions.TransactionType transactionType)
Sets the
TransactionOptions.TransactionType . |
String |
toString() |
void |
writeData(ObjectDataOutput out)
Writes object fields to output stream
|
public static final long DEFAULT_TIMEOUT_MILLIS
public TransactionOptions()
It will be configured with a timeout of 2 minutes, durability of 1 and a TransactionType.TWO_PHASE.
public TransactionOptions.TransactionType getTransactionType()
TransactionOptions.TransactionType
.public TransactionOptions setTransactionType(TransactionOptions.TransactionType transactionType)
TransactionOptions.TransactionType
.
A local transaction is less safe than a two phase transaction; when a member fails during the commit of a local transaction, it could be that some of the changes are committed, while others are not and this can leave your system in an inconsistent state.
transactionType
- the new TransactionType.getTransactionType()
,
setDurability(int)
public long getTimeoutMillis()
setTimeout(long, java.util.concurrent.TimeUnit)
public TransactionOptions setTimeout(long timeout, TimeUnit timeUnit)
The timeout determines the maximum lifespan of a transaction. So if a transaction is configured with a timeout of 2 minutes, then it will automatically rollback if it hasn't committed yet.
timeout
- the timeout.timeUnit
- the TimeUnit of the timeout.IllegalArgumentException
- if timeout smaller or equal than 0, or timeUnit is null.getTimeoutMillis()
public int getDurability()
setDurability(int)
public TransactionOptions setDurability(int durability)
The durability is the number of machines that can take over if a member fails during a transaction
commit or rollback. This value only has meaning when TransactionOptions.TransactionType.TWO_PHASE
is selected.
durability
- the durabilityIllegalArgumentException
- if durability smaller than 0.public static TransactionOptions getDefault()
TransactionOptions()
public void writeData(ObjectDataOutput out) throws IOException
DataSerializable
writeData
in interface DataSerializable
out
- outputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void readData(ObjectDataInput in) throws IOException
DataSerializable
readData
in interface DataSerializable
in
- inputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
input stream has been closed.Copyright © 2024 Hazelcast, Inc.. All rights reserved.