public static class Aeron.Context extends CommonContext
Aeron client 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().
CommonContext.InferableBooleanAERON_DIR_PROP_DEFAULT, AERON_DIR_PROP_NAME, ALIAS_PARAM_NAME, CHANNEL_RECEIVE_TIMESTAMP_OFFSET_PARAM_NAME, CHANNEL_SEND_TIMESTAMP_OFFSET_PARAM_NAME, CONGESTION_CONTROL_PARAM_NAME, DEBUG_TIMEOUT_PROP_NAME, DEFAULT_DRIVER_TIMEOUT_MS, DRIVER_TIMEOUT_MS, DRIVER_TIMEOUT_PROP_NAME, ENDPOINT_PARAM_NAME, EOS_PARAM_NAME, FALLBACK_LOGGER_PROP_NAME, FLOW_CONTROL_PARAM_NAME, GROUP_PARAM_NAME, GROUP_TAG_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, MEDIA_RCV_TIMESTAMP_OFFSET_PARAM_NAME, MTU_LENGTH_PARAM_NAME, NULL_SESSION_ID, RECEIVER_WINDOW_LENGTH_PARAM_NAME, REJOIN_PARAM_NAME, RELIABLE_STREAM_PARAM_NAME, RESERVED_OFFSET, SESSION_ID_PARAM_NAME, SOCKET_RCVBUF_PARAM_NAME, SOCKET_SNDBUF_PARAM_NAME, SPARSE_PARAM_NAME, SPIES_SIMULATE_CONNECTION_PARAM_NAME, SPY_PREFIX, TAG_PREFIX, TAGS_PARAM_NAME, TERM_ID_PARAM_NAME, TERM_LENGTH_PARAM_NAME, TERM_OFFSET_PARAM_NAME, TETHER_PARAM_NAME, TTL_PARAM_NAME, UDP_CHANNEL, UDP_MEDIA| Constructor and Description |
|---|
Context() |
| Modifier and Type | Method and Description |
|---|---|
Aeron.Context |
aeronDirectoryName(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)
Set up a callback for when a counter is available.
|
AvailableImageHandler |
availableImageHandler()
Get the default callback handler for notifying when
Images become available. |
Aeron.Context |
availableImageHandler(AvailableImageHandler handler)
Set up a default callback for when an
Image is available. |
IdleStrategy |
awaitingIdleStrategy()
The
IdleStrategy to be used when awaiting a response from the Media Driver. |
Aeron.Context |
awaitingIdleStrategy(IdleStrategy idleStrategy)
Provides an
IdleStrategy to be used when awaiting a response from the Media Driver. |
long |
clientId()
Get the client identity that has been allocated for communicating with the media driver.
|
Lock |
clientLock()
Get the
Lock that is used to provide mutual exclusion in the Aeron client. |
Aeron.Context |
clientLock(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.
|
Runnable |
closeHandler()
Get the
Runnable that is called when the client is closed by timeout or normal means. |
Aeron.Context |
closeHandler(Runnable handler)
Set a
Runnable that is called when the client is closed by timeout or normal means. |
long |
closeLingerDurationNs()
Duration to linger on closing to allow publishers and subscribers time to notice closed resources.
|
Aeron.Context |
closeLingerDurationNs(long closeLingerDurationNs)
Duration to linger on closing to allow publishers and subscribers time to notice closed resources.
|
Aeron.Context |
conclude()
This is called automatically by
Aeron.connect(Aeron.Context) and its overloads. |
AgentInvoker |
driverAgentInvoker()
Get the
AgentInvoker that is used to run the Media Driver while awaiting a synchronous response. |
Aeron.Context |
driverAgentInvoker(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.
|
EpochClock |
epochClock()
Get the
EpochClock used by the client for the epoch time in milliseconds. |
Aeron.Context |
epochClock(EpochClock clock)
Set the
EpochClock to be used for tracking wall clock time when interacting with the driver. |
ErrorHandler |
errorHandler()
Get the error handler that will be called for errors reported back from the media driver or during poll
operations.
|
Aeron.Context |
errorHandler(ErrorHandler errorHandler)
Handle Aeron exceptions in a callback method.
|
IdleStrategy |
idleStrategy()
Get the
IdleStrategy employed by the client for the client duty cycle. |
Aeron.Context |
idleStrategy(IdleStrategy idleStrategy)
Provides an
IdleStrategy for the thread responsible for the client duty cycle. |
long |
interServiceTimeoutNs()
Return the timeout between service calls to the duty cycle for the client.
|
long |
keepAliveIntervalNs()
Get the interval in nanoseconds for which the client will perform keep-alive operations.
|
Aeron.Context |
keepAliveIntervalNs(long value)
Set the interval in nanoseconds for which the client will perform keep-alive operations.
|
NanoClock |
nanoClock()
Get the
NanoClock to be used for tracking high resolution time. |
Aeron.Context |
nanoClock(NanoClock clock)
Set the
NanoClock to be used for tracking high resolution time. |
boolean |
preTouchMappedMemory()
Should mapped-memory be pre-touched to avoid soft page faults.
|
Aeron.Context |
preTouchMappedMemory(boolean preTouchMappedMemory)
Should mapped-memory be pre-touched to avoid soft page faults.
|
long |
resourceLingerDurationNs()
Duration to wait while lingering an entity such as an
Image before deleting underlying resources
such as memory mapped files. |
Aeron.Context |
resourceLingerDurationNs(long resourceLingerDurationNs)
Duration to wait while lingering an entity such as an
Image before deleting underlying resources
such as memory mapped files. |
ErrorHandler |
subscriberErrorHandler()
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). |
Aeron.Context |
subscriberErrorHandler(ErrorHandler errorHandler)
The error handler which will be used if an error occurs during the callback for poll operations such as
Subscription.poll(FragmentHandler, int). |
ThreadFactory |
threadFactory()
The thread factory to be used to construct the conductor thread.
|
Aeron.Context |
threadFactory(ThreadFactory threadFactory)
Specify the thread factory to use when starting the conductor thread.
|
CopyBroadcastReceiver |
toClientBuffer()
The buffer used for communicating from the media driver to the Aeron client.
|
RingBuffer |
toDriverBuffer()
Get the
RingBuffer used for sending commands to the media driver. |
String |
toString() |
UnavailableCounterHandler |
unavailableCounterHandler()
Get the callback handler for when a counter is unavailable.
|
Aeron.Context |
unavailableCounterHandler(UnavailableCounterHandler handler)
Set up 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)
Set up 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, checkDebugTimeout, checkDebugTimeout, cncFile, concludeAeronDirectory, countersMetaDataBuffer, countersMetaDataBuffer, countersValuesBuffer, countersValuesBuffer, deleteAeronDirectory, driverTimeoutMs, errorLogBuffer, fallbackLogger, generateRandomDirName, getAeronDirectoryName, isConcluded, isDriverActive, isDriverActive, isDriverActive, mapExistingCncFile, newCncFile, newDefaultCncFile, printErrorLog, requestDriverTermination, saveErrorLog, saveErrorLog, saveExistingErrors, setupErrorHandlerpublic Aeron.Context clone()
clone in class CommonContextpublic 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 CommonContextpublic 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 preTouchMappedMemory(boolean preTouchMappedMemory)
preTouchMappedMemory - true if mapped-memory should be pre-touched otherwise false.Aeron.Configuration.PRE_TOUCH_MAPPED_MEMORY_PROP_NAMEpublic boolean preTouchMappedMemory()
Aeron.Configuration.PRE_TOUCH_MAPPED_MEMORY_PROP_NAMEpublic Aeron.Context driverAgentInvoker(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 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(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 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(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 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(NanoClock clock)
NanoClock to be used for tracking high resolution time.clock - NanoClock to be used for tracking high resolution time.public NanoClock nanoClock()
NanoClock to be used for tracking high resolution time.NanoClock to be used for tracking high resolution time.public Aeron.Context idleStrategy(IdleStrategy idleStrategy)
IdleStrategy for the thread responsible for the client duty cycle.idleStrategy - Thread idle strategy for the client duty cycle.public IdleStrategy idleStrategy()
IdleStrategy employed by the client for the client duty cycle.IdleStrategy employed by the client for the client duty cycle.public Aeron.Context awaitingIdleStrategy(IdleStrategy idleStrategy)
IdleStrategy to be used when awaiting a response from the Media Driver.idleStrategy - Thread idle strategy for awaiting a response from the Media Driver.public IdleStrategy awaitingIdleStrategy()
IdleStrategy to be used when awaiting a response from the Media Driver.
This can be changed to a BusySpinIdleStrategy or YieldingIdleStrategy for lower response
time, especially for adding counters or releasing resources, at the expense of CPU usage.
IdleStrategy to be used when awaiting a response from the Media Driver.public CopyBroadcastReceiver toClientBuffer()
public RingBuffer toDriverBuffer()
RingBuffer used for sending commands to the media driver.RingBuffer used for sending commands to the media driver.public DriverProxy driverProxy()
public Aeron.Context errorHandler(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 bootstrapping process can be performed such as replacing the default one with a
CountedErrorHandler.
errorHandler - Method to handle objects of type Throwable.DriverTimeoutException,
RegistrationExceptionpublic ErrorHandler errorHandler()
public Aeron.Context subscriberErrorHandler(ErrorHandler errorHandler)
Subscription.poll(FragmentHandler, int). The default will be errorHandler() if not set.errorHandler - Method to handle objects of type Throwable.DriverTimeoutException,
RegistrationExceptionpublic ErrorHandler subscriberErrorHandler()
Subscription.poll(FragmentHandler, int). The default will be errorHandler() if not
set. To have Subscription.poll(FragmentHandler, int) not delegate then set with
RethrowingErrorHandler.public Aeron.Context availableImageHandler(AvailableImageHandler handler)
Image is available.handler - Callback method for handling available image notifications.public AvailableImageHandler availableImageHandler()
Images become available.Images 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)
Aeron.addAvailableCounterHandler(AvailableCounterHandler).handler - to be called for handling available counter notifications.public AvailableCounterHandler availableCounterHandler()
public Aeron.Context unavailableCounterHandler(UnavailableCounterHandler handler)
Aeron.addUnavailableCounterHandler(UnavailableCounterHandler).handler - to be called for handling unavailable counter notifications.public UnavailableCounterHandler unavailableCounterHandler()
public Aeron.Context closeHandler(Runnable handler)
Runnable that is called when the client is closed by timeout or normal means.
It is not safe to call any API functions from any threads after this hook is called. In addition, any in flight calls may still cause faults. Thus treating this as a hard error and terminate the process in this hook as soon as possible is recommended.
handler - that is called when the client is closed.public Runnable closeHandler()
Runnable that is called when the client is closed by timeout or normal means.Runnable that is called when the client is closed.public Aeron.Context keepAliveIntervalNs(long value)
value - the interval in nanoseconds for which the client will perform keep-alive operations.public long keepAliveIntervalNs()
public Aeron.Context driverTimeoutMs(long value)
DriverTimeoutException will be generated for the error handler.driverTimeoutMs in class CommonContextvalue - Number of milliseconds.errorHandler(ErrorHandler)public long interServiceTimeoutNs()
When exceeded, errorHandler() will be called and the active Publications, Images,
and Counters will be 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 set 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 an expired resource.Aeron.Configuration.RESOURCE_LINGER_DURATION_PROP_NAMEpublic long resourceLingerDurationNs()
Image before deleting underlying resources
such as memory mapped files.Aeron.Configuration.RESOURCE_LINGER_DURATION_PROP_NAMEpublic Aeron.Context closeLingerDurationNs(long closeLingerDurationNs)
This value can be increased from the default to a few seconds to better cope with long GC pauses or resource starved environments. Issues could manifest as seg faults using files after they have been unmapped from publishers or subscribers not noticing the close in a timely fashion.
closeLingerDurationNs - to wait before deleting resources when closing.Aeron.Configuration.CLOSE_LINGER_DURATION_PROP_NAMEpublic long closeLingerDurationNs()
This value can be increased from the default to a few seconds to better cope with long GC pauses or resource starved environments. Issues could manifest as seg faults using files after they have been unmapped from publishers or subscribers not noticing the close in a timely fashion.
Aeron.Configuration.CLOSE_LINGER_DURATION_PROP_NAMEpublic Aeron.Context aeronDirectoryName(String dirName)
aeronDirectoryName in class CommonContextdirName - New top level Aeron directory.public Aeron.Context threadFactory(ThreadFactory threadFactory)
threadFactory - thread factory to construct the thread.public ThreadFactory threadFactory()
Thread(Runnable) if none is provided.public void close()
close in class CommonContextCopyright © 2014-2023 Real Logic Limited. All Rights Reserved.