Class TransactionSettings
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 Summary
ConstructorDescriptionCreate a configuration object where all settings use the default values configured on the server.Copy another settings object. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the transaction timeout (seewithDistributedTransactionTimeout(Integer)
).Retrieve the latency count (withTransactionLatencyCount(Integer)
.Retrieve the latency timeout (withTransactionLatencyTimeout(Integer)
.<T> T
visitDurability
(DurabilityVisitor<T> visitor) Retrieves the durability level (seewithDurability(Integer)
).withDistributedTransactionTimeout
(Integer distributedTransactionTimeout) Sets the distributed transaction timeout.withDurability
(DurabilityLevel durability) Sets the durability level (seewithDurability(Integer)
) to a symbolic value.withDurability
(Integer durability) Sets the durability level to a given number of instances.withTransactionLatencyCount
(Integer transactionLatencyCount) Sets the distributed transaction latency count.withTransactionLatencyTimeout
(Integer transactionLatencyTimeout) Sets the distributed transaction latency timeout.
-
Constructor Details
-
TransactionSettings
public TransactionSettings()Create a configuration object where all settings use the default values configured on the server. -
TransactionSettings
Copy another settings object.- Parameters:
other
- Object to be cloned.
-
-
Method Details
-
visitDurability
Retrieves the durability level (seewithDurability(Integer)
).This goes through a visitor interface since durability can be either an integer or a symbolic
DurabilityLevel
.- Type Parameters:
T
- Type of values returned by the visitor.- Parameters:
visitor
- Object that will consume the durability value.- Returns:
- Whatever the visitor returns.
-
getDistributedTransactionTimeout
Retrieves the transaction timeout (seewithDistributedTransactionTimeout(Integer)
).- Returns:
- Number of seconds to wait or
null
, meaning "use the default value configured on the server".
-
getTransactionLatencyCount
Retrieve the latency count (withTransactionLatencyCount(Integer)
.- Returns:
- Max number of pending commits or
null
, meaning "use the default value configured on the server".
-
getTransactionLatencyTimeout
Retrieve the latency timeout (withTransactionLatencyTimeout(Integer)
.- Returns:
- Number of seconds to wait for Transaction Latency Count
to be satisfied or
null
, meaning "use the default value configured on the server".
-
withDurability
Sets the durability level to a given number of instances.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.
- Parameters:
durability
- Number of instances ornull
, meaning "use the default value configured on the server".- Returns:
- A fresh config instance with updated settings.
-
withDurability
Sets the durability level (seewithDurability(Integer)
) to a symbolic value.- Parameters:
durability
- Durability level name ornull
, meaning "use the default value configured on the server".- Returns:
- A fresh config instance with updated settings.
-
withDistributedTransactionTimeout
Sets the distributed transaction timeout.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.
- Parameters:
distributedTransactionTimeout
- Timeout in seconds ornull
.null
means 'use server config').- Returns:
- A fresh config instance with updated settings.
-
withTransactionLatencyCount
Sets the distributed transaction latency count.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.
- Parameters:
transactionLatencyCount
- number of commits ornull
(use server default).- Returns:
- A fresh config instance with updated settings.
-
withTransactionLatencyTimeout
Sets the distributed transaction latency timeout.Use this setting to specify how long a commit operation should wait for the Transaction Latency Count to be satisfied before throwing an error.
- Parameters:
transactionLatencyTimeout
- number of seconds ornull
(use server default).- Returns:
- A fresh config instance with updated settings.
-