* @param loggable
* @throws TransactionException
*/
public synchronized void writeToLog(Loggable loggable) throws TransactionException {
if (currentBuffer == null)
{throw new TransactionException("Database is shut down.");}
SanityCheck.ASSERT(!inRecovery, "Write to log during recovery. Should not happen!");
final int size = loggable.getLogSize();
final int required = size + LOG_ENTRY_BASE_LEN;
if (required > currentBuffer.remaining())
{flushToLog(false);}
currentLsn = Lsn.create(currentFile, inFilePos + currentBuffer.position() + 1);
loggable.setLsn(currentLsn);
try {
currentBuffer.put(loggable.getLogType());
currentBuffer.putLong(loggable.getTransactionId());
currentBuffer.putShort((short) loggable.getLogSize());
loggable.write(currentBuffer);
currentBuffer.putShort((short) (size + LOG_ENTRY_HEADER_LEN));
} catch (final BufferOverflowException e) {
throw new TransactionException("Buffer overflow while writing log record: " + loggable.dump(), e);
}
pool.getTransactionManager().trackOperation(loggable.getTransactionId());
}