Skip to content

Commit

Permalink
improve FixArchive{Printer,Scanner} default settings (fixes #468, fixes
Browse files Browse the repository at this point in the history
#492, closes #493)

In typical cases they should not require any archive settings, but if
any are required, then all should be overridable using system properties.
  • Loading branch information
wojciech-adaptive committed Mar 14, 2024
1 parent c254de8 commit 0f6bff0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.aeron.archive.Archive;
import io.aeron.archive.ArchivingMediaDriver;
import io.aeron.archive.client.AeronArchive;
import io.aeron.driver.MediaDriver;
import org.agrona.CloseHelper;
import org.agrona.DirectBuffer;
Expand Down Expand Up @@ -89,9 +90,22 @@ private ArchivingMediaDriver startArchiverIfNeeded()
return null;
}

final Archive.Context archiveCtx = new Archive.Context().archiveDirectoryName(offlineArchiveDirectoryName);
if (archiveCtx.controlChannel() == null)
{
final AeronArchive.Context archiveClientCtx = new AeronArchive.Context()
.controlResponseChannel("aeron:udp?endpoint=localhost:0");
archiveCtx.controlChannelEnabled(false)
.archiveClientContext(archiveClientCtx);
}
if (archiveCtx.replicationChannel() == null)
{
archiveCtx.replicationChannel("aeron:udp?endpoint=localhost:0");
}

return ArchivingMediaDriver.launch(
new MediaDriver.Context().aeronDirectoryName(aeronDirectoryName),
new Archive.Context().archiveDirectoryName(offlineArchiveDirectoryName));
archiveCtx);
}

private void parseArgs(final String[] args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package uk.co.real_logic.artio.engine.logger;

import io.aeron.Aeron;
import io.aeron.CommonContext;
import io.aeron.archive.client.AeronArchive;
import org.agrona.collections.IntHashSet;
import org.agrona.concurrent.IdleStrategy;
Expand All @@ -35,7 +36,6 @@
*/
public class FixArchiveScanner implements AutoCloseable
{
public static final String DEFAULT_ARCHIVE_CONTROL_CHANNEL = "aeron:udp?endpoint=localhost:8010";
public static final int DEFAULT_FRAGMENT_LIMIT = 10000;

static final boolean DEBUG_LOG_ARCHIVE_SCAN = DebugLogger.isEnabled(ARCHIVE_SCAN);
Expand Down Expand Up @@ -211,7 +211,15 @@ public FixArchiveScanner(final Configuration configuration)
if (archiveContext == null)
{
archiveContext = new AeronArchive.Context();
archiveContext.controlResponseChannel(DEFAULT_ARCHIVE_CONTROL_CHANNEL);
if (archiveContext.controlRequestChannel() == null)
{
archiveContext.controlRequestChannel(AeronArchive.Configuration.localControlChannel())
.controlRequestStreamId(AeronArchive.Configuration.localControlStreamId());
}
if (archiveContext.controlResponseChannel() == null)
{
archiveContext.controlResponseChannel(CommonContext.IPC_CHANNEL);
}
}
// Context closes Aeron instance if this fails to connect.
final AeronArchive aeronArchive = AeronArchive.connect(archiveContext.aeron(aeron).ownsAeronClient(true));
Expand Down

0 comments on commit 0f6bff0

Please sign in to comment.