use of io.aeron.CncFileDescriptor.CNC_VERSION in project aeron by real-logic.
the class CommonContext method saveErrorLog.
/**
* Read the error log to a given {@link PrintStream}
*
* @param out to write the error log contents to.
* @param cncByteBuffer containing the error log.
* @return the number of observations from the error log.
*/
public int saveErrorLog(final PrintStream out, final MappedByteBuffer cncByteBuffer) {
if (null == cncByteBuffer) {
return 0;
}
final UnsafeBuffer cncMetaDataBuffer = CncFileDescriptor.createMetaDataBuffer(cncByteBuffer);
final int cncVersion = cncMetaDataBuffer.getInt(CncFileDescriptor.cncVersionOffset(0));
if (CNC_VERSION != cncVersion) {
throw new IllegalStateException("Aeron CnC version does not match: required=" + CNC_VERSION + " version=" + cncVersion);
}
final AtomicBuffer buffer = CncFileDescriptor.createErrorLogBuffer(cncByteBuffer, cncMetaDataBuffer);
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
final ErrorConsumer errorConsumer = (count, firstTimestamp, lastTimestamp, ex) -> formatError(out, dateFormat, count, firstTimestamp, lastTimestamp, ex);
final int distinctErrorCount = ErrorLogReader.read(buffer, errorConsumer);
out.format("%n%d distinct errors observed.%n", distinctErrorCount);
return distinctErrorCount;
}
Aggregations