Skip to content

Commit

Permalink
[Java] Add archiveId to the ArchiveMarkFile.
Browse files Browse the repository at this point in the history
  • Loading branch information
vyazelenko committed Jan 14, 2025
1 parent 4bca6e6 commit 8c90817
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ private void encode(final Archive.Context ctx)
.eventsStreamId(ctx.recordingEventsStreamId())
.headerLength(HEADER_LENGTH)
.errorBufferLength(ctx.errorBufferLength())
.archiveId(ctx.archiveId())
.controlChannel(ctx.controlChannel())
.localControlChannel(ctx.localControlChannel())
.eventsChannel(ctx.recordingEventsChannel())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<sbe:messageSchema xmlns:sbe="http://fixprotocol.io/2016/sbe"
package="io.aeron.archive.codecs.mark"
id="100"
version="1"
version="2"
semanticVersion="5.2"
description="Codecs for Mark file of Aeron Archive."
byteOrder="littleEndian">
Expand Down Expand Up @@ -38,6 +38,7 @@
<field name="eventsStreamId" id="7" type="int32"/>
<field name="headerLength" id="8" type="length_t" sinceVersion="1"/>
<field name="errorBufferLength" id="9" type="length_t" sinceVersion="1"/>
<field name="archiveId" id="14" type="int64" sinceVersion="2"/>
<data name="controlChannel" id="10" type="varAsciiEncoding"/>
<data name="localControlChannel" id="11" type="varAsciiEncoding"/>
<data name="eventsChannel" id="12" type="varAsciiEncoding"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.aeron.exceptions.DriverTimeoutException;
import io.aeron.test.TestContexts;
import org.agrona.MarkFile;
import org.agrona.concurrent.CachedEpochClock;
import org.agrona.concurrent.SystemEpochClock;
import org.agrona.concurrent.UnsafeBuffer;
import org.junit.jupiter.api.Test;
Expand All @@ -47,16 +48,36 @@ void shouldUseMarkFileDirectory(final @TempDir File tempDir)
assertTrue(markFileDir.mkdirs());
assertFalse(markFile.exists());

try (ArchiveMarkFile archiveMarkFile = new ArchiveMarkFile(
TestContexts.localhostArchive()
final CachedEpochClock epochClock = new CachedEpochClock();
epochClock.advance(12345678909876L);
final Archive.Context ctx = TestContexts.localhostArchive()
.aeronDirectoryName(aeronDir.getAbsolutePath())
.controlStreamId(42)
.localControlStreamId(-118)
.recordingEventsStreamId(85858585)
.errorBufferLength(4096)
.archiveId(46238467823468L)
.archiveDir(archiveDir)
.markFileDir(markFileDir)
.controlChannel(AeronArchive.Configuration.localControlChannel())
.controlChannel("aeron:udp?endpoint=localhost:55555|alias=control")
.localControlChannel(AeronArchive.Configuration.localControlChannel())
.epochClock(SystemEpochClock.INSTANCE)))
.recordingEventsChannel("aeron:udp?endpoint=localhost:0")
.epochClock(epochClock);
try (ArchiveMarkFile archiveMarkFile = new ArchiveMarkFile(ctx))
{
assertNotNull(archiveMarkFile);

assertEquals(epochClock.time(), archiveMarkFile.decoder().startTimestamp());
assertEquals(ctx.controlStreamId(), archiveMarkFile.decoder().controlStreamId());
assertEquals(ctx.localControlStreamId(), archiveMarkFile.decoder().localControlStreamId());
assertEquals(ctx.recordingEventsStreamId(), archiveMarkFile.decoder().eventsStreamId());
assertEquals(ArchiveMarkFile.HEADER_LENGTH, archiveMarkFile.decoder().headerLength());
assertEquals(ctx.errorBufferLength(), archiveMarkFile.decoder().errorBufferLength());
assertEquals(ctx.archiveId(), archiveMarkFile.decoder().archiveId());
assertEquals(ctx.controlChannel(), archiveMarkFile.decoder().controlChannel());
assertEquals(ctx.localControlChannel(), archiveMarkFile.decoder().localControlChannel());
assertEquals(ctx.recordingEventsChannel(), archiveMarkFile.decoder().eventsChannel());
assertEquals(ctx.aeronDirectoryName(), archiveMarkFile.decoder().aeronDirectory());
}

assertTrue(markFile.exists());
Expand Down

0 comments on commit 8c90817

Please sign in to comment.