![]() |
Quadcap Embeddable Database |
Inheritance diagram for com.quadcap.sql.file.Log1:

Checkpoints plus physical logging of block writes is coupled with logical logging to support transactions rollback and recovery.
Definition at line 71 of file Log1.java.
Public Member Functions | |
| Log1 () | |
| Constructor for transaction log. | |
| void | init (Datafile db, boolean create, Properties props) throws IOException |
| Initialize the log. | |
| void | start () |
| Start the logging subsystem. | |
| void | remove () throws IOException |
| Remove the log. | |
| Datafile | getDatafile () |
| Return the database that we're logging for. | |
| File | getDbRootDir () |
| Return the database root directory. | |
| void | addEntry (LogEntry entry) throws IOException |
| Add a transaction's log record to the end of the open log file. | |
| void | close () throws IOException |
| Flush and close the log file. | |
| void | flushLog () throws IOException |
| Flush all log records to disk. | |
| void | checkpoint () throws IOException |
| Perform a checkpoint operation. | |
| void | sync () throws IOException |
| Wait for all queued ops to be processed by the log sync thread. | |
| void | rollbackTransaction (Transaction trans) throws IOException |
| Transaction rollback. | |
| void | rollbackStatement (Transaction trans, int stmtId) throws IOException |
| Statement rollback. | |
| void | restart () throws Exception |
| Restart from a previous state. | |
| final long | getRowMap (long rowId) |
| Retrieve a row mapping. | |
| final void | putRowMap (long logRow, long fileRow) |
| Remember a row mapping {old,new} The old row (logRow) is now stored in a new place (fileRow), so any stored log entries that refer to the old row need to be translated to use the new row. | |
| final void | removeRowMap (long row) |
| Discard a row mapping. | |
| void | reallyAddEntry (LogEntry entry) throws IOException |
| XXX why public? | |
| void | put (LogEntry h) throws IOException |
| XXXX Problem: If you have "the lock" and you call this when the channel is full, you may block. | |
| boolean | isLogging () |
| Are you logging? | |
| boolean | inRecovery () |
| Are we currently performing recovery? | |
| void | saveBlock (long b) throws IOException |
| Save a "before" image. | |
| void | restoreBlocks () throws IOException |
| Restore all the "before" images. | |
| void | resetBlocks () throws IOException |
| Reset the "before" list to be empty. | |
| String | toString () |
Protected Member Functions | |
| boolean | checksync (int x) |
Package Functions | |
| void | reallyFlush () throws IOException |
| void | reallyClose () throws IOException |
| void | reallyRollbackTransaction (Transaction tr) throws Exception |
| void | reallyRollbackStatement (Transaction tr, int s) throws Exception |
| LogEntry | scanLog (LongMap t) throws IOException |
| void | reallyRestart () throws Exception |
| void | maybeCheckpoint () throws IOException |
| void | reallyCheckpoint () throws IOException |
Package Attributes | |
| Logger | logger |
| Log writer/reader. | |
| LogSync | logSync |
| log sync thread | |
| Latch | closeLatch = new Latch() |
| log sync thread done, close interlock | |
| producer/consumer conduit | |
| Object | fileLock |
| our datatbase's file lock | |
| LongMap | rowIdMap = new LongMap(256) |
| Map rows during recovery, null otherwise. | |
| FileOutputStream | bfo |
| "before-images" file | |
| boolean | bfoActive = false |
| boolean | recovering = false |
| int | blockSize |
| long | minSyncInterval = ConfigNumber.find("qed.minSyncInterval", "15000").longValue() |
| long | maxSyncInterval = ConfigNumber.find("qed.maxSyncInterval", "60000").longValue() |
| int | syncMap |
| String[] | syncStrs |
| int[] | syncCnts = new int[syncStrs.length] |
| int | pendingBegins = 0 |
| Add a transaction's log record to the end of the open log file. | |
| long | lastCheckpoint = System.currentTimeMillis() |
| int | entryCount = 0 |
| int | filepos = 0 |
| byte[] | sav = null |
| Save a "before" image. | |
Static Package Attributes | |
| Flush | opFlush = new Flush() |
| A single static instance of this op is all we need. | |
| Checkpoint | opCheckpoint = new Checkpoint() |
| Close | opClose = new Close() |
| A single static instance of this op is all we need. | |
Private Member Functions | |
| void | sortEntry (long tId, List save, List discard, LogEntry e) |
| final void | abortOldestTransaction (LogEntry entry) throws IOException |
Private Attributes | |
| Datafile | db |
| the database we're logging for | |
| BlockFile | dbFile |
| the database file we're logging for | |
| File | dbRootDir |
| log file directory | |
|
|
Constructor for transaction log.
|
|
|
|
Add a transaction's log record to the end of the open log file.
Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 259 of file Log1.java. References com.quadcap.sql.file.Log1.addEntry(), com.quadcap.sql.file.Log1.pendingBegins, and com.quadcap.sql.file.Log1.put(). Referenced by com.quadcap.sql.file.Log1.addEntry(). |
|
|
Perform a checkpoint operation.
Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 290 of file Log1.java. References com.quadcap.sql.file.Log1.opCheckpoint, and com.quadcap.sql.file.Log1.put(). Referenced by com.quadcap.sql.file.Log1.reallyRestart(). |
|
|
Definition at line 155 of file Log1.java. References com.quadcap.sql.file.Log1.checksync(), com.quadcap.sql.file.Log1.syncCnts, and com.quadcap.sql.file.Log1.syncMap. Referenced by com.quadcap.sql.file.Log1.checksync(). |
|
|
Flush and close the log file.
Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 271 of file Log1.java. References com.quadcap.sql.file.Log1.closeLatch, com.quadcap.sql.file.Log1.opClose, and com.quadcap.sql.file.Log1.put(). Referenced by com.quadcap.sql.file.Log1.LogSync.run(). |
|
|
Flush all log records to disk. Action not performed on this thread, we're in a hurry.... Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 283 of file Log1.java. References com.quadcap.sql.file.Log1.opFlush, and com.quadcap.sql.file.Log1.put(). |
|
|
Return the database that we're logging for.
Implements com.quadcap.sql.file.Log. Definition at line 248 of file Log1.java. References com.quadcap.sql.file.Log1.db. |
|
|
Return the database root directory.
Definition at line 253 of file Log1.java. References com.quadcap.sql.file.Log1.dbRootDir. |
|
|
Retrieve a row mapping.
Implements com.quadcap.sql.file.Log. Definition at line 338 of file Log1.java. References com.quadcap.sql.file.Log1.getRowMap(), and com.quadcap.sql.file.Log1.rowIdMap. Referenced by com.quadcap.sql.file.Log1.getRowMap(). |
|
||||||||||||||||
|
Initialize the log.
Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 177 of file Log1.java. References com.quadcap.sql.file.BlockFile.blockSize, com.quadcap.sql.file.Log1.db, com.quadcap.sql.file.Log1.dbFile, com.quadcap.sql.file.Datafile.dbRootDir, com.quadcap.sql.file.Datafile.file, com.quadcap.sql.file.BlockFile.getBlockSize(), com.quadcap.sql.file.Datafile.getFileLock(), com.quadcap.sql.file.Logger.init(), com.quadcap.sql.file.Log1.init(), com.quadcap.sql.file.Log1.logger, com.quadcap.sql.file.Log1.maxSyncInterval, and com.quadcap.sql.file.Log1.minSyncInterval. Referenced by com.quadcap.sql.file.Log1.init(). |
|
|
Are we currently performing recovery?
Implements com.quadcap.sql.file.Log. Definition at line 889 of file Log1.java. References com.quadcap.sql.file.Log1.recovering. |
|
|
Are you logging? Oh yes. Implements com.quadcap.sql.file.Log. |
|
|
|
XXXX Problem: If you have "the lock" and you call this when the channel is full, you may block. This would be bad, because it might block the log thread trying to get the lock, leading to deadlock Definition at line 726 of file Log1.java. References com.quadcap.sql.file.Log1.channel, and com.quadcap.sql.file.Log1.put(). Referenced by com.quadcap.sql.file.Log1.addEntry(), com.quadcap.sql.file.Log1.checkpoint(), com.quadcap.sql.file.Log1.close(), com.quadcap.sql.file.Log1.flushLog(), com.quadcap.sql.file.Log1.put(), com.quadcap.sql.file.Log1.rollbackStatement(), com.quadcap.sql.file.Log1.rollbackTransaction(), and com.quadcap.sql.file.Log1.sync(). |
|
||||||||||||
|
Remember a row mapping {old,new} The old row (logRow) is now stored in a new place (fileRow), so any stored log entries that refer to the old row need to be translated to use the new row.
Implements com.quadcap.sql.file.Log. Definition at line 355 of file Log1.java. References com.quadcap.sql.file.Log1.putRowMap(), and com.quadcap.sql.file.Log1.rowIdMap. Referenced by com.quadcap.sql.file.Log1.putRowMap(). |
|
|
XXX why public?
Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 626 of file Log1.java. References com.quadcap.sql.file.Log1.abortOldestTransaction(), com.quadcap.sql.file.Log1.entryCount, com.quadcap.sql.file.Log1.logger, com.quadcap.sql.file.Log1.pendingBegins, com.quadcap.sql.file.Logger.put(), com.quadcap.sql.file.Log1.reallyAddEntry(), and com.quadcap.sql.file.Log1.toString(). Referenced by com.quadcap.sql.file.Log1.reallyAddEntry(). |
|
|
|
Definition at line 376 of file Log1.java. References com.quadcap.sql.file.Log1.bfo, com.quadcap.sql.file.Log1.LogSync.close(), and com.quadcap.sql.file.Log1.logSync. Referenced by com.quadcap.sql.file.Log2.close(). |
|
|
Definition at line 364 of file Log1.java. References com.quadcap.sql.file.Log1.db, com.quadcap.sql.file.BlockFile.flush(), com.quadcap.sql.file.Log1.logger, com.quadcap.sql.file.Logger.sync(), and com.quadcap.sql.file.Datafile.tempFile. Referenced by com.quadcap.sql.file.Log2.flushLog(). |
|
|
||||||||||||
|
|
|
Remove the log.
Implements com.quadcap.sql.file.Log. Definition at line 241 of file Log1.java. References com.quadcap.sql.file.Log1.dbRootDir. |
|
|
Discard a row mapping.
Implements com.quadcap.sql.file.Log. Definition at line 360 of file Log1.java. References com.quadcap.sql.file.Log1.removeRowMap(), and com.quadcap.sql.file.Log1.rowIdMap. Referenced by com.quadcap.sql.file.Log1.removeRowMap(). |
|
|
Reset the "before" list to be empty.
Implements com.quadcap.sql.file.Log. Definition at line 981 of file Log1.java. References com.quadcap.sql.file.Log1.bfo, com.quadcap.sql.file.Log1.bfoActive, com.quadcap.sql.file.Log1.db, com.quadcap.sql.file.Log1.dbFile, com.quadcap.sql.file.Log1.filepos, com.quadcap.sql.file.Datafile.getScratchDir(), com.quadcap.sql.file.BlockFile.getSize(), and com.quadcap.sql.file.Datafile.toString(). Referenced by com.quadcap.sql.file.Log1.saveBlock(). |
|
|
Restart from a previous state.
Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 329 of file Log1.java. References com.quadcap.sql.file.Log1.reallyRestart(). |
|
|
||||||||||||
|
Statement rollback.
Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 319 of file Log1.java. References com.quadcap.sql.file.Log1.put(), com.quadcap.sql.file.Log1.rollbackStatement(), and com.quadcap.sql.file.Log1.sync(). Referenced by com.quadcap.sql.file.Log1.rollbackStatement(). |
|
|
Transaction rollback.
Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 309 of file Log1.java. References com.quadcap.sql.file.Log1.put(), com.quadcap.sql.file.Log1.rollbackTransaction(), and com.quadcap.sql.file.Log1.sync(). Referenced by com.quadcap.sql.file.Log1.rollbackTransaction(). |
|
|
Save a "before" image.
Implements com.quadcap.sql.file.Log. Definition at line 901 of file Log1.java. References com.quadcap.sql.file.Log1.bfo, com.quadcap.sql.file.Log1.bfoActive, com.quadcap.sql.file.Log1.blockSize, com.quadcap.sql.file.Log1.dbFile, com.quadcap.sql.file.Log1.filepos, com.quadcap.sql.file.BlockStore.read(), com.quadcap.sql.file.Log1.resetBlocks(), com.quadcap.sql.file.Log1.sav, com.quadcap.sql.file.Log1.saveBlock(), and com.quadcap.sql.file.BlockFile.store. Referenced by com.quadcap.sql.file.Log1.saveBlock(). |
|
|
Definition at line 469 of file Log1.java. References com.quadcap.sql.file.LogEntry.getCode(), com.quadcap.sql.file.Logger.getFirstOp(), com.quadcap.sql.file.Logger.getNextOp(), com.quadcap.sql.file.LogEntry.getTransactionId(), com.quadcap.sql.file.Log1.logger, and com.quadcap.sql.file.Log1.scanLog(). Referenced by com.quadcap.sql.file.Log1.scanLog(). |
|
||||||||||||||||||||
|
Definition at line 648 of file Log1.java. References com.quadcap.sql.file.LogEntry.getTransactionId(), and com.quadcap.sql.file.Log1.sortEntry(). Referenced by com.quadcap.sql.file.Log1.sortEntry(). |
|
|
Start the logging subsystem.
Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 235 of file Log1.java. References com.quadcap.sql.file.Log1.logSync. |
|
|
Wait for all queued ops to be processed by the log sync thread.
Implements com.quadcap.sql.file.Log. Reimplemented in com.quadcap.sql.file.Log2. Definition at line 297 of file Log1.java. References com.quadcap.sql.file.Log1.put(). Referenced by com.quadcap.sql.file.Log1.rollbackStatement(), and com.quadcap.sql.file.Log1.rollbackTransaction(). |
|
|
Definition at line 1000 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.reallyAddEntry(), and com.quadcap.sql.file.Log1.reallyRestart(). |
|
|
"before-images" file
Definition at line 100 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.reallyClose(), com.quadcap.sql.file.Log1.resetBlocks(), and com.quadcap.sql.file.Log1.saveBlock(). |
|
|
Definition at line 101 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.resetBlocks(), and com.quadcap.sql.file.Log1.saveBlock(). |
|
|
Definition at line 105 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.restoreBlocks(), and com.quadcap.sql.file.Log1.saveBlock(). |
|
|
|
producer/consumer conduit
Definition at line 91 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.abortOldestTransaction(), and com.quadcap.sql.file.Log1.put(). |
|
|
log sync thread done, close interlock
Definition at line 88 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.close(). |
|
|
|
the database file we're logging for
Definition at line 76 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.init(), com.quadcap.sql.file.Log1.reallyCheckpoint(), com.quadcap.sql.file.Log1.resetBlocks(), com.quadcap.sql.file.Log1.restoreBlocks(), and com.quadcap.sql.file.Log1.saveBlock(). |
|
|
log file directory
Definition at line 82 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.getDbRootDir(), and com.quadcap.sql.file.Log1.remove(). |
|
|
Definition at line 623 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.maybeCheckpoint(), and com.quadcap.sql.file.Log1.reallyAddEntry(). |
|
|
our datatbase's file lock
|
|
|
Definition at line 894 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.resetBlocks(), and com.quadcap.sql.file.Log1.saveBlock(). |
|
|
Definition at line 555 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.maybeCheckpoint(), and com.quadcap.sql.file.Log1.reallyCheckpoint(). |
|
|
|
log sync thread
Definition at line 85 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.reallyClose(), and com.quadcap.sql.file.Log1.start(). |
|
|
Definition at line 129 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.init(), and com.quadcap.sql.file.Log1.maybeCheckpoint(). |
|
|
Definition at line 116 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.init(), and com.quadcap.sql.file.Log1.maybeCheckpoint(). |
|
|
Definition at line 761 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.checkpoint(). |
|
|
A single static instance of this op is all we need.
Definition at line 776 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.close(). |
|
|
A single static instance of this op is all we need.
Definition at line 750 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.flushLog(). |
|
|
Add a transaction's log record to the end of the open log file.
Definition at line 258 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.addEntry(), com.quadcap.sql.file.Log1.reallyAddEntry(), and com.quadcap.sql.file.Log1.reallyCheckpoint(). |
|
|
Definition at line 103 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.inRecovery(), and com.quadcap.sql.file.Log1.reallyRestart(). |
|
|
Map rows during recovery, null otherwise.
Definition at line 97 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.getRowMap(), com.quadcap.sql.file.Log1.maybeCheckpoint(), com.quadcap.sql.file.Log1.putRowMap(), com.quadcap.sql.file.Log1.reallyCheckpoint(), com.quadcap.sql.file.Log1.reallyRestart(), com.quadcap.sql.file.Log1.reallyRollbackStatement(), com.quadcap.sql.file.Log1.reallyRollbackTransaction(), and com.quadcap.sql.file.Log1.removeRowMap(). |
|
|
Save a "before" image.
Definition at line 900 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.saveBlock(). |
|
|
Definition at line 153 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.checksync(). |
|
|
Initial value:
Definition at line 131 of file Log1.java. Referenced by com.quadcap.sql.file.Log1.checksync(). |
|
|
Initial value:
|