public final class JTransaction extends BaseTransaction implements JTransactionMBean
Transaction
Modifier and Type | Field and Description |
---|---|
private int |
commitCount
Number of commit operation since starting up.
|
private File |
dir |
static String |
EMPTY_STRING |
private Hashtable |
log |
private static String |
LOG |
private RandomAccessFile |
logFile |
(package private) static int |
LogThresholdOperation
Number of pooled operation, by default 100.
|
protected int |
phase |
protected long |
startTime |
logmon
Constructor and Description |
---|
JTransaction() |
Modifier and Type | Method and Description |
---|---|
private void |
_commit() |
String |
backup(String path)
Backups the content of Transaction module.
|
void |
begin()
Start a transaction validation, the validation phase needs 3 phases: begin, commit
and release.
|
void |
close()
Close the transaction module.
|
void |
commit(boolean release)
Commit the current transaction.
|
boolean |
containsOperations()
Indicates whether some operations have been done in
this transaction.
|
void |
create(Serializable obj,
String name)
Register the state of a newly created object in the current transaction.
|
void |
create(Serializable obj,
String dirName,
String name)
Register the state of a newly created object in the current transaction.
|
void |
createByteArray(byte[] buf,
String name)
Register a new byte array in the current transaction.
|
void |
createByteArray(byte[] buf,
String dirName,
String name)
Register a new byte array in the current transaction.
|
void |
delete(String name)
Deletes the specified object.
|
void |
delete(String dirName,
String name)
Deletes the specified object.
|
private void |
deleteDir(File dir)
Delete the specified directory if it is empty.
|
int |
getCommitCount()
Returns the number of commit operation since starting up.
|
File |
getDir() |
String[] |
getList(String prefix)
Returns an array of strings naming the objects in the component started by this prefix.
|
int |
getOperationCount()
Returns the number of operations to be committed.
|
String |
getPersistenceDir()
Returns the path of persistence directory.
|
int |
getPhase()
Returns the transaction state.
|
String |
getPhaseInfo()
Returns a string representation of the transaction state.
|
long |
getStartTime()
Returns the starting time.
|
void |
init(String path)
Initializes the atomic storage component.
|
boolean |
isPersistent()
Tests if the Transaction component is persistent.
|
Object |
load(String name)
Load the specified object.
|
Object |
load(String dirName,
String name)
Load the specified object.
|
void |
loadAll(String prefix,
Map map)
Fills the map with all objects of the component whose name begins with the prefix.
|
byte[] |
loadByteArray(String name)
Load the specified byte array.
|
byte[] |
loadByteArray(String dirName,
String name)
Load the specified byte array.
|
void |
release()
Release the mutual exclusion.
|
void |
save(Serializable obj,
String name)
Register the modified state of an object in the current transaction.
|
void |
save(Serializable obj,
String dirName,
String name)
Register the modified state of an object in the current transaction.
|
void |
save(Serializable obj,
String dirName,
String name,
boolean first)
Register the state of an object in the current transaction.
|
void |
saveByteArray(byte[] buf,
String name)
Register a modified byte array in the current transaction.
|
void |
saveByteArray(byte[] buf,
String dirName,
String name)
Register a modified byte array in the current transaction.
|
void |
saveByteArray(byte[] buf,
String dirName,
String name,
boolean copy,
boolean first)
Register a modified byte array in the current transaction.
|
protected void |
setPhase(int newPhase) |
void |
stop()
Stops the transaction module.
|
boolean |
useLoadAll()
Returns false, this Transaction implementation does not implement an optimized loadAll method.
|
freeze, getBoolean, getInteger, getInteger, getProperty, getProperty, loadProperties, saveProperties
protected long startTime
private int commitCount
public static final String EMPTY_STRING
static int LogThresholdOperation
LogThresholdOperation
specific property.
These property can be fixed either from java
launching
command, or in a3servers.xml
configuration file.
private File dir
private static final String LOG
private RandomAccessFile logFile
private Hashtable log
protected int phase
public long getStartTime()
getStartTime
in interface TransactionMBean
public final int getCommitCount()
getCommitCount
in interface Transaction
getCommitCount
in interface TransactionMBean
public boolean isPersistent()
isPersistent
in interface Transaction
isPersistent
in interface TransactionMBean
public void init(String path) throws IOException
Transaction
init
in interface Transaction
path
- the path of storage directory.IOException
- an error occurs.public File getDir()
public String getPersistenceDir()
public final int getPhase()
TransactionMBean
getPhase
in interface Transaction
getPhase
in interface TransactionMBean
public final String getPhaseInfo()
TransactionMBean
getPhaseInfo
in interface Transaction
getPhaseInfo
in interface TransactionMBean
protected void setPhase(int newPhase) throws IOException
IOException
public final void begin() throws IOException
Transaction
begin
in interface Transaction
IOException
- an error occurs.public String[] getList(String prefix)
Transaction
getList
in interface Transaction
prefix
- the prefix of searched objects.public final void create(Serializable obj, String name) throws IOException
Transaction
create
in interface Transaction
obj
- the object to store.name
- the name of the object.IOException
- an error occurs.public final void create(Serializable obj, String dirName, String name) throws IOException
Transaction
create
in interface Transaction
obj
- the object to store.dirName
- the directory name of the object.name
- the name of the object.IOException
- an error occurs.public final void save(Serializable obj, String name) throws IOException
Transaction
save
in interface Transaction
obj
- the object to store.name
- the name of the object.IOException
- an error occurs.public final void save(Serializable obj, String dirName, String name) throws IOException
Transaction
save
in interface Transaction
obj
- the object to store.dirName
- the directory name of the object.name
- the name of the object.IOException
- an error occurs.public void save(Serializable obj, String dirName, String name, boolean first) throws IOException
Transaction
save
in interface Transaction
obj
- the object to store.dirName
- the directory name of the object.name
- the name of the object.first
- the object is a new one.IOException
- an error occurs.public final void createByteArray(byte[] buf, String name) throws IOException
Transaction
createByteArray
in interface Transaction
buf
- the byte array to store.name
- the name of the object.IOException
- an error occurs.public final void createByteArray(byte[] buf, String dirName, String name) throws IOException
Transaction
createByteArray
in interface Transaction
buf
- the byte array to store.dirName
- the directory name of the object.name
- the name of the object.IOException
- an error occurs.public final void saveByteArray(byte[] buf, String name) throws IOException
Transaction
saveByteArray
in interface Transaction
buf
- the byte array to store.name
- the name of the object.IOException
- an error occurs.public final void saveByteArray(byte[] buf, String dirName, String name) throws IOException
Transaction
saveByteArray
in interface Transaction
buf
- the byte array to store.dirName
- the directory name of the object.name
- the name of the object.IOException
- an error occurs.public void saveByteArray(byte[] buf, String dirName, String name, boolean copy, boolean first) throws IOException
Transaction
saveByteArray
in interface Transaction
buf
- the byte array to store.dirName
- the directory name of the object.name
- the name of the object.copy
- the byte array can be modified, copy it.first
- the object is a new one.IOException
- an error occurs.public final Object load(String name) throws IOException, ClassNotFoundException
Transaction
load
in interface Transaction
name
- the name of the object.IOException
- an error occurs.ClassNotFoundException
- an error occurs.public final Object load(String dirName, String name) throws IOException, ClassNotFoundException
Transaction
load
in interface Transaction
dirName
- the directory name of the object.name
- the name of the object.IOException
- an error occurs.ClassNotFoundException
- an error occurs.public boolean useLoadAll()
useLoadAll
in interface Transaction
useLoadAll
in interface TransactionMBean
public void loadAll(String prefix, Map map)
loadAll
in interface Transaction
prefix
- The prefix of searched objects.map
- The map of corresponding objects.public final byte[] loadByteArray(String name) throws IOException
Transaction
loadByteArray
in interface Transaction
name
- the name of the object.IOException
- an error occurs.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 name)
Transaction
delete
in interface Transaction
name
- the name of the object.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.private void deleteDir(File dir)
dir
- the directory to delete.public 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 _commit() throws IOException
IOException
public void release() throws IOException
Transaction
release
in interface Transaction
IOException
- an error occurs.public void stop()
stop
in interface Transaction
public void close()
close
in interface Transaction
public boolean containsOperations()
containsOperations
in interface Transaction
public int getOperationCount()
getOperationCount
in interface Transaction
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 © 2021 ScalAgent D.T.. All rights reserved.