From 0df4eb872db3ba676c07ab051391d90caac3af8b Mon Sep 17 00:00:00 2001 From: Robinson Date: Fri, 24 Jun 2022 13:12:18 +0200 Subject: [PATCH] Added support for getting specific aeron driver information --- src/dorkbox/network/connection/EndPoint.kt | 91 ++++++++++++---------- 1 file changed, 52 insertions(+), 39 deletions(-) diff --git a/src/dorkbox/network/connection/EndPoint.kt b/src/dorkbox/network/connection/EndPoint.kt index 30b67853..c8a85d70 100644 --- a/src/dorkbox/network/connection/EndPoint.kt +++ b/src/dorkbox/network/connection/EndPoint.kt @@ -39,7 +39,6 @@ import dorkbox.network.serialization.KryoExtra import dorkbox.network.serialization.Serialization import dorkbox.network.serialization.SettingsStore import io.aeron.Publication -import io.aeron.driver.MediaDriver import io.aeron.logbuffer.Header import kotlinx.atomicfu.atomic import kotlinx.coroutines.CoroutineScope @@ -673,30 +672,35 @@ internal constructor(val type: Class<*>, } } - override fun toString(): String { - return "EndPoint [${type.simpleName}]" + /** + * Checks to see if an endpoint is running. + * + * @return true if the media driver is active and running + */ + fun isRunning(): Boolean { + return aeronDriver.isRunning() } - override fun hashCode(): Int { - val prime = 31 - var result = 1 - result = prime * result + (crypto.hashCode()) - return result + /** + * @param counterFunction callback for each of the internal counters of the Aeron driver in the current aeron directory + */ + fun driverCounters(counterFunction: (counterId: Int, counterValue: Long, typeId: Int, keyBuffer: DirectBuffer?, label: String?) -> Unit) { + aeronDriver.driverCounters(counterFunction) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - if (other == null) { - return false - } - if (javaClass != other.javaClass) { - return false - } - other as EndPoint<*> - return crypto == other.crypto + /** + * @return the internal heartbeat of the Aeron driver in the current aeron directory + */ + fun driverHeartbeatMs(): Long { + return aeronDriver.driverHeartbeatMs() + } + + /** + * @return the internal version of the Aeron driver in the current aeron directory + */ + fun driverVersion(): String { + return aeronDriver.driverVersion() } /** @@ -713,25 +717,6 @@ internal constructor(val type: Class<*>, shutdownMutex.withLock { } } - /** - * Checks to see if an endpoint (using the current configuration) is running. - * - * @return true if the media driver is active and running - */ - fun isRunning(): Boolean { - return aeronDriver.isRunning() - } - - /** - * Checks to see if an endpoint (using the specified configuration) is running. - * - * @return true if the media driver is active and running - */ - fun isRunning(context: MediaDriver.Context): Boolean { - // if the media driver is running, it will be a quick connection. Usually 100ms or so - return context.isDriverActive(1_000) { } - } - final override fun close() { if (shutdown.compareAndSet(expect = false, update = true)) { logger.info { "Shutting down..." } @@ -767,4 +752,32 @@ internal constructor(val type: Class<*>, } internal open fun close0() {} + + + override fun toString(): String { + return "EndPoint [${type.simpleName}]" + } + + override fun hashCode(): Int { + val prime = 31 + var result = 1 + result = prime * result + (crypto.hashCode()) + return result + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + if (other == null) { + return false + } + if (javaClass != other.javaClass) { + return false + } + + other as EndPoint<*> + return crypto == other.crypto + } + }