public class DistinctErrorLog
extends java.lang.Object
The provided AtomicBuffer
can wrap a memory-mapped file so logging can be out of process. This provides
the benefit that if a crash or lockup occurs then the log can be read externally without loss of data.
Note: This class is threadsafe to be used from multiple logging threads.
The error records are recorded to the memory mapped buffer in the following format.
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R| Length | +-+-------------------------------------------------------------+ |R| Observation Count | +-+-------------------------------------------------------------+ |R| Last Observation Timestamp | | | +-+-------------------------------------------------------------+ |R| First Observation Timestamp | | | +---------------------------------------------------------------+ | UTF-8 Encoded Error ... ... | +---------------------------------------------------------------+
Modifier and Type | Class and Description |
---|---|
static class |
DistinctErrorLog.DistinctObservation |
Modifier and Type | Field and Description |
---|---|
static int |
ENCODED_ERROR_OFFSET
Offset within a record at which the encoded exception field begins.
|
static int |
FIRST_OBSERVATION_TIMESTAMP_OFFSET
Offset within a record at which the first observation timestamp field begins.
|
static int |
LAST_OBSERVATION_TIMESTAMP_OFFSET
Offset within a record at which the last observation timestamp field begins.
|
static int |
LENGTH_OFFSET
Offset within a record at which the length field begins.
|
static int |
OBSERVATION_COUNT_OFFSET
Offset within a record at which the observation count field begins.
|
static int |
RECORD_ALIGNMENT
Alignment to be applied for record beginning.
|
Constructor and Description |
---|
DistinctErrorLog(AtomicBuffer buffer,
EpochClock clock)
Create a new error log that will be written to a provided
AtomicBuffer . |
Modifier and Type | Method and Description |
---|---|
boolean |
record(java.lang.Throwable observation)
Record an observation of an error.
|
public static final int LENGTH_OFFSET
public static final int OBSERVATION_COUNT_OFFSET
public static final int LAST_OBSERVATION_TIMESTAMP_OFFSET
public static final int FIRST_OBSERVATION_TIMESTAMP_OFFSET
public static final int ENCODED_ERROR_OFFSET
public static final int RECORD_ALIGNMENT
public DistinctErrorLog(AtomicBuffer buffer, EpochClock clock)
AtomicBuffer
.buffer
- into which the observation records are recorded.clock
- to be used for time stamping records.public boolean record(java.lang.Throwable observation)
observation
- to be logged as an error observation.Copyright © 2014-2019 Real Logic Ltd. All Rights Reserved.