Skip to content

Commit

Permalink
[Java] Fix conclude order on Archive context.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Aug 27, 2017
1 parent 8cf6f50 commit 3792072
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions aeron-archive/src/main/java/io/aeron/archive/Archive.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ public final class Archive implements AutoCloseable
private Archive(final Context ctx)
{
this.ctx = ctx;
ctx.conclude();

ctx.aeronContext
.errorHandler(ctx.countedErrorHandler())
.driverAgentInvoker(ctx.mediaDriverAgentInvoker())
.useConductorAgentInvoker(true)
.clientLock(new NoOpLock());

aeron = Aeron.connect(ctx.aeronContext);

ctx.conclude();

final ArchiveConductor conductor =
ArchiveThreadingMode.DEDICATED == ctx.threadingMode() ?
new DedicatedModeArchiveConductor(aeron, ctx) :
Expand Down Expand Up @@ -255,8 +255,7 @@ public static int replayFragmentLimit()
*/
public static class Context
{
private final Aeron.Context aeronContext;

private Aeron.Context aeronContext;
private File archiveDir;

private String controlChannel = AeronArchive.Configuration.controlChannel();
Expand All @@ -283,25 +282,6 @@ public static class Context
private int maxConcurrentRecordings = Configuration.maxConcurrentRecordings();
private int maxConcurrentReplays = Configuration.maxConcurrentReplays();

/**
* Default constructor that sets up a default {@link #aeronContext()}.
*/
public Context()
{
this(new Aeron.Context());
}

/**
* Create a new context and provide an {@link Aeron.Context} for the client.
*
* @param aeronContext for the Aeron client.
*/
public Context(final Aeron.Context aeronContext)
{
this.aeronContext = aeronContext;
aeronContext.useConductorAgentInvoker(true);
}

/**
* Conclude the configuration parameters by resolving dependencies and null values to use defaults.
*/
Expand All @@ -317,6 +297,11 @@ public void conclude()
throw new IllegalStateException("Counter manager must be externally supplied");
}

if (null == aeronContext)
{
aeronContext = new Aeron.Context();
}

errorCounter = countersManager.newCounter("Archive errors");
countedErrorHandler = new CountedErrorHandler(errorHandler, errorCounter);

Expand All @@ -342,6 +327,30 @@ public void conclude()
}
}

/**
* Get the Aeron client context used by the Archive.
*
* @return Aeron client context used by the Archive
*/
public Aeron.Context aeronContext()
{
return aeronContext;
}

/**
* Provide an {@link Aeron.Context} for configuring the connection to Aeron.
* <p>
* If not provided then a default context will be created.
*
* @param aeronContext for configuring the connection to Aeron.
* @return this for a fluent API.
*/
public Context aeronContext(final Aeron.Context aeronContext)
{
this.aeronContext = aeronContext;
return this;
}

/**
* Get the directory in which the Archive will store recordings and the {@link Catalog}.
*
Expand All @@ -364,16 +373,6 @@ public Context archiveDir(final File archiveDir)
return this;
}

/**
* Get the Aeron client context used by the Archive.
*
* @return Aeron client context used by the Archive
*/
public Aeron.Context aeronContext()
{
return aeronContext;
}

/**
* Get the channel URI on which the control request subscription will listen.
*
Expand Down

0 comments on commit 3792072

Please sign in to comment.