public abstract class DBTransaction extends AbstractTransaction implements DBTransactionMBean
Be Careful, the configuration properties don't work for the transaction component: these properties are saved in the transaction repository so they can not be used to configure it.
Transaction
,
MySQLDBTransaction
,
DerbyDBTransaction
AbstractTransaction.Context
Modifier and Type | Field and Description |
---|---|
(package private) int |
badinserts |
(package private) int |
badupdates |
private long |
commitBytes
Number of bytes written in commit.
|
private int |
commitCount
Number of commit operation since starting up.
|
protected Connection |
conn |
protected int |
connectRetryCount |
protected long |
connectRetryMaxPeriod |
protected long |
connectRetryMinDelay |
static String |
DB_TRANSACTION_PREFIX |
protected String |
dbclose |
protected String |
dbdelete |
protected String |
dbinsert |
protected String |
dbload |
protected String |
dbtable |
protected String |
dbupdate |
private PreparedStatement |
deleteStmt |
static String |
DFLT_TABLE_PREFIX |
private PreparedStatement |
insertStmt |
protected int |
JDBC_CONNECT_RETRY_COUNT_DFLT |
protected long |
JDBC_CONNECT_RETRY_MAX_PERIOD_DFLT |
protected long |
JDBC_CONNECT_RETRY_MIN_DELAY_DFLT |
private PreparedStatement |
loadStmt |
(package private) static int |
LogThresholdOperation
Number of pooled operation, by default 1000.
|
(package private) int |
nbdeletes |
(package private) int |
nbinserts |
(package private) int |
nbnoop |
(package private) int |
nbupdates |
static String |
TABLE_NAME_PROP |
private PreparedStatement |
updateStmt |
dir, OOS_STREAM_HEADER, perThreadContext, phase, startTime
logmon
Constructor and Description |
---|
DBTransaction() |
Modifier and Type | Method and Description |
---|---|
String |
backup(String path)
Backups the content of Transaction module.
|
void |
close()
Close the transaction module.
|
void |
commit(boolean release)
Commit the current transaction.
|
protected abstract void |
connectDB()
This method try to reconnect to the database, it is used in case of failure during commit.
|
private void |
createPreparedStatement() |
private void |
dbLogCommit(Hashtable<String,DBOperation> log)
Executes all SQL statements corresponding to log operations, and the commit.
|
private void |
dbLogExecute(Hashtable<String,DBOperation> log)
Executes all SQL statements corresponding to log operations.
|
void |
delete(String dirName,
String name)
Deletes the specified object.
|
String |
dumpProperties()
Returns the configuration properties of the component.
|
protected void |
dumpProperties(StringBuilder strbuf) |
(package private) String |
fname(String dirName,
String name) |
int |
getBadInserts()
Returns the number of bad inserts in database since last boot (record already existing).
|
int |
getBadUpdates()
Returns the number of bad updates in database since last boot (record needing to be inserted)..
|
long |
getCommitBytes()
Returns the number of bytes written to database since last boot.
|
int |
getCommitCount()
Returns the number of commit operation since last boot.
|
String |
getDBCloseStatement() |
String |
getDBDeleteStatement() |
String |
getDBInsertStatement() |
String |
getDBLoadStatement() |
String |
getDBTableName() |
String |
getDBUpdateStatement() |
byte[] |
getFromLog(String name) |
String[] |
getList(String prefix)
Returns an array of strings naming the persistent objects denoted by
a name that satisfy the specified prefix.
|
int |
getLogThresholdOperation()
Returns the pool size for
operation objects, by default 1000. |
int |
getNbDeletes()
Returns the number of deletes in database since last boot.
|
int |
getNbInserts()
Returns the number of inserts in database since last boot.
|
int |
getNbUpdates()
Returns the number of updates in database since last boot.
|
String |
getObject(String dirname,
String name)
Only use with MBean.
|
String |
getObjectList(String prefix)
Only use with MBean.
|
String |
getPersistenceDir()
Returns the path of persistence directory.
|
protected abstract void |
initDB()
Instantiates the database driver and creates the table if necessary
|
void |
initRepository() |
void |
loadAll(String prefix,
Map map)
Fills the map with all objects of the component whose name begins with the prefix.
|
byte[] |
loadByteArray(String dirName,
String name)
Load the specified byte array.
|
protected void |
saveInLog(byte[] buf,
String dirName,
String name,
Hashtable log,
boolean copy,
boolean first)
Register the specified object in transaction log.
|
protected void |
setPhase(int newPhase)
Changes the transaction state.
|
void |
stop()
Stops the transaction module.
|
boolean |
useLoadAll()
Returns true if this Transaction implementation implements an optimized loadAll method.
|
begin, containsOperations, create, create, createByteArray, createByteArray, delete, getOperationCount, getPhase, getPhaseInfo, getStartTime, init, isPersistent, load, load, loadByteArray, loadFromByteArray, release, save, save, save, saveByteArray, saveByteArray, saveByteArray
freeze, getBoolean, getInteger, getInteger, getProperty, getProperty, loadProperties, saveProperties
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPhase, getPhaseInfo
getStartTime, isPersistent
public static final String DB_TRANSACTION_PREFIX
public static final String TABLE_NAME_PROP
public static final String DFLT_TABLE_PREFIX
protected String dbtable
static int LogThresholdOperation
DBLogThresholdOperation
specific property.
This property can be fixed only from java
launching
command, or through System.property method.
protected Connection conn
protected String dbinsert
protected String dbupdate
protected String dbload
protected String dbdelete
protected String dbclose
private PreparedStatement insertStmt
private PreparedStatement updateStmt
private PreparedStatement loadStmt
private PreparedStatement deleteStmt
private int commitCount
private long commitBytes
protected final int JDBC_CONNECT_RETRY_COUNT_DFLT
protected int connectRetryCount
protected final long JDBC_CONNECT_RETRY_MAX_PERIOD_DFLT
protected long connectRetryMaxPeriod
protected final long JDBC_CONNECT_RETRY_MIN_DELAY_DFLT
protected long connectRetryMinDelay
int nbinserts
int badinserts
int nbupdates
int badupdates
int nbdeletes
int nbnoop
public String getDBTableName()
getDBTableName
in interface DBTransactionMBean
public int getLogThresholdOperation()
operation
objects, by default 1000.getLogThresholdOperation
in interface DBTransactionMBean
operation
objects.public String getDBInsertStatement()
getDBInsertStatement
in interface DBTransactionMBean
public String getDBUpdateStatement()
getDBUpdateStatement
in interface DBTransactionMBean
public String getDBLoadStatement()
getDBLoadStatement
in interface DBTransactionMBean
public String getDBDeleteStatement()
getDBDeleteStatement
in interface DBTransactionMBean
public String getDBCloseStatement()
getDBCloseStatement
in interface DBTransactionMBean
public void initRepository() throws IOException
initRepository
in class AbstractTransaction
IOException
private void createPreparedStatement() throws IOException
IOException
protected abstract void initDB() throws IOException
IOException
- an error occurs.public String getPersistenceDir()
protected final void setPhase(int newPhase)
AbstractTransaction
setPhase
in class AbstractTransaction
newPhase
- the new transaction state.public final int getCommitCount()
getCommitCount
in interface Transaction
getCommitCount
in interface TransactionMBean
public final long getCommitBytes()
getCommitBytes
in interface DBTransactionMBean
public String getObjectList(String prefix)
getObjectList
in interface DBTransactionMBean
public final String[] getList(String prefix)
getList
in interface Transaction
prefix
- the prefixpublic byte[] getFromLog(String name) throws IOException
IOException
public boolean useLoadAll()
useLoadAll
in interface Transaction
useLoadAll
in interface TransactionMBean
useLoadAll
in class AbstractTransaction
public void loadAll(String prefix, Map map)
loadAll
in interface Transaction
loadAll
in class AbstractTransaction
prefix
- The prefix of searched objects.map
- The map of corresponding objects.protected final void saveInLog(byte[] buf, String dirName, String name, Hashtable log, boolean copy, boolean first) throws IOException
AbstractTransaction
saveInLog
in class AbstractTransaction
buf
- the byte array containing the state of the object.dirName
- the directory name of the object.name
- the name of the object.log
- the log to use.copy
- the byte array can be modified, copy it.first
- the object is a new one.IOException
- an error occurs.public String getObject(String dirname, String name)
getObject
in interface DBTransactionMBean
public byte[] loadByteArray(String dirName, String name) throws IOException
Transaction
loadByteArray
in interface Transaction
dirName
- the directory name of the object.name
- the name of the object.IOException
- an error occurs.public void delete(String dirName, String name)
Transaction
delete
in interface Transaction
dirName
- the directory name of the object.name
- the name of the object.protected abstract void connectDB() throws IOException
IOException
- The reconnection has failed.public final void commit(boolean release) throws IOException
Transaction
commit
in interface Transaction
release
- if true releases the transaction at the end of the commit.IOException
- an error occurs.private void dbLogCommit(Hashtable<String,DBOperation> log) throws SQLException
log
- Hashtable containing all operations to commit.SQLException
- an error occurs.public final int getNbInserts()
getNbInserts
in interface DBTransactionMBean
public final int getBadInserts()
getBadInserts
in interface DBTransactionMBean
public final int getNbUpdates()
getNbUpdates
in interface DBTransactionMBean
public int getBadUpdates()
getBadUpdates
in interface DBTransactionMBean
public final int getNbDeletes()
getNbDeletes
in interface DBTransactionMBean
private void dbLogExecute(Hashtable<String,DBOperation> log) throws SQLException
log
- Hashtable containing all operations to commit.SQLException
- an error occurs.public void stop()
stop
in interface Transaction
public void close()
close
in interface Transaction
public String dumpProperties()
DBTransactionMBean
dumpProperties
in interface DBTransactionMBean
protected void dumpProperties(StringBuilder strbuf)
public String backup(String path) throws Exception
backup
in interface Transaction
backup
in interface TransactionMBean
path
- Directory path to store the backup.Exception
- An error occurs during backup.Copyright © 2022 ScalAgent D.T.. All rights reserved.