use of org.agrona.concurrent.errors.ErrorConsumer 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;
}
use of org.agrona.concurrent.errors.ErrorConsumer in project aeron by real-logic.
the class ClusterMarkFile method saveErrorLog.
public static int saveErrorLog(final PrintStream out, final AtomicBuffer errorBuffer) {
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
final ErrorConsumer errorConsumer = (count, firstTimestamp, lastTimestamp, ex) -> out.format("***%n%d observations from %s to %s for:%n %s%n", count, dateFormat.format(new Date(firstTimestamp)), dateFormat.format(new Date(lastTimestamp)), ex);
final int distinctErrorCount = ErrorLogReader.read(errorBuffer, errorConsumer);
out.format("%n%d distinct errors observed.%n", distinctErrorCount);
return distinctErrorCount;
}
use of org.agrona.concurrent.errors.ErrorConsumer in project aeron by real-logic.
the class CommonContext method printErrorLog.
/**
* Print the contents of an error log to a {@link PrintStream} in human-readable format.
*
* @param errorBuffer to read errors from.
* @param out print the errors to.
* @return number of distinct errors observed.
*/
public static int printErrorLog(final AtomicBuffer errorBuffer, final PrintStream out) {
int distinctErrorCount = 0;
if (errorBuffer.capacity() > 0 && ErrorLogReader.hasErrors(errorBuffer)) {
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
final ErrorConsumer errorConsumer = (count, firstTimestamp, lastTimestamp, ex) -> out.format("***%n%d observations from %s to %s for:%n %s%n", count, dateFormat.format(new Date(firstTimestamp)), dateFormat.format(new Date(lastTimestamp)), ex);
distinctErrorCount = ErrorLogReader.read(errorBuffer, errorConsumer);
out.format("%n%d distinct errors observed.%n", distinctErrorCount);
}
return distinctErrorCount;
}
use of org.agrona.concurrent.errors.ErrorConsumer in project Aeron by real-logic.
the class CommonContext method printErrorLog.
/**
* Print the contents of an error log to a {@link PrintStream} in human-readable format.
*
* @param errorBuffer to read errors from.
* @param out print the errors to.
* @return number of distinct errors observed.
*/
public static int printErrorLog(final AtomicBuffer errorBuffer, final PrintStream out) {
int distinctErrorCount = 0;
if (errorBuffer.capacity() > 0 && ErrorLogReader.hasErrors(errorBuffer)) {
final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
final ErrorConsumer errorConsumer = (count, firstTimestamp, lastTimestamp, ex) -> out.format("***%n%d observations from %s to %s for:%n %s%n", count, dateFormat.format(new Date(firstTimestamp)), dateFormat.format(new Date(lastTimestamp)), ex);
distinctErrorCount = ErrorLogReader.read(errorBuffer, errorConsumer);
out.format("%n%d distinct errors observed.%n", distinctErrorCount);
}
return distinctErrorCount;
}
Aggregations