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 |
connectRetryDelay |
static String |
DB_TRANSACTION_PREFIX |
protected String |
dbclose |
protected String |
dbdelete |
protected String |
dbinsert |
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_DELAY_DFLT |
(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 |
---|---|
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.
|
(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 |
getDBTableName() |
String |
getDBUpdateStatement() |
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() |
boolean |
isPersistent()
Tests if the Transaction component is persistent.
|
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.
|
begin, containsOperations, create, create, createByteArray, createByteArray, delete, getOperationCount, getPhase, getPhaseInfo, getStartTime, init, load, load, loadByteArray, 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
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 dbdelete
protected String dbclose
private PreparedStatement insertStmt
private PreparedStatement updateStmt
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_DELAY_DFLT
protected long connectRetryDelay
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 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
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 boolean isPersistent()
isPersistent
in interface Transaction
isPersistent
in interface TransactionMBean
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
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
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
private void dbLogCommit(Hashtable<String,DBOperation> log) throws SQLException
log
- Hashtable containing all operations to commit.SQLException
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
public void stop()
stop
in interface Transaction
public void close()
close
in interface Transaction
Copyright © 2019 ScalAgent D.T.. All rights reserved.