WIP connection setup

This commit is contained in:
Robinson 2021-04-27 10:27:03 +02:00
parent 1765b4e367
commit ef598b0b72

View File

@ -124,8 +124,7 @@ object AeronConfig {
.socketSndbufLength(config.sendBufferSize) .socketSndbufLength(config.sendBufferSize)
.socketRcvbufLength(config.receiveBufferSize) .socketRcvbufLength(config.receiveBufferSize)
context context.aeronDirectoryName(config.aeronDirectory!!.absolutePath)
.aeronDirectoryName(config.aeronDirectory!!.absolutePath)
if (context.ipcTermBufferLength() != io.aeron.driver.Configuration.ipcTermBufferLength()) { if (context.ipcTermBufferLength() != io.aeron.driver.Configuration.ipcTermBufferLength()) {
// default 64 megs each is HUGE // default 64 megs each is HUGE
@ -239,19 +238,22 @@ object AeronConfig {
if (!isRunning(context)) { if (!isRunning(context)) {
logger.debug("Starting Aeron Media driver in '${context.aeronDirectory()}'") logger.debug("Starting Aeron Media driver in '${context.aeronDirectory()}'")
val threadFactory = NamedThreadFactory("Thread", ThreadGroup("${type.simpleName}-AeronDriver"), true) var threadFactory: NamedThreadFactory? = null
context
.conductorThreadFactory(threadFactory)
.receiverThreadFactory(threadFactory)
.senderThreadFactory(threadFactory)
.sharedNetworkThreadFactory(threadFactory)
.sharedThreadFactory(threadFactory)
// try to start. If we start/stop too quickly, it's a problem // try to start. If we start/stop too quickly, it's a problem
var count = 10 var count = 10
while (count-- > 0) { while (count-- > 0) {
try { try {
if (threadFactory == null) {
threadFactory = NamedThreadFactory("Thread", ThreadGroup("${type.simpleName}-AeronDriver"), true)
context
.conductorThreadFactory(threadFactory)
.receiverThreadFactory(threadFactory)
.senderThreadFactory(threadFactory)
.sharedNetworkThreadFactory(threadFactory)
.sharedThreadFactory(threadFactory)
}
return MediaDriver.launch(context) return MediaDriver.launch(context)
} catch (e: Exception) { } catch (e: Exception) {
logger.warn(e) { "Unable to start the Aeron Media driver. Retrying $count more times..." } logger.warn(e) { "Unable to start the Aeron Media driver. Retrying $count more times..." }