in activeio-core/src/main/java/org/apache/activeio/journal/active/JournalImpl.java [161:199]
private Location write(byte recordType, Packet data, boolean sync, Location mark) throws IOException {
try {
Location location;
BatchedWrite writeCommand;
Record record = new Record(recordType, data, mark);
// The following synchronized block is the bottle neck of the journal. Make this
// code faster and the journal should speed up.
synchronized (this) {
if (disposed) {
throw new IOException("Journal has been closed.");
}
// Create our record
location = new Location(appendLogFileId, appendLogFileOffset);
record.setLocation(location);
// Piggy back the packet on the pending write batch.
writeCommand = addToPendingWriteBatch(record, mark, sync);
// Update where the next record will land.
appendLogFileOffset += data.limit() + Record.RECORD_BASE_SIZE;
rolloverCheck();
}
if (sync) {
writeCommand.waitForForce();
}
return location;
} catch (IOException e) {
throw e;
} catch (InterruptedException e) {
throw (IOException) new InterruptedIOException().initCause(e);
} catch (Throwable e) {
throw (IOException) new IOException("Write failed: " + e).initCause(e);
}
}