Class TransactionConfiguration
- java.lang.Object
-
- org.infinispan.configuration.cache.TransactionConfiguration
-
- All Implemented Interfaces:
Matchable<TransactionConfiguration>
public class TransactionConfiguration extends Object implements Matchable<TransactionConfiguration>
Defines transactional (JTA) characteristics of the cache.- Author:
- pmuir, Pedro Ruivo
-
-
Field Summary
Fields Modifier and Type Field Description static AttributeDefinition<Boolean>
AUTO_COMMIT
static AttributeDefinition<Long>
CACHE_STOP_TIMEOUT
static AttributeDefinition<Long>
COMPLETED_TX_TIMEOUT
static AttributeDefinition<LockingMode>
LOCKING_MODE
static AttributeDefinition<Boolean>
NOTIFICATIONS
static AttributeDefinition<Long>
REAPER_WAKE_UP_INTERVAL
static AttributeDefinition<TransactionManagerLookup>
TRANSACTION_MANAGER_LOOKUP
static AttributeDefinition<TransactionMode>
TRANSACTION_MODE
static AttributeDefinition<TransactionProtocol>
TRANSACTION_PROTOCOL
static AttributeDefinition<TransactionSynchronizationRegistryLookup>
TRANSACTION_SYNCHRONIZATION_REGISTRY_LOOKUP
static AttributeDefinition<Boolean>
USE_1_PC_FOR_AUTO_COMMIT_TRANSACTIONS
static AttributeDefinition<Boolean>
USE_SYNCHRONIZATION
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AttributeSet
attributes()
boolean
autoCommit()
If the cache is transactional (i.e.long
cacheStopTimeout()
If there are any ongoing transactions when a cache is stopped, Infinispan waits for ongoing remote and local transactions to finish.TransactionConfiguration
cacheStopTimeout(long l)
If there are any ongoing transactions when a cache is stopped, Infinispan waits for ongoing remote and local transactions to finish.long
completedTxTimeout()
boolean
equals(Object obj)
int
hashCode()
LockingMode
lockingMode()
Configures whether the cache uses optimistic or pessimistic locking.TransactionConfiguration
lockingMode(LockingMode lockingMode)
Configures whether the cache uses optimistic or pessimistic locking.boolean
notifications()
long
reaperWakeUpInterval()
RecoveryConfiguration
recovery()
This method allows configuration of the transaction recovery cache.boolean
syncCommitPhase()
Deprecated.since 9.0.TransactionConfiguration
syncCommitPhase(boolean b)
Deprecated.The syncRollbackPhase setting can no longer be modified at runtime.boolean
syncRollbackPhase()
Deprecated.since 9.0.TransactionConfiguration
syncRollbackPhase(boolean b)
Deprecated.The syncRollbackPhase setting can no longer be modified at runtime.String
toString()
TransactionManagerLookup
transactionManagerLookup()
Configure Transaction manager lookup directly using an instance of TransactionManagerLookup.TransactionConfiguration
transactionManagerLookup(TransactionManagerLookup transactionManagerLookup)
Deprecated.since 9.0.TransactionMode
transactionMode()
TransactionProtocol
transactionProtocol()
TransactionSynchronizationRegistryLookup
transactionSynchronizationRegistryLookup()
Configure Transaction Synchronization Registry lookup directly using an instance of TransactionManagerLookup.boolean
use1PcForAutoCommitTransactions()
Before Infinispan 5.1 you could access the cache both transactionally and non-transactionally.boolean
useSynchronization()
-
-
-
Field Detail
-
AUTO_COMMIT
public static final AttributeDefinition<Boolean> AUTO_COMMIT
-
CACHE_STOP_TIMEOUT
public static final AttributeDefinition<Long> CACHE_STOP_TIMEOUT
-
LOCKING_MODE
public static final AttributeDefinition<LockingMode> LOCKING_MODE
-
TRANSACTION_MANAGER_LOOKUP
public static final AttributeDefinition<TransactionManagerLookup> TRANSACTION_MANAGER_LOOKUP
-
TRANSACTION_SYNCHRONIZATION_REGISTRY_LOOKUP
public static final AttributeDefinition<TransactionSynchronizationRegistryLookup> TRANSACTION_SYNCHRONIZATION_REGISTRY_LOOKUP
-
TRANSACTION_MODE
public static final AttributeDefinition<TransactionMode> TRANSACTION_MODE
-
USE_SYNCHRONIZATION
public static final AttributeDefinition<Boolean> USE_SYNCHRONIZATION
-
USE_1_PC_FOR_AUTO_COMMIT_TRANSACTIONS
public static final AttributeDefinition<Boolean> USE_1_PC_FOR_AUTO_COMMIT_TRANSACTIONS
-
REAPER_WAKE_UP_INTERVAL
public static final AttributeDefinition<Long> REAPER_WAKE_UP_INTERVAL
-
COMPLETED_TX_TIMEOUT
public static final AttributeDefinition<Long> COMPLETED_TX_TIMEOUT
-
TRANSACTION_PROTOCOL
public static final AttributeDefinition<TransactionProtocol> TRANSACTION_PROTOCOL
-
NOTIFICATIONS
public static final AttributeDefinition<Boolean> NOTIFICATIONS
-
-
Method Detail
-
autoCommit
public boolean autoCommit()
If the cache is transactional (i.e.transactionMode()
== TransactionMode.TRANSACTIONAL) and transactionAutoCommit is enabled then for single operation transactions the user doesn't need to manually start a transaction, but a transactions is injected by the system. Defaults to true.
-
cacheStopTimeout
public TransactionConfiguration cacheStopTimeout(long l)
If there are any ongoing transactions when a cache is stopped, Infinispan waits for ongoing remote and local transactions to finish. The amount of time to wait for is defined by the cache stop timeout. It is recommended that this value does not exceed the transaction timeout because even if a new transaction was started just before the cache was stopped, this could only last as long as the transaction timeout allows it.
-
cacheStopTimeout
public long cacheStopTimeout()
If there are any ongoing transactions when a cache is stopped, Infinispan waits for ongoing remote and local transactions to finish. The amount of time to wait for is defined by the cache stop timeout. It is recommended that this value does not exceed the transaction timeout because even if a new transaction was started just before the cache was stopped, this could only last as long as the transaction timeout allows it.
-
lockingMode
public LockingMode lockingMode()
Configures whether the cache uses optimistic or pessimistic locking. If the cache is not transactional then the locking mode is ignored.- See Also:
transactionMode()
-
lockingMode
public TransactionConfiguration lockingMode(LockingMode lockingMode)
Configures whether the cache uses optimistic or pessimistic locking. If the cache is not transactional then the locking mode is ignored.- See Also:
transactionMode()
-
syncCommitPhase
@Deprecated public boolean syncCommitPhase()
Deprecated.since 9.0. no longer supportedIf true, the cluster-wide commit phase in two-phase commit (2PC) transactions will be synchronous, so Infinispan will wait for responses from all nodes to which the commit was sent. Otherwise, the commit phase will be asynchronous. Keeping it as false improves performance of 2PC transactions, but it can lead to inconsistencies when the primary owner releases the lock before the backup commits the change.
-
syncCommitPhase
@Deprecated public TransactionConfiguration syncCommitPhase(boolean b)
Deprecated.The syncRollbackPhase setting can no longer be modified at runtime. It must be the same on all nodes.If true, the cluster-wide commit phase in two-phase commit (2PC) transactions will be synchronous, so Infinispan will wait for responses from all nodes to which the commit was sent. Otherwise, the commit phase will be asynchronous. Keeping it as false improves performance of 2PC transactions, but it can lead to inconsistencies when the primary owner releases the lock before the backup commits the change.
-
syncRollbackPhase
@Deprecated public boolean syncRollbackPhase()
Deprecated.since 9.0. no longer supportedIf true, the cluster-wide rollback phase in two-phase commit (2PC) transactions will be synchronous, so Infinispan will wait for responses from all nodes to which the rollback was sent. Otherwise, the rollback phase will be asynchronous. Keeping it as false improves performance of 2PC transactions.
-
syncRollbackPhase
@Deprecated public TransactionConfiguration syncRollbackPhase(boolean b)
Deprecated.The syncRollbackPhase setting can no longer be modified at runtime. It must be the same on all nodes.If true, the cluster-wide rollback phase in two-phase commit (2PC) transactions will be synchronous, so Infinispan will wait for responses from all nodes to which the rollback was sent.
-
transactionManagerLookup
public TransactionManagerLookup transactionManagerLookup()
Configure Transaction manager lookup directly using an instance of TransactionManagerLookup. Calling this method marks the cache as transactional.
-
transactionManagerLookup
@Deprecated public TransactionConfiguration transactionManagerLookup(TransactionManagerLookup transactionManagerLookup)
Deprecated.since 9.0. The transaction manager is only looked up once, during cache startup.
-
transactionSynchronizationRegistryLookup
public TransactionSynchronizationRegistryLookup transactionSynchronizationRegistryLookup()
Configure Transaction Synchronization Registry lookup directly using an instance of TransactionManagerLookup. Calling this method marks the cache as transactional.
-
transactionMode
public TransactionMode transactionMode()
-
useSynchronization
public boolean useSynchronization()
-
recovery
public RecoveryConfiguration recovery()
This method allows configuration of the transaction recovery cache. When this method is called, it automatically enables recovery. So, if you want it to be disabled, make sure you callRecoveryConfigurationBuilder.enabled(boolean)
with false as parameter
-
reaperWakeUpInterval
public long reaperWakeUpInterval()
-
completedTxTimeout
public long completedTxTimeout()
-
use1PcForAutoCommitTransactions
public boolean use1PcForAutoCommitTransactions()
Before Infinispan 5.1 you could access the cache both transactionally and non-transactionally. Naturally the non-transactional access is faster and offers less consistency guarantees. From Infinispan 5.1 onwards, mixed access is no longer supported, so if you wanna speed up transactional caches and you're ready to trade some consistency guarantees, you can enable use1PcForAutoCommitTransactions. What this configuration option does is force an induced transaction, that has been started by Infinispan as a result of enabling autoCommit, to commit in a single phase. So only 1 RPC instead of 2RPCs as in the case of a full 2 Phase Commit (2PC). N.B. this option should NOT be used when modifying the same key from multiple transactions as 1PC does not offer any consistency guarantees under concurrent access.
-
transactionProtocol
public TransactionProtocol transactionProtocol()
- Returns:
- the transaction protocol in use (2PC or Total Order)
-
notifications
public boolean notifications()
- Returns:
- are transactional notifications (
TransactionRegistered
andTransactionCompleted
) triggered?
-
attributes
public AttributeSet attributes()
-
-