-
Notifications
You must be signed in to change notification settings - Fork 896
Aeron Archive
The Aeron Archive service can record and replay messages streams. The service is designed to be high performance and test show that its major limitation is the performance of the storage for the archive or recorded streams. With sufficiently fast storage the archive can record or replay a stream of message at full 10GigE line rate.
Samples can be found here.
To start the Archive service you launch the ArchivingMediaDriver which includes the media driver by composition. This can run standalone or be embedded in another service. The configuration options can be found in the Archive.
The service offers three main features:
-
Record: service can record a particular subscription, described by
<channel, streamId>
. Each resulting image for the subscription will be recorded under a newrecordingId
. Local network publications are recorded using the spy feature for efficiency. If no subscribers are active then the recording can advance the stream by setting theaeron.spies.simulate.connection
property to true. -
Replay: service can replay a recorded
recordingId
from a particularposition
in stream for a particular length. If the value provided for the length isLong.MAX_VALUE
this this effectively is infinite replay and can follow an active recording. -
Query: service provides a rudimentary query interface which allows
recordingId
discovery and description. Currently this supports a query for all descriptors or filtered by<channel, streamId>
.
The Archive service can be run in one of three threading modes:
- ArchiveThreadingMode.DEDICATED: 3 threads are used. One for each of the conductor responding to control signals and queries, one for recording streams, and one for replaying streams.
- ArchiveThreadingMode.SHARED: 1 thread is used for all the control, recording, and replay.
-
ArchiveThreadingMode.INVOKER: No threads are used in the archive and the duty cycle is driven externally by calling the
AgentInvoker.invoke()
method on theArchive.invoker()
object. Each call to invoke with perform one duty cycle of the Archive.
The overall threading usage of the Archive is a combination for the ArchviveThreadingMode
and the ThreadingMode
for the composed MediaDriver
.
The Archive Client can communicate with an Archive using the control protocol and receive events on the progress of recording via the recording events stream. To support dynamic subscribers for the recording events stream then its channel can be multicast or MDC (Multi-Destination-Cast).
Samples using an archive can be found here.
An archive can be instructed to record streams, i.e. <channel, streamId>
pairs. These streams are recorded with the file sync level the archive has been launched with. Progress is reported on the recording events stream.
-
aeron.archive.file.sync.level=0
: for normal writes to the OS page cache for background writing to disk. -
aeron.archive.file.sync.level=1
: for forcing the dirty data pages to disk. -
aeron.archive.file.sync.level=2
: for forcing the dirty data pages and file metadata to disk.
Recordings will be assigned a recordingId
and a full description of the stream is captured in the Archive Catalog. The Catalog chronicles the contents of an archive as RecordingDescriptor
s which can be queried.
The progress of active recordings can be tracked using AeronStat
to view the rec-pos
counter for each stream.
The contents for Archive can be queried by listing the RecordingDescriptor
s. This can be a simple paging through all descriptors in the catalog, or the query can be filtered by <channel, streamId>
to reduce the result set.
The SBE message format for the descriptors is as follows:
<sbe:message name="RecordingDescriptor"
id="11"
description="Describes a recording in the catalog">
<field name="controlSessionId" id="1" type="int64"/>
<field name="correlationId" id="2" type="int64"/>
<field name="recordingId" id="3" type="int64"/>
<field name="startTimestamp" id="4" type="time_t"/>
<field name="stopTimestamp" id="5" type="time_t"/>
<field name="startPosition" id="6" type="int64"/>
<field name="stopPosition" id="7" type="int64"/>
<field name="initialTermId" id="8" type="int32"/>
<field name="segmentFileLength" id="9" type="int32"/>
<field name="termBufferLength" id="10" type="int32"/>
<field name="mtuLength" id="11" type="int32"/>
<field name="sessionId" id="12" type="int32"/>
<field name="streamId" id="13" type="int32"/>
<data name="strippedChannel" id="14" type="varAsciiEncoding"/>
<data name="originalChannel" id="15" type="varAsciiEncoding"/>
<data name="sourceIdentity" id="16" type="varAsciiEncoding"/>
</sbe:message>
A replay of a recorded stream can be requested by recordingId
. It is possible to replay a recording that has stopped or one that is currently in progress. Replays are request from a position and for a length.
If the requested replay is for a recording that is currently in progress and the length goes beyond the current recorded position then replay will track the live recording. This can be useful for a subscriber that wants to track a live stream but does not want to participate in flow control of the transient stream if it make slow the others down.
Replays of live streams should sent to a different <channel, streamId>
pairing to avoid congestion.