cleaned up logging
This commit is contained in:
parent
eaafc0f0c4
commit
9fcbabd061
|
@ -219,7 +219,13 @@ open class Client<CONNECTION : Connection>(
|
|||
* @throws ClientException if there are misc errors
|
||||
*/
|
||||
@Suppress("DuplicatedCode")
|
||||
suspend fun reconnect(connectionTimeoutSec: Int = this.connectionTimeoutSec) {
|
||||
suspend fun reconnect() {
|
||||
if (connectionTimeoutSec == 0) {
|
||||
logger.info { "Reconnecting..." }
|
||||
} else {
|
||||
logger.info { "Reconnecting... (timeout in $connectionTimeoutSec seconds)" }
|
||||
}
|
||||
|
||||
connect(
|
||||
remoteAddress = address,
|
||||
remoteAddressString = addressString,
|
||||
|
|
|
@ -234,7 +234,8 @@ open class Server<CONNECTION : Connection>(
|
|||
startDriver()
|
||||
verifyState()
|
||||
initializeState()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
catch (e: Exception) {
|
||||
resetOnError()
|
||||
listenerManager.notifyError(ServerException("Unable to start the server!", e))
|
||||
return@runBlocking
|
||||
|
@ -243,6 +244,9 @@ open class Server<CONNECTION : Connection>(
|
|||
this@Server.port1 = port1
|
||||
this@Server.port2 = port2
|
||||
|
||||
bind0()
|
||||
}
|
||||
private suspend fun bind0() {
|
||||
config as ServerConfiguration
|
||||
|
||||
// we are done with initial configuration, now initialize aeron and the general state of this endpoint
|
||||
|
|
|
@ -76,7 +76,6 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
|
|||
fun notifyError(exception: Throwable) {
|
||||
onErrorGlobalList.value.forEach {
|
||||
try {
|
||||
driverLogger.error(exception) { "Aeron error!" }
|
||||
it(exception)
|
||||
} catch (t: Throwable) {
|
||||
// NOTE: when we remove stuff, we ONLY want to remove the "tail" of the stacktrace, not ALL parts of the stacktrace
|
||||
|
@ -420,7 +419,7 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
|
|||
|
||||
if (!hasDelay) {
|
||||
hasDelay = true
|
||||
logger.debug { "Aeron Driver [$driverId]: Delaying creation of publication [$logInfo] :: sessionId=${publicationUri.sessionId()}, streamId=${streamId}" }
|
||||
logger.debug { "Aeron Driver [$driverId]: Delaying creation of ex-publication [$logInfo] :: sessionId=${publicationUri.sessionId()}, streamId=${streamId}" }
|
||||
}
|
||||
// the publication has not ACTUALLY been created yet!
|
||||
delay(50)
|
||||
|
@ -480,7 +479,6 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
|
|||
|
||||
// there was an error connecting to the aeron client or media driver.
|
||||
val ex = ClientRetryException("Aeron Driver [$driverId]: Error adding a subscription to aeron")
|
||||
ex.cleanStackTraceInternal()
|
||||
throw ex
|
||||
}
|
||||
|
||||
|
@ -554,7 +552,6 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
|
|||
val aeron1 = aeron
|
||||
if (aeron1 == null || aeron1.isClosed) {
|
||||
val e = Exception("Aeron Driver [$driverId]: Error closing $name [$logInfo] :: sessionId=${publication.sessionId()}, streamId=${publication.streamId()}")
|
||||
e.cleanStackTraceInternal()
|
||||
throw e
|
||||
}
|
||||
|
||||
|
@ -596,7 +593,6 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
|
|||
val aeron1 = aeron
|
||||
if (aeron1 == null || aeron1.isClosed) {
|
||||
val e = Exception("Aeron Driver [$driverId]: Error closing publication [$logInfo] :: sessionId=${subscription.images().firstOrNull()?.sessionId()}, streamId=${subscription.streamId()}")
|
||||
e.cleanStackTraceInternal()
|
||||
throw e
|
||||
}
|
||||
|
||||
|
@ -848,7 +844,7 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// check to make sure it's actually deleted
|
||||
if (driverDirectory.isDirectory) {
|
||||
if (endPoint != null) {
|
||||
endPoint.listenerManager.notifyError(AeronDriverException("Aeron Driver [$driverId]: Error deleting Aeron directory at: $driverDirectory"))
|
||||
|
@ -864,6 +860,8 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
|
|||
|
||||
// actually remove it, since we've passed all the checks to guarantee it's closed...
|
||||
AeronDriver.driverConfigurations.remove(driverId)
|
||||
|
||||
logger.debug { "Aeron Driver [$driverId]: Closed the media driver at '${driverDirectory}'" }
|
||||
closed = true
|
||||
|
||||
return true
|
||||
|
|
|
@ -237,7 +237,9 @@ internal class EventPoller {
|
|||
val wasRunning = running
|
||||
|
||||
running = false
|
||||
shutdownLatch.await()
|
||||
while (!shutdownLatch.await(200)) {
|
||||
logger.error { "Waiting for poller to close. It should not take this long" }
|
||||
}
|
||||
configured = false
|
||||
|
||||
if (wasRunning) {
|
||||
|
|
|
@ -295,6 +295,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
|
|||
* The client calls this every time it attempts a connection.
|
||||
*/
|
||||
internal fun initializeState() {
|
||||
// on the first run, we depend on these to be 0
|
||||
shutdownLatch = dorkbox.util.sync.CountDownLatch(1)
|
||||
pollerClosedLatch = dorkbox.util.sync.CountDownLatch(1)
|
||||
endpointIsRunning.lazySet(true)
|
||||
|
@ -561,6 +562,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
|
|||
// NOTE: This MUST be on a new co-routine (this is...)
|
||||
runBlocking {
|
||||
connection.close(false)
|
||||
logger.debug { "Received disconnect message from $otherTypeName" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue