in gflog-core/src/main/java/com/epam/deltix/gflog/core/service/AsyncLogService.java [102:140]
void commit(final LogLocalEntry entry, final Throwable exception, final int exceptionPosition) {
final int length = entry.length();
final int min = exceptionIndex.segment();
final int max = Math.max(length + SIZE_OF_LONG, min);
final int required = Util.align(max, SIZE_OF_LONG);
final int offset;
if (strategy == OverflowStrategy.WAIT) {
offset = buffer.claim(required, backpressure);
} else {
offset = buffer.tryClaim(required);
if (offset < 0) {
failedOffersCounter.increment();
return;
}
}
try {
final long timestamp = clock.nanoTime();
final long address = buffer.dataAddress() + offset;
entry.onCommit(timestamp);
entry.copyTo(address);
final byte logLevel = UNSAFE.getByte(address + LogRecordEncoder.LOG_LEVEL_OFFSET);
UNSAFE.putByte(address + LogRecordEncoder.LOG_LEVEL_OFFSET, (byte) ~logLevel);
UNSAFE.putInt(address + required - LogRecordEncoder.EXCEPTION_POSITION_OFFSET, exceptionPosition);
UNSAFE.putInt(address + required - LogRecordEncoder.EXCEPTION_REAL_LENGTH_OFFSET, length);
exceptionIndex.put(offset, exception);
buffer.commit(offset, required);
} catch (final Throwable e) {
LogDebug.warn("error committing log entry to log buffer", e);
buffer.abort(offset, required);
}
}