Class TransactionSettings

java.lang.Object
com.franz.agraph.repository.repl.TransactionSettings

public class TransactionSettings extends Object
A container for all settings related to commit behavior in multi-master replication clusters.

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 Details

    • TransactionSettings

      public TransactionSettings()
      Create a configuration object where all settings use the default values configured on the server.
    • TransactionSettings

      public TransactionSettings(TransactionSettings other)
      Copy another settings object.
      Parameters:
      other - Object to be cloned.
  • Method Details

    • visitDurability

      public <T> T visitDurability(DurabilityVisitor<T> visitor)
      Retrieves the durability level (see withDurability(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

      public Integer getDistributedTransactionTimeout()
      Retrieves the transaction timeout (see withDistributedTransactionTimeout(Integer)).
      Returns:
      Number of seconds to wait or null, meaning "use the default value configured on the server".
    • getTransactionLatencyCount

      public Integer 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

      public Integer 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

      public TransactionSettings withDurability(Integer durability)
      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 or null, meaning "use the default value configured on the server".
      Returns:
      A fresh config instance with updated settings.
    • withDurability

      public TransactionSettings withDurability(DurabilityLevel durability)
      Sets the durability level (see withDurability(Integer)) to a symbolic value.
      Parameters:
      durability - Durability level name or null, meaning "use the default value configured on the server".
      Returns:
      A fresh config instance with updated settings.
    • withDistributedTransactionTimeout

      public TransactionSettings withDistributedTransactionTimeout(Integer distributedTransactionTimeout)
      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 or null. null means 'use server config').
      Returns:
      A fresh config instance with updated settings.
    • withTransactionLatencyCount

      public TransactionSettings withTransactionLatencyCount(Integer transactionLatencyCount)
      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 or null (use server default).
      Returns:
      A fresh config instance with updated settings.
    • withTransactionLatencyTimeout

      public TransactionSettings withTransactionLatencyTimeout(Integer transactionLatencyTimeout)
      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 or null (use server default).
      Returns:
      A fresh config instance with updated settings.