public class TransactionSettings extends Object
Instances of this class are immutable. To change a setting use the corresponding 'withXXXX()' method, which will return a fresh object with updated settings.
Constructor and Description |
---|
TransactionSettings()
Create a configuration object where all settings use the default
values configured on the server.
|
TransactionSettings(TransactionSettings other)
Copy another settings object.
|
Modifier and Type | Method and Description |
---|---|
Integer |
getDistributedTransactionTimeout()
Retrieves the transaction timeout
(see
withDistributedTransactionTimeout(Integer) ). |
Integer |
getTransactionLatencyCount()
Retrieve the latency count (
withTransactionLatencyCount(Integer) . |
Integer |
getTransactionLatencyTimeout()
Retrieve the latency timeout (
withTransactionLatencyTimeout(Integer) . |
<T> T |
visitDurability(DurabilityVisitor<T> visitor)
Retrieves the durability level (see
withDurability(Integer) ). |
TransactionSettings |
withDistributedTransactionTimeout(Integer distributedTransactionTimeout)
Sets the distributed transaction timeout.
|
TransactionSettings |
withDurability(DurabilityLevel durability)
Sets the durability level (see
withDurability(Integer) ) to a symbolic value. |
TransactionSettings |
withDurability(Integer durability)
Sets the durability level to a given number of instances.
|
TransactionSettings |
withTransactionLatencyCount(Integer transactionLatencyCount)
Sets the distributed transaction latency count.
|
TransactionSettings |
withTransactionLatencyTimeout(Integer transactionLatencyTimeout)
Sets the distributed transaction latency timeout.
|
public TransactionSettings()
public TransactionSettings(TransactionSettings other)
other
- Object to be cloned.public <T> T visitDurability(DurabilityVisitor<T> visitor)
withDurability(Integer)
).
This goes through a visitor interface since durability can be either
an integer or a symbolic DurabilityLevel
.
T
- Type of values returned by the visitor.visitor
- Object that will consume the durability value.public Integer getDistributedTransactionTimeout()
withDistributedTransactionTimeout(Integer)
).null
, meaning "use the default
value configured on the server".public Integer getTransactionLatencyCount()
withTransactionLatencyCount(Integer)
.null
, meaning "use the default
value configured on the server".public Integer getTransactionLatencyTimeout()
withTransactionLatencyTimeout(Integer)
.null
, meaning "use the
default value configured on the server".public TransactionSettings withDurability(Integer durability)
The durability is a positive integer value that specifies how many instances must have a commit ingested in order for that commit to be considered durable. The count includes the instance that made the commit.
A durability setting of 1 means that when an instance makes a commit that commit is immediately considered durable before even being sent to any other instance (the commit will still be sent to the other instances after it's considered durable).
A value that equals the total number of nodes in the cluster means that every instance must have ingested the commit before it's considered durable. If one or more instances are stopped at the moment then the commit will not become durable until the stopped instances are restarted.
durability
- Number of instances or null
, meaning "use the default
value configured on the server".public TransactionSettings withDurability(DurabilityLevel durability)
withDurability(Integer)
) to a symbolic value.durability
- Durability level name or null
, meaning "use the default
value configured on the server".public TransactionSettings withDistributedTransactionTimeout(Integer distributedTransactionTimeout)
Use this setting to specify how long a commit call will wait for the commit to become durable. It's a non-negative integer (number of seconds).
If the durability is greater than one then the committing process has to wait for acknowledgements from the other servers that the transaction was committed. The committing process returns to the caller when the durability has been reached or the distributed transaction timeout seconds has passed, whichever comes first.
When the commit returns the caller does not know if durability has been reached.
distributedTransactionTimeout
- Timeout in seconds or null
.
null
means 'use server config').public TransactionSettings withTransactionLatencyCount(Integer transactionLatencyCount)
Use this setting to limit the number of non-durable (pending) commits that can be active on the cluster. If this limit is reached all new commits will signal an error (and have to be retried).
When a commit is done the committing process tries to wait until the
commit is durable but if that takes too long
(see withDistributedTransactionTimeout(Integer)
) then commit will return
with the system still working on making that transaction durable.
If the latency count is 4 then even if the last four commits are not yet durable it is possible to do one more commit. But if there are five pending transactions then any attempt to commit will result in an error.
Another example: If you set the latency count to zero then each commit must be durable before the next commit can be done.
transactionLatencyCount
- number of commits or null
(use server default).public TransactionSettings withTransactionLatencyTimeout(Integer transactionLatencyTimeout)
Use this setting to specify how long a commit operation should wait for the Transaction Latency Count to be satisfied before throwing an error.
transactionLatencyTimeout
- number of seconds or null
(use server default).Copyright © 2019 Franz Inc.. All rights reserved.