public class VanillaMessageHistory extends SelfDescribingMarshallable implements MessageHistory
MessageHistory storing source identifiers, message indices and
processing timestamps. Entries are kept in internal arrays up to
MESSAGE_HISTORY_LENGTH. The object can be marshalled in a compact
binary form or as a verbose textual structure.| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_LENGTH
The maximum number of bytes this object can take when marshalled in its
compact binary form.
|
static int |
MESSAGE_HISTORY_LENGTH
The maximum number of source/timing entries that can be stored in a single
VanillaMessageHistory instance. |
EMPTYDISCARD| Constructor and Description |
|---|
VanillaMessageHistory() |
| Modifier and Type | Method and Description |
|---|---|
void |
addSource(int id,
long index)
Adds a new source entry and marks the history as dirty.
|
boolean |
addSourceDetails()
Gets the flag that determines whether the MessageHistory should automatically
add a timestamp on read.
|
void |
addSourceDetails(boolean addSourceDetails)
Sets whether the MessageHistory should automatically add a timestamp on read.
|
void |
addTiming(long l)
Adds a timing entry.
|
net.openhft.chronicle.bytes.util.BinaryLengthLength |
binaryLengthLength()
Provides an assumed length in bytes for the serialized form of this entity.
|
<T> T |
deepCopy()
Override deepCopy as writeMarshallable adds a timing every time it is called.
|
void |
doWriteHistory(DocumentContext dc)
Default implementation for recording history into the supplied
DocumentContext. |
boolean |
equals(Object o) |
int |
hashCode() |
void |
historyWallClock(boolean historyWallClock)
Sets whether to use wall-clock time for new timings.
|
boolean |
isDirty() |
int |
lastSourceId()
Returns the last source id contained in this
MessageHistory. |
long |
lastSourceIndex()
Returns the last source index contained in this
MessageHistory. |
protected long |
nanoTime()
Returns the timestamp used for new timing entries.
|
void |
readMarshallable(@NotNull net.openhft.chronicle.bytes.BytesIn<?> bytes)
Reads the message history data from the provided bytes input.
|
void |
readMarshallable(@NotNull WireIn wire)
Deserialises this history from a
WireIn. |
void |
reset()
Clears all recorded entries.
|
void |
reset(int sourceId,
long sourceIndex)
Initialise the history with the given source and current time.
|
int |
sourceId(int n)
Returns the source id at a position specified by the input
n. |
boolean |
sourceIdsEndsWith(int[] sourceIds)
Returns
true if the source ids contained in this
MessageHistory end with the provided sourceIds. |
long |
sourceIndex(int n)
Returns the index of the source at a position specified by the
input
n. |
int |
sources()
Returns the number of sources contained in this
MessageHistory. |
long |
timing(int n)
Returns a timing at a position specified by the input
n. |
int |
timings()
Returns the number of timings contained in this
MessageHistory. |
String |
toString()
We need a custom toString as the base class toString calls writeMarshallable which does not mutate this,
but will display a different result every time you toString the object as it outputs System.nanoTime
or Wall Clock in NS if the wall.clock.message.history system property is set
|
void |
useBytesMarshallable(boolean useBytesMarshallable)
Sets whether to use the compact binary form when writing.
|
void |
writeMarshallable(@NotNull net.openhft.chronicle.bytes.BytesOut<?> b)
Serialises to the compact binary representation.
|
void |
writeMarshallable(@NotNull WireOut wire)
Serialises this history to the given wire.
|
void |
writeMarshallable0(@NotNull net.openhft.chronicle.bytes.BytesOut<?> b)
Fallback binary serialisation when direct memory is unavailable.
|
usesSelfDescribingMessageclone, finalize, getClass, notify, notifyAll, wait, wait, waitclear, emptyHistory, get, set, writeHistory$equals, $fieldInfoMap, $fieldInfos, $hashCode, $toString, className, copyTo, fromFile, fromFile, fromString, fromString, fromString, getField, getLongField, mergeToMap, setField, setLongField, streamFromFile, streamFromFilewriteValueunexpectedFieldpublic static final int MESSAGE_HISTORY_LENGTH
VanillaMessageHistory instance.public static final int MAX_LENGTH
public void addSourceDetails(boolean addSourceDetails)
addSourceDetails - True if source details should be added, false otherwise.public void reset()
reset in interface net.openhft.chronicle.core.io.Resettablereset in interface Marshallablereset in interface MessageHistorypublic boolean addSourceDetails()
public void reset(int sourceId,
long sourceIndex)
reset in interface MessageHistorysourceId - source identifiersourceIndex - index from the calling componentpublic int lastSourceId()
MessageHistoryMessageHistory.lastSourceId in interface MessageHistory-1 if nonepublic long lastSourceIndex()
MessageHistoryMessageHistory.lastSourceIndex in interface MessageHistory-1 if nonepublic int timings()
MessageHistoryMessageHistory.timings in interface MessageHistorypublic long timing(int n)
MessageHistoryn.timing in interface MessageHistoryn - index of the entrypublic int sources()
MessageHistoryMessageHistory.sources in interface MessageHistorypublic int sourceId(int n)
MessageHistoryn.sourceId in interface MessageHistoryn - index of the entrypublic boolean sourceIdsEndsWith(int[] sourceIds)
MessageHistorytrue if the source ids contained in this
MessageHistory end with the provided sourceIds.sourceIdsEndsWith in interface MessageHistorytrue if the recorded source ids end with the given arraypublic long sourceIndex(int n)
MessageHistoryn.sourceIndex in interface MessageHistoryn - index of the entrypublic void readMarshallable(@NotNull
@NotNull WireIn wire)
throws net.openhft.chronicle.core.io.IORuntimeException,
net.openhft.chronicle.core.io.InvalidMarshallableException
WireIn. Binary wires may hold a
compact representation starting with BinaryWireCode.HISTORY_MESSAGE.
Structured wires read 'sources' and 'timings' fields. If
addSourceDetails is true the caller is appended as another hop.readMarshallable in interface MarshallablereadMarshallable in interface ReadMarshallablewire - The wire input source.net.openhft.chronicle.core.io.IORuntimeException - If an IO error occurs during the read operation.net.openhft.chronicle.core.io.InvalidMarshallableException - If there's an error during marshalling.public void writeMarshallable(@NotNull
@NotNull WireOut wire)
useBytesMarshallable is true and the wire is binary,
otherwise writes 'sources' and 'timings' sequences. Resets the dirty flag.writeMarshallable in interface MarshallablewriteMarshallable in interface WriteMarshallablewire - The wire output destination.public void readMarshallable(@NotNull
@NotNull net.openhft.chronicle.bytes.BytesIn<?> bytes)
throws net.openhft.chronicle.core.io.IORuntimeException
readMarshallable in interface net.openhft.chronicle.bytes.BytesMarshallablereadMarshallable in interface net.openhft.chronicle.bytes.ReadBytesMarshallablebytes - Input bytes to read the data from.net.openhft.chronicle.core.io.IORuntimeExceptionpublic void writeMarshallable(@NotNull
@NotNull net.openhft.chronicle.bytes.BytesOut<?> b)
writeMarshallable in interface net.openhft.chronicle.bytes.BytesMarshallablewriteMarshallable in interface net.openhft.chronicle.bytes.WriteBytesMarshallablepublic void writeMarshallable0(@NotNull
@NotNull net.openhft.chronicle.bytes.BytesOut<?> b)
protected long nanoTime()
historyWallClock is true, otherwise System.nanoTime().public void addSource(int id,
long index)
id - source identifierindex - source indexpublic boolean isDirty()
isDirty in interface MessageHistorytrue if the message history has not been written using
Marshallable.writeMarshallable(net.openhft.chronicle.wire.WireOut)public void addTiming(long l)
IllegalStateException if the capacity is exceeded.public String toString()
@NotNull
public <T> T deepCopy()
throws net.openhft.chronicle.core.io.InvalidMarshallableException
toString()deepCopy in interface Marshallablenet.openhft.chronicle.core.io.InvalidMarshallableExceptionpublic net.openhft.chronicle.bytes.util.BinaryLengthLength binaryLengthLength()
WriteMarshallablebinaryLengthLength in interface WriteMarshallablepublic void doWriteHistory(DocumentContext dc)
MessageHistoryDocumentContext. It writes an event named
MethodReader.HISTORY with this history
as the value.doWriteHistory in interface MessageHistorydc - the document to append the history topublic void useBytesMarshallable(boolean useBytesMarshallable)
public void historyWallClock(boolean historyWallClock)
Copyright © 2026 Chronicle Software Ltd. All rights reserved.