public final class ATransaction extends AbstractTransaction implements ATransactionMBean, Runnable
AbstractTransaction.Context
Modifier and Type | Field and Description |
---|---|
private static ByteArrayOutputStream |
baos |
(package private) static int |
CLEANUP_THRESHOLD_COMMIT |
(package private) static int |
CLEANUP_THRESHOLD_OPERATION |
(package private) static int |
CLEANUP_THRESHOLD_SIZE |
private Hashtable |
clog
Log of all operations already commited but not reported on disk
by the "garbage" Thread.
|
private int |
commitCount |
private int |
cumulativeSize |
(package private) static boolean |
debug |
private static DataOutputStream |
dos |
private static byte[] |
emptyUTFString |
private boolean |
garbage |
private Thread |
gThread |
private boolean |
isRunning |
private Object |
lock |
private static String |
LOCK |
private File |
lockFile |
private static String |
LOG |
protected FileDescriptor |
logFD |
protected RandomAccessFile |
logFile |
protected File |
logFilePN |
private int |
operationCount |
private Hashtable |
plog
Log currently used by "garbage" Thread, its thread reports all
operation it contents on disk, then it deletes it.
|
private static String |
PLOG |
protected File |
plogFilePN |
dir, OOS_STREAM_HEADER, perThreadContext, phase, startTime
logmon
Constructor and Description |
---|
ATransaction() |
Modifier and Type | Method and Description |
---|---|
private void |
_release() |
void |
_stop() |
void |
close()
Close the transaction module.
|
void |
commit(boolean release)
Commit the current transaction.
|
private void |
commit(Hashtable log)
Reports all logged operations on disk.
|
void |
delete(String dirName,
String name)
Deletes the specified object.
|
private void |
deleteDir(File dir)
Delete the specified directory if it is empty.
|
File |
getDir() |
private byte[] |
getFromLog(Hashtable log,
Object key) |
private byte[] |
getFromLog(String dirName,
String name) |
String[] |
getList(String prefix)
Returns an array of strings naming the objects in the component started by this prefix.
|
void |
initRepository() |
boolean |
isPersistent()
Tests if the Transaction component is persistent.
|
byte[] |
loadByteArray(String dirName,
String name)
Load the specified byte array.
|
protected void |
newLogFile() |
void |
release()
Release the mutual exclusion.
|
private void |
restart(Hashtable log,
File logFilePN) |
void |
rollback() |
void |
run() |
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.
|
protected void |
syncLogFile() |
private void |
wakeup() |
begin, containsOperations, create, create, createByteArray, createByteArray, delete, getOperationCount, getPhase, getPhaseInfo, getStartTime, init, load, load, loadByteArray, save, save, save, saveByteArray, saveByteArray, saveByteArray
getBoolean, getInteger, getInteger, getProperty, getProperty, loadProperties, saveProperties
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPhase, getPhaseInfo, getStartTime
static final int CLEANUP_THRESHOLD_COMMIT
static final int CLEANUP_THRESHOLD_OPERATION
static final int CLEANUP_THRESHOLD_SIZE
private int commitCount
private int operationCount
private int cumulativeSize
private Hashtable clog
private Hashtable plog
private static final String LOCK
private static final String LOG
private static final String PLOG
private File lockFile
protected File logFilePN
protected File plogFilePN
private boolean garbage
private Object lock
private boolean isRunning
private Thread gThread
static final boolean debug
private static final byte[] emptyUTFString
private static ByteArrayOutputStream baos
private static DataOutputStream dos
protected RandomAccessFile logFile
protected FileDescriptor logFD
public boolean isPersistent()
TransactionMBean
isPersistent
in interface Transaction
isPersistent
in interface TransactionMBean
public final void initRepository() throws IOException
initRepository
in class AbstractTransaction
IOException
private final void restart(Hashtable log, File logFilePN) throws IOException
IOException
public final File getDir()
protected final void setPhase(int newPhase)
AbstractTransaction
setPhase
in class AbstractTransaction
newPhase
- the new transaction state.public final String[] getList(String prefix)
Transaction
getList
in interface Transaction
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
private final byte[] getFromLog(Hashtable log, Object key) throws IOException
IOException
private final byte[] getFromLog(String dirName, String name) throws IOException
IOException
public final 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 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 void commit(boolean release) throws IOException
Transaction
commit
in interface Transaction
release
- if true releases the transaction at the end of the commit.IOException
protected void newLogFile() throws IOException
IOException
protected void syncLogFile() throws IOException
IOException
public final void rollback()
public final void release() throws IOException
AbstractTransaction
release
in interface Transaction
release
in class AbstractTransaction
IOException
Transaction.release()
private final void commit(Hashtable log) throws IOException
IOException
private final void deleteDir(File dir)
public final void _stop()
public final void stop()
Transaction
stop
in interface Transaction
public void close()
close
in interface Transaction
private void _release() throws IOException
IOException
private final void wakeup() throws IOException
IOException
Copyright © 2018 ScalAgent D.T.. All Rights Reserved.