public class CommonContext
extends java.lang.Object
implements java.lang.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 | Field and Description |
---|---|
static java.lang.String |
AERON_DIR_PROP_DEFAULT
The value of the top level Aeron directory unless overridden by
aeronDirectoryName(String) |
static java.lang.String |
AERON_DIR_PROP_NAME
The top level Aeron directory used for communication between a Media Driver and client.
|
static java.lang.String |
ALIAS_PARAM_NAME
Parameter name for channel URI param to indicate an alias for the given URI.
|
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 java.lang.String |
DRIVER_TIMEOUT_PROP_NAME
Property name for driver timeout after which the driver is considered inactive.
|
static java.lang.String |
ENDPOINT_PARAM_NAME
The address and port used for a UDP channel.
|
static java.lang.String |
INITIAL_TERM_ID_PARAM_NAME
Initial term id to be used when creating an
ExclusivePublication . |
static java.lang.String |
INTERFACE_PARAM_NAME
The network interface via which the socket will be routed.
|
static java.lang.String |
IPC_CHANNEL
URI used for IPC
Publication s and Subscription s |
static java.lang.String |
IPC_MEDIA
Media type used for IPC shared memory from
Publication to Subscription channels. |
static java.lang.String |
LINGER_PARAM_NAME
Key for the linger timeout for a publication to wait around after draining in nanoseconds.
|
static java.lang.String |
MDC_CONTROL_MODE_DYNAMIC
Valid value for
MDC_CONTROL_MODE_PARAM_NAME when dynamic control is desired. |
static java.lang.String |
MDC_CONTROL_MODE_MANUAL
Valid value for
MDC_CONTROL_MODE_PARAM_NAME when manual control is desired. |
static java.lang.String |
MDC_CONTROL_MODE_PARAM_NAME
Key for the mode of control that such be used for multi-destination-cast semantics.
|
static java.lang.String |
MDC_CONTROL_PARAM_NAME
The param for the control channel IP address and port for multi-destination-cast semantics.
|
static java.lang.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 java.lang.String |
RELIABLE_STREAM_PARAM_NAME
Parameter name for channel URI param to indicate if a subscribed must be reliable or not.
|
static java.lang.String |
SESSION_ID_PARAM_NAME
Key for the session id for a publication or restricted subscription.
|
static java.lang.String |
SPARSE_PARAM_NAME
Parameter name for channel URI param to indicate if term buffers should be sparse.
|
static java.lang.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 java.lang.String |
TAG_PREFIX
Qualifier for a value which is a tag for reference.
|
static java.lang.String |
TAGS_PARAM_NAME
Key for the tags for a channel
|
static java.lang.String |
TERM_ID_PARAM_NAME
Current term id to be used when creating an
ExclusivePublication . |
static java.lang.String |
TERM_LENGTH_PARAM_NAME
The param name to be used for the term length as a channel URI param.
|
static java.lang.String |
TERM_OFFSET_PARAM_NAME
Current term offset to be used when creating an
ExclusivePublication . |
static java.lang.String |
TTL_PARAM_NAME
Time To Live param for a multicast datagram.
|
static java.lang.String |
UDP_MEDIA
Media type used for UDP sockets from
Publication to Subscription channels. |
Constructor and Description |
---|
CommonContext() |
Modifier and Type | Method and Description |
---|---|
java.io.File |
aeronDirectory()
Get the directory in which the aeron config files are stored.
|
java.lang.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(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.
|
CommonContext |
clone()
Perform a shallow copy of the object.
|
void |
close()
Release resources used by the CommonContext.
|
java.io.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. |
org.agrona.concurrent.UnsafeBuffer |
countersMetaDataBuffer()
Get the buffer containing the counter meta data.
|
CommonContext |
countersMetaDataBuffer(org.agrona.concurrent.UnsafeBuffer countersMetaDataBuffer)
Set the buffer containing the counter meta data.
|
org.agrona.concurrent.UnsafeBuffer |
countersValuesBuffer()
Get the buffer containing the counters.
|
CommonContext |
countersValuesBuffer(org.agrona.concurrent.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 void |
formatError(java.io.PrintStream out,
java.text.SimpleDateFormat dateFormat,
int observationCount,
long firstObservationTimestamp,
long lastObservationTimestamp,
java.lang.String encodedException) |
static java.lang.String |
generateRandomDirName()
Convert the default Aeron directory name to be a random name for use with embedded drivers.
|
static java.lang.String |
getAeronDirectoryName()
Get the default directory name to be used if
aeronDirectoryName(String) is not set. |
static boolean |
isDriverActive(java.io.File directory,
long driverTimeoutMs,
java.util.function.Consumer<java.lang.String> logger)
Is a media driver active in the given directory?
|
boolean |
isDriverActive(long driverTimeoutMs,
java.util.function.Consumer<java.lang.String> logger)
Is a media driver active in the current Aeron directory?
|
static boolean |
isDriverActive(long driverTimeoutMs,
java.util.function.Consumer<java.lang.String> logger,
java.nio.ByteBuffer cncByteBuffer)
Is a media driver active in the current mapped CnC buffer? If the driver is mid start then it will wait for
up to the driverTimeoutMs by checking for the cncVersion being set.
|
java.nio.MappedByteBuffer |
mapExistingCncFile(java.util.function.Consumer<java.lang.String> logger)
Map the CnC file if it exists.
|
static java.io.File |
newDefaultCncFile()
Create a new command and control file in the administration directory.
|
int |
saveErrorLog(java.io.PrintStream out)
Read the error log to a given
PrintStream |
int |
saveErrorLog(java.io.PrintStream out,
java.nio.ByteBuffer cncByteBuffer)
Read the error log to a given
PrintStream |
public static final java.lang.String DRIVER_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 java.lang.String AERON_DIR_PROP_NAME
public static final java.lang.String AERON_DIR_PROP_DEFAULT
aeronDirectoryName(String)
public static final java.lang.String IPC_MEDIA
Publication
to Subscription
channels.public static final java.lang.String UDP_MEDIA
Publication
to Subscription
channels.public static final java.lang.String IPC_CHANNEL
Publication
s and Subscription
spublic static final java.lang.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 java.lang.String ENDPOINT_PARAM_NAME
public static final java.lang.String INTERFACE_PARAM_NAME
public static final java.lang.String INITIAL_TERM_ID_PARAM_NAME
ExclusivePublication
.public static final java.lang.String TERM_ID_PARAM_NAME
ExclusivePublication
.public static final java.lang.String TERM_OFFSET_PARAM_NAME
ExclusivePublication
.public static final java.lang.String TERM_LENGTH_PARAM_NAME
public static final java.lang.String MTU_LENGTH_PARAM_NAME
public static final java.lang.String TTL_PARAM_NAME
public static final java.lang.String MDC_CONTROL_PARAM_NAME
public static final java.lang.String MDC_CONTROL_MODE_PARAM_NAME
public static final java.lang.String MDC_CONTROL_MODE_MANUAL
MDC_CONTROL_MODE_PARAM_NAME
when manual control is desired.public static final java.lang.String MDC_CONTROL_MODE_DYNAMIC
MDC_CONTROL_MODE_PARAM_NAME
when dynamic control is desired. Default value.public static final java.lang.String SESSION_ID_PARAM_NAME
public static final java.lang.String LINGER_PARAM_NAME
public static final java.lang.String RELIABLE_STREAM_PARAM_NAME
public static final java.lang.String TAGS_PARAM_NAME
public static final java.lang.String TAG_PREFIX
public static final java.lang.String SPARSE_PARAM_NAME
public static final java.lang.String ALIAS_PARAM_NAME
public CommonContext clone()
clone
in class java.lang.Object
public static java.lang.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 java.lang.String generateRandomDirName()
public CommonContext conclude()
public CommonContext concludeAeronDirectory()
aeronDirectory()
so it does not need to keep being recreated.public java.lang.String aeronDirectoryName()
public java.io.File aeronDirectory()
This is valid after a call to conclude()
.
aeronDirectoryName()
public CommonContext aeronDirectoryName(java.lang.String dirName)
dirName
- New top level Aeron directory.public static java.io.File newDefaultCncFile()
public org.agrona.concurrent.UnsafeBuffer countersMetaDataBuffer()
public CommonContext countersMetaDataBuffer(org.agrona.concurrent.UnsafeBuffer countersMetaDataBuffer)
countersMetaDataBuffer
- The new counter meta data buffer.public org.agrona.concurrent.UnsafeBuffer countersValuesBuffer()
public CommonContext countersValuesBuffer(org.agrona.concurrent.UnsafeBuffer countersValuesBuffer)
countersValuesBuffer
- The new counters buffer.public java.io.File cncFile()
public CommonContext driverTimeoutMs(long driverTimeoutMs)
driverTimeoutMs
- to indicate liveness of driverpublic long driverTimeoutMs()
public void deleteAeronDirectory()
public java.nio.MappedByteBuffer mapExistingCncFile(java.util.function.Consumer<java.lang.String> logger)
logger
- for feedbackpublic static boolean isDriverActive(java.io.File directory, long driverTimeoutMs, java.util.function.Consumer<java.lang.String> logger)
directory
- to checkdriverTimeoutMs
- for the driver liveness check.logger
- for feedback as liveness checked.public boolean isDriverActive(long driverTimeoutMs, java.util.function.Consumer<java.lang.String> logger)
driverTimeoutMs
- for the driver liveness check.logger
- for feedback as liveness checked.public static boolean isDriverActive(long driverTimeoutMs, java.util.function.Consumer<java.lang.String> logger, java.nio.ByteBuffer cncByteBuffer)
driverTimeoutMs
- for the driver liveness check.logger
- for feedback as liveness checked.cncByteBuffer
- for the existing CnC file.public int saveErrorLog(java.io.PrintStream out)
PrintStream
out
- to write the error log contents to.public int saveErrorLog(java.io.PrintStream out, java.nio.ByteBuffer cncByteBuffer)
PrintStream
out
- to write the error log contents to.cncByteBuffer
- containing the error log.public void close()
public static void formatError(java.io.PrintStream out, java.text.SimpleDateFormat dateFormat, int observationCount, long firstObservationTimestamp, long lastObservationTimestamp, java.lang.String encodedException)
Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.