public class CommonContext extends Object implements Cloneable
This class should have conclude()
called before the methods are used or at least
concludeAeronDirectory()
to avoid NPEs.
Properties:
aeron.dir
: Use value as directory name for Aeron buffers and status.Modifier and Type | Class and Description |
---|---|
static class |
CommonContext.InferableBoolean
Condition to specify a triple state conditional of always override to be true, always override to be false,
or infer value.
|
Modifier and Type | Field and Description |
---|---|
static String |
AERON_DIR_PROP_DEFAULT
The value of the top level Aeron directory unless overridden by
aeronDirectoryName(String) |
static String |
AERON_DIR_PROP_NAME
The top level Aeron directory used for communication between a Media Driver and client.
|
static String |
ALIAS_PARAM_NAME
Parameter name for channel URI param to indicate an alias for the given URI.
|
static String |
CHANNEL_RECEIVE_TIMESTAMP_OFFSET_PARAM_NAME
Parameter name of the offset for the channel receive timestamp to be inserted into the incoming message on a
subscription.
|
static String |
CHANNEL_SEND_TIMESTAMP_OFFSET_PARAM_NAME
Parameter name of the offset for the channel send timestamp to be inserted into the outgoing message
on a publication.
|
static String |
CONGESTION_CONTROL_PARAM_NAME
Parameter name for Subscription URI param to indicate the congestion control algorithm to be used.
|
static String |
DEBUG_TIMEOUT_PROP_NAME
Property name for the timeout to use in debug mode.
|
static long |
DEFAULT_DRIVER_TIMEOUT_MS
Default timeout in which the driver is expected to respond or heartbeat.
|
static long |
DRIVER_TIMEOUT_MS
Timeout in which the driver is expected to respond or heartbeat.
|
static String |
DRIVER_TIMEOUT_PROP_NAME
Property name for driver timeout after which the driver is considered inactive.
|
static String |
ENDPOINT_PARAM_NAME
The address and port used for a UDP channel.
|
static String |
EOS_PARAM_NAME
Parameter name for channel URI param to indicate if End of Stream (EOS) should be sent or not.
|
static String |
FALLBACK_LOGGER_PROP_NAME
Property name for a fallback
PrintStream based logger when it is not possible to use the error logging
callback. |
static String |
FLOW_CONTROL_PARAM_NAME
Parameter name for Publication URI param to indicate the flow control strategy to be used.
|
static String |
GROUP_PARAM_NAME
Parameter name for channel URI param to indicate if a Subscription represents a group member or individual
from the perspective of message reception.
|
static String |
GROUP_TAG_PARAM_NAME
Parameter name for Subscription URI param to indicate the receiver tag to be sent in SMs.
|
static String |
INITIAL_TERM_ID_PARAM_NAME
Initial term id to be used when creating an
ExclusivePublication . |
static String |
INTERFACE_PARAM_NAME
The network interface via which the socket will be routed.
|
static String |
IPC_CHANNEL
URI base used for IPC channels for
Publication s and Subscription s |
static String |
IPC_MEDIA
Media type used for IPC shared memory from
Publication to Subscription channels. |
static String |
LINGER_PARAM_NAME
Key for timeout a publication to linger after draining in nanoseconds.
|
static String |
MDC_CONTROL_MODE_DYNAMIC
Valid value for
MDC_CONTROL_MODE_PARAM_NAME when dynamic control is desired. |
static String |
MDC_CONTROL_MODE_MANUAL
Valid value for
MDC_CONTROL_MODE_PARAM_NAME when manual control is desired. |
static String |
MDC_CONTROL_MODE_PARAM_NAME
Key for the mode of control that such be used for multi-destination-cast semantics.
|
static String |
MDC_CONTROL_PARAM_NAME
The param for the control channel IP address and port for multi-destination-cast semantics.
|
static String |
MEDIA_RCV_TIMESTAMP_OFFSET_PARAM_NAME
Parameter name of the offset for the media receive timestamp to be inserted into the incoming message on a
subscription.
|
static String |
MTU_LENGTH_PARAM_NAME
MTU length parameter name for using as a channel URI param.
|
static int |
NULL_SESSION_ID
Value to represent a sessionId that is not to be used.
|
static String |
RECEIVER_WINDOW_LENGTH_PARAM_NAME
Parameter name for the congestion control's initial receiver window length.
|
static String |
REJOIN_PARAM_NAME
Parameter name for Subscription URI param to indicate if Images that go unavailable should be allowed to
rejoin after a short cooldown or not.
|
static String |
RELIABLE_STREAM_PARAM_NAME
Parameter name for channel URI param to indicate if a subscribed stream must be reliable or not.
|
static String |
RESERVED_OFFSET
Placeholder value to use in URIs to specify that a timestamp should be stored in the reserved value field.
|
static String |
SESSION_ID_PARAM_NAME
Key for the session id for a publication or restricted subscription.
|
static String |
SOCKET_RCVBUF_PARAM_NAME
Parameter name for the underlying OS socket receive buffer length.
|
static String |
SOCKET_SNDBUF_PARAM_NAME
Parameter name for the underlying OS socket send buffer length.
|
static String |
SPARSE_PARAM_NAME
Parameter name for channel URI param to indicate if term buffers should be sparse.
|
static String |
SPIES_SIMULATE_CONNECTION_PARAM_NAME
Parameter name for Publication URI param to indicate whether spy subscriptions should simulate a connection.
|
static String |
SPY_PREFIX
URI used for Spy
Subscription s whereby an outgoing unicast or multicast publication can be spied on
by IPC without receiving it again via the network. |
static String |
TAG_PREFIX
Qualifier for a value which is a tag for reference.
|
static String |
TAGS_PARAM_NAME
Key for the tags for a channel
|
static String |
TERM_ID_PARAM_NAME
Current term id to be used when creating an
ExclusivePublication . |
static String |
TERM_LENGTH_PARAM_NAME
The param name to be used for the term length as a channel URI param.
|
static String |
TERM_OFFSET_PARAM_NAME
Current term offset to be used when creating an
ExclusivePublication . |
static String |
TETHER_PARAM_NAME
Parameter name for channel URI param to indicate if a subscription should tether for local flow control.
|
static String |
TTL_PARAM_NAME
Time To Live param for a multicast datagram.
|
static String |
UDP_CHANNEL
URI base used for UDP channels for
Publication s and Subscription s |
static String |
UDP_MEDIA
Media type used for UDP sockets from
Publication to Subscription channels. |
Constructor and Description |
---|
CommonContext() |
Modifier and Type | Method and Description |
---|---|
File |
aeronDirectory()
Get the directory in which the aeron config files are stored.
|
String |
aeronDirectoryName()
Get the top level Aeron directory used for communication between the client and Media Driver, and
the location of the data buffers.
|
CommonContext |
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.
|
static long |
checkDebugTimeout(long timeout,
TimeUnit timeUnit)
Override the supplied timeout with the debug value if it has been set, and we are in debug mode.
|
CommonContext |
clone()
Perform a shallow copy of the object.
|
void |
close()
Release resources used by the CommonContext.
|
File |
cncFile()
Get the command and control file.
|
CommonContext |
conclude()
This completes initialization of the CommonContext object.
|
CommonContext |
concludeAeronDirectory()
Conclude the
aeronDirectory() so it does not need to keep being recreated. |
UnsafeBuffer |
countersMetaDataBuffer()
Get the buffer containing the counter metadata.
|
CommonContext |
countersMetaDataBuffer(UnsafeBuffer countersMetaDataBuffer)
Set the buffer containing the counter metadata.
|
UnsafeBuffer |
countersValuesBuffer()
Get the buffer containing the counters.
|
CommonContext |
countersValuesBuffer(UnsafeBuffer countersValuesBuffer)
Set the buffer containing the counters.
|
void |
deleteAeronDirectory()
Delete the current Aeron directory, throwing errors if not possible.
|
long |
driverTimeoutMs()
Get the driver timeout in milliseconds.
|
CommonContext |
driverTimeoutMs(long driverTimeoutMs)
Set the driver timeout in milliseconds
|
static AtomicBuffer |
errorLogBuffer(ByteBuffer cncByteBuffer)
Get an
AtomicBuffer which wraps the error log in the CnC file. |
static PrintStream |
fallbackLogger()
Get the current fallback logger based on the supplied property.
|
static String |
generateRandomDirName()
Convert the default Aeron directory name to be a random name for use with embedded drivers.
|
static String |
getAeronDirectoryName()
Get the default directory name to be used if
aeronDirectoryName(String) is not set. |
boolean |
isConcluded()
Has the context had the
conclude() method called. |
static boolean |
isDriverActive(File directory,
long driverTimeoutMs,
Consumer<String> logger)
Is a media driver active in the given directory?
|
boolean |
isDriverActive(long driverTimeoutMs,
Consumer<String> logger)
Is a media driver active in the current Aeron directory?
|
static boolean |
isDriverActive(long driverTimeoutMs,
Consumer<String> logger,
ByteBuffer cncByteBuffer)
Is a media driver active in the current mapped CnC buffer? If the driver is starting then it will wait for
up to the driverTimeoutMs by checking for the cncVersion being set.
|
MappedByteBuffer |
mapExistingCncFile(Consumer<String> logger)
Map the CnC file if it exists.
|
static File |
newCncFile(String aeronDirectoryName)
Create a new command and control file in the administration directory.
|
static File |
newDefaultCncFile()
Create a new command and control file in the administration directory.
|
static int |
printErrorLog(AtomicBuffer errorBuffer,
PrintStream out)
Print the contents of an error log to a
PrintStream in human-readable format. |
static boolean |
requestDriverTermination(File directory,
DirectBuffer tokenBuffer,
int tokenOffset,
int tokenLength)
Request a driver to run its termination hook.
|
int |
saveErrorLog(PrintStream out)
Read the error log to a given
PrintStream |
int |
saveErrorLog(PrintStream out,
ByteBuffer cncByteBuffer)
Read the error log to a given
PrintStream |
static void |
saveExistingErrors(File markFile,
AtomicBuffer errorBuffer,
PrintStream logger,
String errorFilePrefix)
Save the existing errors from a
MarkFile to a file in the same directory as the original MarkFile
and optionally print location of such file to the supplied PrintStream . |
static ErrorHandler |
setupErrorHandler(ErrorHandler userErrorHandler,
DistinctErrorLog errorLog)
Wrap a user ErrorHandler so that error will continue to write to the errorLog.
|
public static final String DRIVER_TIMEOUT_PROP_NAME
public static final String DEBUG_TIMEOUT_PROP_NAME
public static final long DEFAULT_DRIVER_TIMEOUT_MS
public static final long DRIVER_TIMEOUT_MS
public static final int NULL_SESSION_ID
public static final String AERON_DIR_PROP_NAME
public static final String AERON_DIR_PROP_DEFAULT
aeronDirectoryName(String)
public static final String IPC_MEDIA
Publication
to Subscription
channels.public static final String UDP_MEDIA
Publication
to Subscription
channels.public static final String IPC_CHANNEL
Publication
s and Subscription
spublic static final String UDP_CHANNEL
Publication
s and Subscription
spublic static final String SPY_PREFIX
Subscription
s whereby an outgoing unicast or multicast publication can be spied on
by IPC without receiving it again via the network.public static final String ENDPOINT_PARAM_NAME
public static final String INTERFACE_PARAM_NAME
public static final String INITIAL_TERM_ID_PARAM_NAME
ExclusivePublication
.public static final String TERM_ID_PARAM_NAME
ExclusivePublication
.public static final String TERM_OFFSET_PARAM_NAME
ExclusivePublication
.public static final String TERM_LENGTH_PARAM_NAME
public static final String MTU_LENGTH_PARAM_NAME
public static final String TTL_PARAM_NAME
public static final String MDC_CONTROL_PARAM_NAME
public static final String MDC_CONTROL_MODE_PARAM_NAME
public static final String MDC_CONTROL_MODE_MANUAL
MDC_CONTROL_MODE_PARAM_NAME
when manual control is desired.public static final String MDC_CONTROL_MODE_DYNAMIC
MDC_CONTROL_MODE_PARAM_NAME
when dynamic control is desired. Default value.public static final String SESSION_ID_PARAM_NAME
public static final String LINGER_PARAM_NAME
public static final String RELIABLE_STREAM_PARAM_NAME
public static final String TAGS_PARAM_NAME
public static final String TAG_PREFIX
public static final String SPARSE_PARAM_NAME
public static final String ALIAS_PARAM_NAME
This is a reserved application level param used to identify a particular channel for application purposes.
public static final String EOS_PARAM_NAME
public static final String TETHER_PARAM_NAME
public static final String GROUP_PARAM_NAME
When configuring a subscription for an MDC publication then should be added as this is effective multicast.
public static final String REJOIN_PARAM_NAME
public static final String CONGESTION_CONTROL_PARAM_NAME
static
and cubic
.public static final String FLOW_CONTROL_PARAM_NAME
min
, max
, and pref
.public static final String GROUP_TAG_PARAM_NAME
public static final String SPIES_SIMULATE_CONNECTION_PARAM_NAME
public static final String SOCKET_SNDBUF_PARAM_NAME
public static final String SOCKET_RCVBUF_PARAM_NAME
public static final String RECEIVER_WINDOW_LENGTH_PARAM_NAME
public static final String MEDIA_RCV_TIMESTAMP_OFFSET_PARAM_NAME
public static final String CHANNEL_RECEIVE_TIMESTAMP_OFFSET_PARAM_NAME
public static final String CHANNEL_SEND_TIMESTAMP_OFFSET_PARAM_NAME
public static final String RESERVED_OFFSET
public static final String FALLBACK_LOGGER_PROP_NAME
PrintStream
based logger when it is not possible to use the error logging
callback. Supported values are stdout, stderr, no_op (stderr is the default).public static PrintStream fallbackLogger()
public CommonContext clone()
public static String getAeronDirectoryName()
aeronDirectoryName(String)
is not set. This will take
the AERON_DIR_PROP_NAME
if set and if not then AERON_DIR_PROP_DEFAULT
.aeronDirectoryName(String)
is not set.public static String generateRandomDirName()
public CommonContext conclude()
public boolean isConcluded()
conclude()
method called.conclude()
method has been called.public CommonContext concludeAeronDirectory()
aeronDirectory()
so it does not need to keep being recreated.public String aeronDirectoryName()
public File aeronDirectory()
This is valid after a call to conclude()
or concludeAeronDirectory()
.
aeronDirectoryName()
public CommonContext aeronDirectoryName(String dirName)
dirName
- New top level Aeron directory.public static File newDefaultCncFile()
public static File newCncFile(String aeronDirectoryName)
aeronDirectoryName
- name of the aeronDirectory that containing the cnc file.public UnsafeBuffer countersMetaDataBuffer()
public CommonContext countersMetaDataBuffer(UnsafeBuffer countersMetaDataBuffer)
countersMetaDataBuffer
- The new counter metadata buffer.public UnsafeBuffer countersValuesBuffer()
public CommonContext countersValuesBuffer(UnsafeBuffer countersValuesBuffer)
countersValuesBuffer
- The new counters buffer.public File cncFile()
public CommonContext driverTimeoutMs(long driverTimeoutMs)
driverTimeoutMs
- to indicate liveness of driverpublic long driverTimeoutMs()
public static long checkDebugTimeout(long timeout, TimeUnit timeUnit)
timeout
- The timeout value currently in use.timeUnit
- The units of the timeout value. Debug timeout is specified in ns, so will be converted to this
unit.public void deleteAeronDirectory()
public MappedByteBuffer mapExistingCncFile(Consumer<String> logger)
logger
- for feedbackpublic static boolean isDriverActive(File directory, long driverTimeoutMs, Consumer<String> logger)
directory
- to checkdriverTimeoutMs
- for the driver liveness check.logger
- for feedback as liveness checked.public boolean isDriverActive(long driverTimeoutMs, Consumer<String> logger)
driverTimeoutMs
- for the driver liveness check.logger
- for feedback as liveness checked.public static boolean isDriverActive(long driverTimeoutMs, Consumer<String> logger, ByteBuffer cncByteBuffer)
driverTimeoutMs
- for the driver liveness check.logger
- for feedback as liveness checked.cncByteBuffer
- for the existing CnC file.public static boolean requestDriverTermination(File directory, DirectBuffer tokenBuffer, int tokenOffset, int tokenLength)
directory
- for the driver.tokenBuffer
- containing the optional token for the request.tokenOffset
- within the tokenBuffer at which the token begins.tokenLength
- of the token in the tokenBuffer.public int saveErrorLog(PrintStream out)
PrintStream
out
- to write the error log contents to.public int saveErrorLog(PrintStream out, ByteBuffer cncByteBuffer)
PrintStream
out
- to write the error log contents to.cncByteBuffer
- containing the error log.public void close()
public static int printErrorLog(AtomicBuffer errorBuffer, PrintStream out)
PrintStream
in human-readable format.errorBuffer
- to read errors from.out
- print the errors to.public static void saveExistingErrors(File markFile, AtomicBuffer errorBuffer, PrintStream logger, String errorFilePrefix)
MarkFile
to a file in the same directory as the original MarkFile
and optionally print location of such file to the supplied PrintStream
.markFile
- which contains the error buffer.errorBuffer
- which wraps the error log.logger
- to which the existing errors will be printed.errorFilePrefix
- to add to the generated error file.public static AtomicBuffer errorLogBuffer(ByteBuffer cncByteBuffer)
AtomicBuffer
which wraps the error log in the CnC file.cncByteBuffer
- which contains the error log.AtomicBuffer
which wraps the error log in the CnC file.public static ErrorHandler setupErrorHandler(ErrorHandler userErrorHandler, DistinctErrorLog errorLog)
userErrorHandler
- the user specified ErrorHandler, can be null.errorLog
- the configured errorLog, either the default or user supplied.Copyright © 2014-2022 Real Logic Limited. All Rights Reserved.