public final class NTransaction extends AbstractTransaction implements NTransactionMBean
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 |
---|---|
private class |
NTransaction.GarbageTask |
(package private) static class |
NTransaction.LogFile |
AbstractTransaction.Context
Modifier and Type | Field and Description |
---|---|
(package private) static boolean |
debug |
(package private) NTransaction.LogFile |
logFile |
(package private) static int |
LogMemoryCapacity
Global in memory log initial capacity, by default 4096.
|
(package private) static int |
LogThresholdOperation
Number of pooled operation, by default 1000.
|
(package private) static int |
MaxLogFileSize
Size of disk log in Mb, by default 16Mb.
|
(package private) static int |
MaxLogMemorySize
Maximum size of memory log, by default 2048Kb.
|
(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.
|
private NTransaction.GarbageTask |
task |
private Timer |
timer |
(package private) boolean |
useLockFile
If true use a lock file to avoid multiples activation of Transaction
component.
|
dir, OOS_STREAM_HEADER, perThreadContext, phase, startTime
logmon
Constructor and Description |
---|
NTransaction() |
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()
Garbage the log file.
|
void |
garbageAsync(boolean async)
Sets asynchronous garbage.
|
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 |
getGarbageDelay()
Returns the maximum time between two garbages, 0 if disable.
|
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 size of disk log in Kb.
|
int |
getLogMemoryCapacity()
Returns the initial capacity of global in memory log (by default 4096).
|
int |
getLogMemorySize()
Returns the size of memory log in bytes.
|
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 |
getMaxLogMemorySize()
Returns the maximum size of memory log in Kb, by default 2048Kb.
|
int |
getNbBadDeletedObjects()
Returns the number of useless delete operation on repository.
|
int |
getNbDeletedObjects()
Returns the number of delete operation on repository.
|
int |
getNbLoadedObjects()
Returns the number of load operation from repository.
|
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 |
isGarbageRunning()
Returns the status of the garbage thread.
|
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.
|
static void |
main(String[] args) |
protected void |
saveInLog(byte[] buf,
String dirName,
String name,
Hashtable log,
boolean copy,
boolean first)
Save an object state already serialized.
|
void |
setGarbageDelay(int timeout)
Sets the maximum time between two garbages, 0 to disable the
asynchronous garbage mechanism.
|
void |
setMaxLogFileSize(int size)
Sets the maximum size of disk log in Mb.
|
void |
setMaxLogMemorySize(int size)
Sets the maximum size of memory log in Kb.
|
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
NTLogMemoryCapacity
specific property.
This property can be set only at first launching.
static int MaxLogMemorySize
NTLogMemorySize
specific property.
This property can be set only at first launching.
static int MaxLogFileSize
NTLogFileSize
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.
static int LogThresholdOperation
NTLogThresholdOperation
specific property.
This property can be set only at first launching.
private Timer timer
private NTransaction.GarbageTask task
String repositoryImpl
NTRepositoryImpl
specific property. By default its value
is "fr.dyade.aaa.util.FileRepository".
This property can be set only at first launching.
NTransaction.LogFile logFile
Repository repository
static final boolean debug
public final int getLogMemoryCapacity()
getLogMemoryCapacity
in interface NTransactionMBean
public final int getMaxLogMemorySize()
getMaxLogMemorySize
in interface NTransactionMBean
public final void setMaxLogMemorySize(int size)
setMaxLogMemorySize
in interface NTransactionMBean
size
- The maximum size of memory log in Kb.public final int getLogMemorySize()
getLogMemorySize
in interface NTransactionMBean
public final int getMaxLogFileSize()
getMaxLogFileSize
in interface NTransactionMBean
public final void setMaxLogFileSize(int size)
setMaxLogFileSize
in interface NTransactionMBean
size
- The maximum size of disk log in Mb.public final int getLogFileSize()
getLogFileSize
in interface NTransactionMBean
public boolean isSyncOnWrite()
NTransactionMBean
isSyncOnWrite
in interface NTransactionMBean
public final int getLogThresholdOperation()
operation
objects, by default 1000.getLogThresholdOperation
in interface NTransactionMBean
operation
objects.public final int getCommitCount()
getCommitCount
in interface Transaction
getCommitCount
in interface TransactionMBean
public final int getGarbageCount()
getGarbageCount
in interface NTransactionMBean
public final int getGarbageDelay()
getGarbageDelay
in interface NTransactionMBean
public final void setGarbageDelay(int timeout)
setGarbageDelay
in interface NTransactionMBean
timeout
- The maximum time between two garbages.public final boolean isGarbageRunning()
isGarbageRunning
in interface NTransactionMBean
public void garbageAsync(boolean async)
garbageAsync
in interface NTransactionMBean
async
- If true activates the asynchronous garbage,
deactivates otherwise.public long getGarbageTime()
getGarbageTime
in interface NTransactionMBean
public int getGarbageRatio()
getGarbageRatio
in interface NTransactionMBean
public String getRepositoryImpl()
getRepositoryImpl
in interface NTransactionMBean
public int getNbSavedObjects()
getNbSavedObjects
in interface NTransactionMBean
public int getNbDeletedObjects()
getNbDeletedObjects
in interface NTransactionMBean
public int getNbBadDeletedObjects()
getNbBadDeletedObjects
in interface NTransactionMBean
public int getNbLoadedObjects()
getNbLoadedObjects
in interface NTransactionMBean
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 final void garbage()
garbage
in interface NTransactionMBean
public void stop()
stop
in interface Transaction
public void close()
close
in interface Transaction
public String toString()
Copyright © 2020 ScalAgent D.T.. All rights reserved.