Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] Update the archiveId in the mark file if it is set when conclu… #1726

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading