public static class Aeron.Context extends CommonContext
Aeron
class via the Aeron.connect(Aeron.Context)
method and its overloads. It gives applications some control over the interactions with the Aeron Media Driver.
It can also set up error handling as well as application callbacks for image information from the
Media Driver.
A number of the properties are for testing and should not be set by end users.
Note: Do not reuse instances of the context across different Aeron
clients.
The context will be owned by ClientConductor
after a successful
Aeron.connect(Context)
and closed via Aeron.close()
.
AERON_DIR_PROP_DEFAULT, AERON_DIR_PROP_NAME, ALIAS_PARAM_NAME, DEFAULT_DRIVER_TIMEOUT_MS, DRIVER_TIMEOUT_MS, DRIVER_TIMEOUT_PROP_NAME, ENDPOINT_PARAM_NAME, INITIAL_TERM_ID_PARAM_NAME, INTERFACE_PARAM_NAME, IPC_CHANNEL, IPC_MEDIA, LINGER_PARAM_NAME, MDC_CONTROL_MODE_DYNAMIC, MDC_CONTROL_MODE_MANUAL, MDC_CONTROL_MODE_PARAM_NAME, MDC_CONTROL_PARAM_NAME, MTU_LENGTH_PARAM_NAME, NULL_SESSION_ID, RELIABLE_STREAM_PARAM_NAME, SESSION_ID_PARAM_NAME, SPARSE_PARAM_NAME, SPY_PREFIX, TAG_PREFIX, TAGS_PARAM_NAME, TERM_ID_PARAM_NAME, TERM_LENGTH_PARAM_NAME, TERM_OFFSET_PARAM_NAME, TTL_PARAM_NAME, UDP_MEDIA
Constructor and Description |
---|
Context() |
Modifier and Type | Method and Description |
---|---|
Aeron.Context |
aeronDirectoryName(java.lang.String dirName)
Set the top level Aeron directory used for communication between the client and Media Driver, and the location
of the data buffers.
|
AvailableCounterHandler |
availableCounterHandler()
Get the callback handler for when a counter is available.
|
Aeron.Context |
availableCounterHandler(AvailableCounterHandler handler)
Setup a callback for when a counter is available.
|
AvailableImageHandler |
availableImageHandler()
Get the default callback handler for notifying when
Image s become available. |
Aeron.Context |
availableImageHandler(AvailableImageHandler handler)
Setup a default callback for when an
Image is available. |
long |
clientId()
Get the client identity that has been allocated for communicating with the media driver.
|
java.util.concurrent.locks.Lock |
clientLock()
Get the
Lock that is used to provide mutual exclusion in the Aeron client. |
Aeron.Context |
clientLock(java.util.concurrent.locks.Lock lock)
The
Lock that is used to provide mutual exclusion in the Aeron client. |
Aeron.Context |
clone()
Perform a shallow copy of the object.
|
void |
close()
Clean up all resources that the client uses to communicate with the Media Driver.
|
Aeron.Context |
conclude()
This is called automatically by
Aeron.connect(Aeron.Context) and its overloads. |
org.agrona.concurrent.AgentInvoker |
driverAgentInvoker()
Get the
AgentInvoker that is used to run the Media Driver while awaiting a synchronous response. |
Aeron.Context |
driverAgentInvoker(org.agrona.concurrent.AgentInvoker driverAgentInvoker)
Set the
AgentInvoker for the Media Driver to be used while awaiting a synchronous response. |
DriverProxy |
driverProxy()
Get the proxy for communicating with the media driver.
|
Aeron.Context |
driverTimeoutMs(long value)
Set the amount of time, in milliseconds, that this client will wait until it determines the
Media Driver is unavailable.
|
org.agrona.concurrent.EpochClock |
epochClock()
Get the
EpochClock used by the client for the epoch time in milliseconds. |
Aeron.Context |
epochClock(org.agrona.concurrent.EpochClock clock)
Set the
EpochClock to be used for tracking wall clock time when interacting with the driver. |
org.agrona.ErrorHandler |
errorHandler()
Get the error handler that will be called for errors reported back from the media driver.
|
Aeron.Context |
errorHandler(org.agrona.ErrorHandler errorHandler)
Handle Aeron exceptions in a callback method.
|
org.agrona.concurrent.IdleStrategy |
idleStrategy()
Get the
IdleStrategy employed by the client conductor thread. |
Aeron.Context |
idleStrategy(org.agrona.concurrent.IdleStrategy idleStrategy)
Provides an IdleStrategy for the thread responsible for communicating with the Aeron Media Driver.
|
long |
interServiceTimeout()
Return the timeout between service calls to the duty cycle for the client.
|
long |
keepAliveInterval()
Get the interval in nanoseconds for which the client will perform keep-alive operations.
|
Aeron.Context |
keepAliveInterval(long value)
Set the interval in nanoseconds for which the client will perform keep-alive operations.
|
io.aeron.LogBuffersFactory |
logBuffersFactory()
Get the factory for making log buffers.
|
org.agrona.concurrent.NanoClock |
nanoClock()
Get the
NanoClock to be used for tracking high resolution time. |
Aeron.Context |
nanoClock(org.agrona.concurrent.NanoClock clock)
Set the
NanoClock to be used for tracking high resolution time. |
long |
resourceLingerDurationNs()
Duration to wait while lingering a entity such as an
Image before deleting underlying resources
such as memory mapped files. |
Aeron.Context |
resourceLingerDurationNs(long resourceLingerDurationNs)
Duration to wait while lingering a entity such as an
Image before deleting underlying resources
such as memory mapped files. |
java.util.concurrent.ThreadFactory |
threadFactory()
The thread factory to be use to construct the conductor thread
|
Aeron.Context |
threadFactory(java.util.concurrent.ThreadFactory threadFactory)
Specify the thread factory to use when starting the conductor thread.
|
org.agrona.concurrent.broadcast.CopyBroadcastReceiver |
toClientBuffer()
The buffer used for communicating from the media driver to the Aeron client.
|
org.agrona.concurrent.ringbuffer.RingBuffer |
toDriverBuffer()
Get the
RingBuffer used for sending commands to the media driver. |
UnavailableCounterHandler |
unavailableCounterHandler()
Get the callback handler for when a counter is unavailable.
|
Aeron.Context |
unavailableCounterHandler(UnavailableCounterHandler handler)
Setup a callback for when a counter is unavailable.
|
UnavailableImageHandler |
unavailableImageHandler()
Get the callback handler for when an
Image is unavailable. |
Aeron.Context |
unavailableImageHandler(UnavailableImageHandler handler)
Setup a default callback for when an
Image is unavailable. |
boolean |
useConductorAgentInvoker()
Should an
AgentInvoker be used for running the ClientConductor rather than run it on
a thread with a AgentRunner . |
Aeron.Context |
useConductorAgentInvoker(boolean useConductorAgentInvoker)
Should an
AgentInvoker be used for running the ClientConductor rather than run it on
a thread with a AgentRunner . |
aeronDirectory, aeronDirectoryName, cncFile, concludeAeronDirectory, countersMetaDataBuffer, countersMetaDataBuffer, countersValuesBuffer, countersValuesBuffer, deleteAeronDirectory, driverTimeoutMs, formatError, generateRandomDirName, getAeronDirectoryName, isDriverActive, isDriverActive, isDriverActive, mapExistingCncFile, newDefaultCncFile, saveErrorLog, saveErrorLog
public Aeron.Context clone()
clone
in class CommonContext
public Aeron.Context conclude()
Aeron.connect(Aeron.Context)
and its overloads.
There is no need to call it from a client application. It is responsible for providing default
values for options that are not individually changed through field setters.conclude
in class CommonContext
public long clientId()
public Aeron.Context useConductorAgentInvoker(boolean useConductorAgentInvoker)
AgentInvoker
be used for running the ClientConductor
rather than run it on
a thread with a AgentRunner
.useConductorAgentInvoker
- use AgentInvoker
be used for running the ClientConductor
?public boolean useConductorAgentInvoker()
AgentInvoker
be used for running the ClientConductor
rather than run it on
a thread with a AgentRunner
.ClientConductor
will be run with an AgentInvoker
otherwise false.public Aeron.Context driverAgentInvoker(org.agrona.concurrent.AgentInvoker driverAgentInvoker)
AgentInvoker
for the Media Driver to be used while awaiting a synchronous response.
Useful for when running on a low thread count scenario.
driverAgentInvoker
- to be invoked while awaiting a response in the client.public org.agrona.concurrent.AgentInvoker driverAgentInvoker()
AgentInvoker
that is used to run the Media Driver while awaiting a synchronous response.AgentInvoker
that is used for running the Media Driver.public Aeron.Context clientLock(java.util.concurrent.locks.Lock lock)
Lock
that is used to provide mutual exclusion in the Aeron client.
If the useConductorAgentInvoker()
is set and only one thread accesses the client
then the lock can be set to NoOpLock
to elide the lock overhead.
lock
- that is used to provide mutual exclusion in the Aeron client.public java.util.concurrent.locks.Lock clientLock()
Lock
that is used to provide mutual exclusion in the Aeron client.Lock
that is used to provide mutual exclusion in the Aeron client.public Aeron.Context epochClock(org.agrona.concurrent.EpochClock clock)
EpochClock
to be used for tracking wall clock time when interacting with the driver.clock
- EpochClock
to be used for tracking wall clock time when interacting with the driver.public org.agrona.concurrent.EpochClock epochClock()
EpochClock
used by the client for the epoch time in milliseconds.EpochClock
used by the client for the epoch time in milliseconds.public Aeron.Context nanoClock(org.agrona.concurrent.NanoClock clock)
NanoClock
to be used for tracking high resolution time.clock
- NanoClock
to be used for tracking high resolution time.public org.agrona.concurrent.NanoClock nanoClock()
NanoClock
to be used for tracking high resolution time.NanoClock
to be used for tracking high resolution time.public Aeron.Context idleStrategy(org.agrona.concurrent.IdleStrategy idleStrategy)
idleStrategy
- Thread idle strategy for communication with the Media Driver.public org.agrona.concurrent.IdleStrategy idleStrategy()
IdleStrategy
employed by the client conductor thread.IdleStrategy
employed by the client conductor thread.public org.agrona.concurrent.broadcast.CopyBroadcastReceiver toClientBuffer()
public org.agrona.concurrent.ringbuffer.RingBuffer toDriverBuffer()
RingBuffer
used for sending commands to the media driver.RingBuffer
used for sending commands to the media driver.public DriverProxy driverProxy()
public io.aeron.LogBuffersFactory logBuffersFactory()
public Aeron.Context errorHandler(org.agrona.ErrorHandler errorHandler)
Aeron.Configuration.DEFAULT_ERROR_HANDLER
. This is the error handler which will be used if an error occurs
during the callback for poll operations such as Subscription.poll(FragmentHandler, int)
.
The error handler can be reset after Aeron.connect()
and the latest version will always be used
so that the boot strapping process can be performed such as replacing the default one with a
CountedErrorHandler
.
errorHandler
- Method to handle objects of type Throwable.DriverTimeoutException
,
RegistrationException
public org.agrona.ErrorHandler errorHandler()
public Aeron.Context availableImageHandler(AvailableImageHandler handler)
Image
is available.handler
- Callback method for handling available image notifications.public AvailableImageHandler availableImageHandler()
Image
s become available.Image
s become available.public Aeron.Context unavailableImageHandler(UnavailableImageHandler handler)
Image
is unavailable.handler
- Callback method for handling unavailable image notifications.public UnavailableImageHandler unavailableImageHandler()
Image
is unavailable.Image
is unavailable.public Aeron.Context availableCounterHandler(AvailableCounterHandler handler)
handler
- to be called for handling available counter notifications.public AvailableCounterHandler availableCounterHandler()
public Aeron.Context unavailableCounterHandler(UnavailableCounterHandler handler)
handler
- to be called for handling unavailable counter notifications.public UnavailableCounterHandler unavailableCounterHandler()
public Aeron.Context keepAliveInterval(long value)
value
- the interval in nanoseconds for which the client will perform keep-alive operations.public long keepAliveInterval()
public Aeron.Context driverTimeoutMs(long value)
DriverTimeoutException
will be generated for the error handler.driverTimeoutMs
in class CommonContext
value
- Number of milliseconds.errorHandler(ErrorHandler)
public long interServiceTimeout()
When exceeded, errorHandler
will be called and the active Publication
s and Image
s
closed.
This value is controlled by the driver and included in the CnC file. It can be configured by adjusting the aeron.client.liveness.timeout property on the media driver.
public Aeron.Context resourceLingerDurationNs(long resourceLingerDurationNs)
Image
before deleting underlying resources
such as memory mapped files.resourceLingerDurationNs
- to wait before deleting a expired resource.Aeron.Configuration.RESOURCE_LINGER_DURATION_PROP_NAME
public long resourceLingerDurationNs()
Image
before deleting underlying resources
such as memory mapped files.Aeron.Configuration.RESOURCE_LINGER_DURATION_PROP_NAME
public Aeron.Context aeronDirectoryName(java.lang.String dirName)
CommonContext
aeronDirectoryName
in class CommonContext
dirName
- New top level Aeron directory.CommonContext.aeronDirectoryName(String)
public Aeron.Context threadFactory(java.util.concurrent.ThreadFactory threadFactory)
threadFactory
- thread factory to construct the thread.public java.util.concurrent.ThreadFactory threadFactory()
Thread.Thread(Runnable)
if none is providedpublic void close()
close
in class CommonContext
Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.