Skip to content

Commit

Permalink
[Java] Update the archiveId in the mark file if it is set when conclu…
Browse files Browse the repository at this point in the history
…ding the context.
  • Loading branch information
nickelaway committed Jan 21, 2025
1 parent 2c149a9 commit d027530
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions aeron-archive/src/main/java/io/aeron/archive/Archive.java
Original file line number Diff line number Diff line change
Expand Up @@ -3717,6 +3717,7 @@ private void concludeArchiveId()
if (NULL_VALUE == archiveId)
{
archiveId = aeron.clientId();
markFile.encoder().archiveId(archiveId);
}
}

Expand Down
25 changes: 25 additions & 0 deletions aeron-archive/src/test/java/io/aeron/archive/ArchiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,31 @@ void shouldTimeoutInactiveArchiveClients(final String controlRequestChannel, fin
}
}

@Test
void archiveMarkFileShouldContainArchiveIdSetOnContextConclude()
{
final MediaDriver.Context driverCtx = new MediaDriver.Context()
.errorHandler(Tests::onError)
.dirDeleteOnStart(true)
.threadingMode(ThreadingMode.SHARED);
final Archive.Context archiveCtx = TestContexts.localhostArchive().threadingMode(SHARED);

assertEquals(Aeron.NULL_VALUE, archiveCtx.archiveId()); // <-- Should not have been set yet.
try (ArchivingMediaDriver ignored = ArchivingMediaDriver.launch(driverCtx, archiveCtx);
AeronArchive archiveClient = AeronArchive.connect(TestContexts.localhostAeronArchive()))
{
final long archiveId = archiveCtx.archiveId(); // <-- Should have been set now as the context is concluded.
assertNotEquals(Aeron.NULL_VALUE, archiveId);
assertEquals(archiveId, archiveClient.archiveId());
assertEquals(archiveId, archiveCtx.archiveMarkFile().archiveId());
}
finally
{
archiveCtx.deleteDirectory();
driverCtx.deleteDirectory();
}
}

private static Catalog openCatalog(final String archiveDirectoryName)
{
final IntConsumer intConsumer = (version) ->
Expand Down

0 comments on commit d027530

Please sign in to comment.