Package fr.dyade.aaa.ext
Class NGTransaction.LogManager
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.ByteArrayOutputStream
-
- fr.dyade.aaa.ext.NGTransaction.LogManager
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Enclosing class:
- NGTransaction
static final class NGTransaction.LogManager extends ByteArrayOutputStream
This class manages the memory log of operations and the multiples log files.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) intcommitCountNumber of commit operation since starting up.(package private) intcurrentCurrent file pointer in log(package private) Filedirprivate static byte[]emptyUTFString(package private) intgarbageCountNumber of garbage operation since starting up.(package private) longgarbageTimeCumulated time of garbage operations since starting up.(package private) longlastGarbageDateDate of last garbage.(package private) intloadFromLogNumber of load from a log file.private static StringLockPathnameCoherence lock filename(package private) Hashtable<Object,Operation>logMemory log of all operations already committed but not reported on disk.(package private) NGTransaction.LogFile[]logFilelog file(package private) intlogidxIndex of log file in used.private Stringmodeprivate Repositoryrepository-
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
-
-
Constructor Summary
Constructors Constructor Description LogManager(File dir, Repository repository, boolean syncOnWrite)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidbackup(File backupDir)Makes a copy of all used log files.(package private) voidcommit(Hashtable<Object,Operation> ctxlog)Reports all buffered operations in logs.private voidgarbage(int idx)private voidgarbage(NGTransaction.LogFile logf)Reports all 'live' operations of a particular log file in the repository, the log file is then cleaned and closed.byte[]getFromLog(Operation op)byte[]getFromLog(String dirName, String name)String[]getList(String prefix)(package private) intgetLogFileSize()Returns the size of disk log in bytes.byte[]load(String dirName, String name)StringlogContent(int idx)StringlogCounters()(package private) voidstop()(package private) voidwriteInt(int v)(package private) voidwriteUTF(String str)-
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, toString, write, write, writeBytes, writeTo
-
Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
-
-
-
Field Detail
-
log
Hashtable<Object,Operation> log
Memory log of all operations already committed but not reported on disk.
-
logidx
int logidx
Index of log file in used.
-
logFile
NGTransaction.LogFile[] logFile
log file
-
current
int current
Current file pointer in log
-
commitCount
int commitCount
Number of commit operation since starting up.
-
loadFromLog
int loadFromLog
Number of load from a log file.
-
garbageCount
int garbageCount
Number of garbage operation since starting up.
-
garbageTime
long garbageTime
Cumulated time of garbage operations since starting up.
-
lastGarbageDate
long lastGarbageDate
Date of last garbage.
-
LockPathname
private static final String LockPathname
Coherence lock filename- See Also:
- Constant Field Values
-
repository
private Repository repository
-
dir
File dir
-
mode
private String mode
-
emptyUTFString
private static final byte[] emptyUTFString
-
-
Constructor Detail
-
LogManager
LogManager(File dir, Repository repository, boolean syncOnWrite) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getLogFileSize
int getLogFileSize()
Returns the size of disk log in bytes.- Returns:
- The size of disk log in bytes.
-
backup
void backup(File backupDir) throws IOException
Makes a copy of all used log files.- Parameters:
backupDir-- Throws:
IOException
-
commit
void commit(Hashtable<Object,Operation> ctxlog) throws IOException
Reports all buffered operations in logs.- Parameters:
ctxlog- the log object.- Throws:
IOException- an error occurs.
-
getFromLog
public byte[] getFromLog(String dirName, String name) throws IOException
- Throws:
IOException
-
getFromLog
public byte[] getFromLog(Operation op) throws IOException
- Throws:
IOException
-
load
public byte[] load(String dirName, String name) throws IOException
- Throws:
IOException
-
logCounters
public String logCounters()
-
logContent
public String logContent(int idx)
-
garbage
private final void garbage(int idx) throws IOException- Throws:
IOException
-
garbage
private final void garbage(NGTransaction.LogFile logf) throws IOException
Reports all 'live' operations of a particular log file in the repository, the log file is then cleaned and closed.- Parameters:
logf- The log file to garbage.- Throws:
IOException- an error occurs.
-
stop
void stop()
-
writeUTF
void writeUTF(String str)
-
writeInt
void writeInt(int v)
-
-