Only configure the media driver context to delete the dirs if this is the process that started it

This commit is contained in:
nathan 2020-09-03 15:31:52 +02:00
parent 818687c0d8
commit e99448e066

View File

@ -118,7 +118,7 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A
internal val listenerManager = ListenerManager<CONNECTION>() internal val listenerManager = ListenerManager<CONNECTION>()
internal val connections = ConnectionManager<CONNECTION>() internal val connections = ConnectionManager<CONNECTION>()
internal var mediaDriverContext: MediaDriver.Context? = null internal val mediaDriverContext: MediaDriver.Context
private var mediaDriver: MediaDriver? = null private var mediaDriver: MediaDriver? = null
private var aeron: Aeron? = null private var aeron: Aeron? = null
@ -250,8 +250,6 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A
val mDrivercontext = MediaDriver.Context() val mDrivercontext = MediaDriver.Context()
.publicationReservedSessionIdLow(RESERVED_SESSION_ID_LOW) .publicationReservedSessionIdLow(RESERVED_SESSION_ID_LOW)
.publicationReservedSessionIdHigh(RESERVED_SESSION_ID_HIGH) .publicationReservedSessionIdHigh(RESERVED_SESSION_ID_HIGH)
.dirDeleteOnStart(true)
.dirDeleteOnShutdown(true)
.conductorThreadFactory(threadFactory) .conductorThreadFactory(threadFactory)
.receiverThreadFactory(threadFactory) .receiverThreadFactory(threadFactory)
.senderThreadFactory(threadFactory) .senderThreadFactory(threadFactory)
@ -294,10 +292,15 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A
val aeronDirectory = config.aeronLogDirectory!!.absolutePath val aeronDirectory = config.aeronLogDirectory!!.absolutePath
if (!isRunning()) { if (!isRunning()) {
logger.debug { "Starting Aeron Media driver..."}
mediaDriverContext
.dirDeleteOnStart(true)
.dirDeleteOnShutdown(true)
// the server always creates a the media driver. // the server always creates a the media driver.
mediaDriver = try { try {
logger.debug { "Starting Aeron Media driver..."} mediaDriver = MediaDriver.launch(mediaDriverContext)
MediaDriver.launch(mediaDriverContext)
} catch (e: Exception) { } catch (e: Exception) {
listenerManager.notifyError(e) listenerManager.notifyError(e)
throw e throw e