Class DbTransactionFactory
java.lang.Object
org.tentackle.dbms.DbTransactionFactory
Factory for transactions.
Collects duration statistics and monitors transactions.
Collects duration statistics and monitors transactions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(EncryptedProperties properties) Configures the factory from the main session properties.Creates a transaction.
Notice that this method is only invoked for local sessions, never for remote sessions.protected longcreateVoucher(boolean fromRemote) Creates a new transaction voucher.voidfinish(DbTransaction transaction, boolean rolledBack) Finishes a transaction.
Invoked when a transaction is committed or rolled back.
Notice that this method is only invoked for local sessions, never for remote sessions.static DbTransactionFactoryThe singleton.longGets the check interval for idle or unreferenced transactions in ms.intGets the number of check intervals that must elapse for an idle transaction to time out.booleanReturns whether statistics are collected.booleanReturns whether the supervisor thread is running.voidlogStatistics(Logger.Level level, boolean clear) Logs the statistics.voidRequests supervisor thread termination.
If transactions are still running, the supervisor keeps running until they are finished or timed out.voidsetCollectingStatistics(boolean collectingStatistics) Sets whether statistics should be collected.voidsetTxIdleInterval(long txIdleInterval) Sets the check interval for idle or unreferenced transactions in ms.voidsetTxIdleTimeout(int txIdleTimeout) Sets the number of check intervals that must elapse for an idle transaction to time out.
-
Constructor Details
-
DbTransactionFactory
public DbTransactionFactory()Creates the transaction factory.
-
-
Method Details
-
getInstance
-
configure
Configures the factory from the main session properties.- Parameters:
properties- the properties
-
create
Creates a transaction.
Notice that this method is only invoked for local sessions, never for remote sessions.- Parameters:
db- the sessiontxName- the transaction name, null if <unnamed>fromRemote- true if initiated from the remote client- Returns:
- the transaction
-
finish
Finishes a transaction.
Invoked when a transaction is committed or rolled back.
Notice that this method is only invoked for local sessions, never for remote sessions.- Parameters:
transaction- the transactionrolledBack- true if transaction was rolled back, false if committed
-
setCollectingStatistics
public void setCollectingStatistics(boolean collectingStatistics) Sets whether statistics should be collected.- Parameters:
collectingStatistics- true if transactions are counted and execution times measured
-
isCollectingStatistics
public boolean isCollectingStatistics()Returns whether statistics are collected.- Returns:
- true if transactions are counted and execution times measured
-
logStatistics
Logs the statistics.- Parameters:
level- the logging levelclear- true if clear statistics after dump
-
getTxIdleInterval
public long getTxIdleInterval()Gets the check interval for idle or unreferenced transactions in ms.- Returns:
- the check interval
-
setTxIdleInterval
public void setTxIdleInterval(long txIdleInterval) Sets the check interval for idle or unreferenced transactions in ms.- Parameters:
txIdleInterval- the check interval
-
getTxIdleTimeout
public int getTxIdleTimeout()Gets the number of check intervals that must elapse for an idle transaction to time out.- Returns:
- the idle count
-
setTxIdleTimeout
public void setTxIdleTimeout(int txIdleTimeout) Sets the number of check intervals that must elapse for an idle transaction to time out.- Parameters:
txIdleTimeout- the idle count, ≤ 0 to disable
-
requestTermination
public void requestTermination()Requests supervisor thread termination.
If transactions are still running, the supervisor keeps running until they are finished or timed out. The supervisor is started again when the next transaction is created. -
isSupervisorRunning
public boolean isSupervisorRunning()Returns whether the supervisor thread is running.- Returns:
- true if running, false if not started yet or terminated
-
createVoucher
protected long createVoucher(boolean fromRemote) Creates a new transaction voucher.- Parameters:
fromRemote- true if the transaction was started at the remote client- Returns:
- the voucher
-