public final class NGTransaction extends AbstractTransaction implements NGTransactionMBean
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
,
Repository
,
FileRepository
,
DBRepository
,
MySqlDBRepository
Modifier and Type | Class and Description |
---|---|
static class |
NGTransaction.LogFile |
(package private) static class |
NGTransaction.LogManager
This class manages the memory log of operations and the multiples
log files.
|
AbstractTransaction.Context
Modifier and Type | Field and Description |
---|---|
(package private) NGTransaction.LogManager |
logManager |
(package private) static int |
LogMemoryCapacity
Global in memory log initial capacity, by default 4096.
|
(package private) int |
LogThresholdOperation
Number of pooled operation, by default 1000.
|
(package private) static int |
MaxLogFileSize
Maximum size of disk log in Mb, by default 16Mb.
|
(package private) static int |
minObjInLog
Minimum number of 'live' objects in a disk log before a garbage, by
default 64.
|
(package private) static int |
nbLogFile
Maximum number of disk log used by the Transaction component, by
default 4.
|
(package private) Repository |
repository |
(package private) String |
repositoryImpl
The Repository classname implementation.
|
(package private) boolean |
syncOnWrite
If true every write in the log file is synced to disk, by default
false.
|
(package private) boolean |
useLockFile
If true (default) use a lock file to avoid multiples activation of Transaction
component.
|
dir, OOS_STREAM_HEADER, perThreadContext, phase, startTime
logmon
Constructor and Description |
---|
NGTransaction() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the transaction module.
|
void |
commit(boolean release)
Commit the current transaction.
|
void |
delete(String dirName,
String name)
Deletes the specified object.
|
void |
garbage(int idx) |
int |
getCommitCount()
Returns the number of commit operation since starting up.
|
private byte[] |
getFromLog(Hashtable log,
Object key) |
private byte[] |
getFromLog(String dirName,
String name) |
int |
getGarbageCount()
Returns the number of garbage operation since starting up.
|
int |
getGarbageRatio()
Returns the ratio of garbage operations since starting up.
|
long |
getGarbageTime()
Returns the cumulated time of garbage operations since starting up.
|
String[] |
getList(String prefix)
Returns an array of strings naming the persistent objects denoted by
a name that satisfy the specified prefix.
|
int |
getLogFileSize()
Returns the current size of disk log in Kb.
|
int |
getLogMemoryCapacity()
Returns the initial capacity of global in memory log (by default 4096).
|
int |
getLogMemorySize()
Returns the number of operation in the memory log.
|
int |
getLogThresholdOperation()
Returns the pool size for
operation objects, by default 1000. |
int |
getMaxLogFileSize()
Returns the maximum size of disk log in Mb, by default 16Mb.
|
int |
getNbBadDeletedObjects()
Returns the number of useless delete operation on repository.
|
int |
getNbDeletedObjects()
Returns the number of delete operation on repository.
|
int |
getNbLoadedFromLog()
Returns the number of load operation from a log file since last start.
|
int |
getNbLoadedObjects()
Returns the number of load operation from repository.
|
int |
getNbLogFiles()
Returns the number of rolled log files.
|
int |
getNbSavedObjects()
Returns the number of save operation to repository.
|
String |
getPersistenceDir()
Returns the path of persistence directory.
|
String |
getRepositoryImpl()
Returns the Repository classname implementation.
|
void |
initRepository() |
boolean |
isSyncOnWrite()
Returns true if every write in the log file is synced to disk.
|
byte[] |
loadByteArray(String dirName,
String name)
Load the specified byte array.
|
String |
logContent(int idx) |
String |
logCounters() |
void |
resetGarbageRatio() |
protected void |
saveInLog(byte[] buf,
String dirName,
String name,
Hashtable log,
boolean copy,
boolean first)
Save an object state already serialized.
|
void |
setMaxLogFileSize(int size)
Sets the maximum size of disk log in Mb.
|
protected void |
setPhase(int newPhase)
Changes the transaction state.
|
void |
stop()
Stops the transaction module.
|
String |
toString()
Returns a string representation for this object.
|
begin, containsOperations, create, create, createByteArray, createByteArray, delete, getOperationCount, getPhase, getPhaseInfo, getStartTime, init, isPersistent, load, load, loadAll, loadByteArray, loadFromByteArray, release, save, save, save, saveByteArray, saveByteArray, saveByteArray, useLoadAll
freeze, getBoolean, getInteger, getInteger, getProperty, getProperty, loadProperties, saveProperties
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getPhase, getPhaseInfo, getStartTime, isPersistent
static int LogMemoryCapacity
Transaction.LogMemoryCapacity
specific property.
This property can be set only at first launching.
static int MaxLogFileSize
Transaction.MaxLogFileSize
specific property.
This property can be set only at first launching.
static int nbLogFile
Transaction.NbLogFile
specific property.
This property can be set only at first launching.
static int minObjInLog
Transaction.minObjInLog
specific property.
This property can be set only at first launching.
boolean syncOnWrite
Transaction.SyncOnWrite
specific property.
This property can be set only at first launching.
boolean useLockFile
Transaction.UseLockFile
specific property.
This property can be set only at first launching.
int LogThresholdOperation
Transaction.LogThresholdOperation
specific property.
This property can be set only at first launching.
String repositoryImpl
Transaction.RepositoryImpl
specific property. By default its value
is "fr.dyade.aaa.util.FileRepository".
This property can be set only at first launching.
NGTransaction.LogManager logManager
Repository repository
public final int getLogMemoryCapacity()
getLogMemoryCapacity
in interface NGTransactionMBean
public int getLogMemorySize()
getLogMemorySize
in interface NGTransactionMBean
public final int getMaxLogFileSize()
getMaxLogFileSize
in interface NGTransactionMBean
public final void setMaxLogFileSize(int size)
setMaxLogFileSize
in interface NGTransactionMBean
size
- The maximum size of disk log in Mb.public final int getLogFileSize()
getLogFileSize
in interface NGTransactionMBean
public final int getNbLogFiles()
getNbLogFiles
in interface NGTransactionMBean
public boolean isSyncOnWrite()
NGTransactionMBean
isSyncOnWrite
in interface NGTransactionMBean
public final int getLogThresholdOperation()
operation
objects, by default 1000.getLogThresholdOperation
in interface NGTransactionMBean
operation
objects.public final int getCommitCount()
getCommitCount
in interface Transaction
getCommitCount
in interface TransactionMBean
public final int getGarbageCount()
getGarbageCount
in interface NGTransactionMBean
public long getGarbageTime()
getGarbageTime
in interface NGTransactionMBean
public int getNbLoadedFromLog()
getNbLoadedFromLog
in interface NGTransactionMBean
public int getGarbageRatio()
getGarbageRatio
in interface NGTransactionMBean
public void resetGarbageRatio()
public String getRepositoryImpl()
getRepositoryImpl
in interface NGTransactionMBean
public int getNbSavedObjects()
getNbSavedObjects
in interface NGTransactionMBean
public int getNbDeletedObjects()
getNbDeletedObjects
in interface NGTransactionMBean
public int getNbBadDeletedObjects()
getNbBadDeletedObjects
in interface NGTransactionMBean
public int getNbLoadedObjects()
getNbLoadedObjects
in interface NGTransactionMBean
public final void initRepository() throws IOException
initRepository
in class AbstractTransaction
IOException
public String getPersistenceDir()
protected final void setPhase(int newPhase)
AbstractTransaction
setPhase
in class AbstractTransaction
newPhase
- the new transaction state.public String[] getList(String prefix)
getList
in interface Transaction
prefix
- the prefixprotected final void saveInLog(byte[] buf, String dirName, String name, Hashtable log, boolean copy, boolean first) throws IOException
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.private final byte[] getFromLog(Hashtable log, Object key) throws IOException
IOException
private final byte[] getFromLog(String dirName, String name) throws IOException
IOException
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 final void delete(String dirName, String name)
Transaction
delete
in interface Transaction
dirName
- the directory name of the object.name
- the name of the object.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.public void stop()
stop
in interface Transaction
public void close()
close
in interface Transaction
public String toString()
public String logCounters()
logCounters
in interface NGTransactionMBean
public String logContent(int idx) throws IOException
logContent
in interface NGTransactionMBean
IOException
public void garbage(int idx) throws IOException
garbage
in interface NGTransactionMBean
IOException
Copyright © 2020 ScalAgent D.T.. All rights reserved.