Moved errorCodeName into the driver

This commit is contained in:
Robinson 2023-07-11 11:50:48 +02:00
parent 90830128e6
commit 2f7a365f75
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
3 changed files with 31 additions and 28 deletions

View File

@ -187,6 +187,30 @@ class AeronDriver private constructor(config: Configuration, val logger: KLogger
} }
} }
/**
* @return the error code text for the specified number
*/
internal fun errorCodeName(result: Long): String {
return when (result) {
// The publication is not connected to a subscriber, this can be an intermittent state as subscribers come and go.
Publication.NOT_CONNECTED -> "Not connected"
// The offer failed due to back pressure from the subscribers preventing further transmission.
Publication.BACK_PRESSURED -> "Back pressured"
// The action is an operation such as log rotation which is likely to have succeeded by the next retry attempt.
Publication.ADMIN_ACTION -> "Administrative action"
// The Publication has been closed and should no longer be used.
Publication.CLOSED -> "Publication is closed"
// If this happens then the publication should be closed and a new one added. To make it less likely to happen then increase the term buffer length.
Publication.MAX_POSITION_EXCEEDED -> "Maximum term position exceeded"
else -> throw IllegalStateException("Unknown error code: $result")
}
}
private fun aeronCounters(aeronLocation: File): CountersReader? { private fun aeronCounters(aeronLocation: File): CountersReader? {
val resolve = aeronLocation.resolve("cnc.dat") val resolve = aeronLocation.resolve("cnc.dat")
return if (resolve.exists()) { return if (resolve.exists()) {

View File

@ -92,29 +92,8 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
internal val lanAddress = IP.lanAddress() internal val lanAddress = IP.lanAddress()
/** const val HAS_TCP = (1 shl 1).toByte()
* @return the error code text for the specified number const val HAS_UDP = (1 shl 2).toByte()
*/
internal fun errorCodeName(result: Long): String {
return when (result) {
// The publication is not connected to a subscriber, this can be an intermittent state as subscribers come and go.
Publication.NOT_CONNECTED -> "Not connected"
// The offer failed due to back pressure from the subscribers preventing further transmission.
Publication.BACK_PRESSURED -> "Back pressured"
// The action is an operation such as log rotation which is likely to have succeeded by the next retry attempt.
Publication.ADMIN_ACTION -> "Administrative action"
// The Publication has been closed and should no longer be used.
Publication.CLOSED -> "Publication is closed"
// If this happens then the publication should be closed and a new one added. To make it less likely to happen then increase the term buffer length.
Publication.MAX_POSITION_EXCEEDED -> "Maximum term position exceeded"
else -> throw IllegalStateException("Unknown error code: $result")
}
}
} }
val logger: KLogger = KotlinLogging.logger(loggerName) val logger: KLogger = KotlinLogging.logger(loggerName)
@ -717,7 +696,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
*/ */
if (result == Publication.NOT_CONNECTED) { if (result == Publication.NOT_CONNECTED) {
if (abortEarly) { if (abortEarly) {
listenerManager.notifyError(newException("[${publication.sessionId()}] Unable to send message. (Connection in non-connected state, aborted attempt! ${errorCodeName(result)})")) listenerManager.notifyError(newException("[${publication.sessionId()}] Unable to send message. (Connection in non-connected state, aborted attempt! ${AeronDriver.errorCodeName(result)})"))
return false return false
} }
@ -732,7 +711,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
continue continue
} else if (publication.isConnected) { } else if (publication.isConnected) {
// more critical error sending the message. we shouldn't retry or anything. // more critical error sending the message. we shouldn't retry or anything.
val errorMessage = "[${publication.sessionId()}] Error sending message. (Connection in non-connected state longer than linger timeout. ${errorCodeName(result)})" val errorMessage = "[${publication.sessionId()}] Error sending message. (Connection in non-connected state longer than linger timeout. ${AeronDriver.errorCodeName(result)})"
// either client or server. No other choices. We create an exception, because it's more useful! // either client or server. No other choices. We create an exception, because it's more useful!
val exception = newException(errorMessage) val exception = newException(errorMessage)
@ -774,7 +753,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
} }
// more critical error sending the message. we shouldn't retry or anything. // more critical error sending the message. we shouldn't retry or anything.
val errorMessage = "[${publication.sessionId()}] Error sending message. (${errorCodeName(result)})" val errorMessage = "[${publication.sessionId()}] Error sending message. (${AeronDriver.errorCodeName(result)})"
// either client or server. No other choices. We create an exception, because it's more useful! // either client or server. No other choices. We create an exception, because it's more useful!
val exception = newException(errorMessage) val exception = newException(errorMessage)

View File

@ -102,7 +102,7 @@ internal class Handshaker<CONNECTION : Connection>(
// this exception will be a ClientException or a ServerException // this exception will be a ClientException or a ServerException
val exception = newException( val exception = newException(
"[$aeronLogInfo] Error sending message. (Connection in non-connected state longer than linger timeout. ${ "[$aeronLogInfo] Error sending message. (Connection in non-connected state longer than linger timeout. ${
EndPoint.errorCodeName(result) AeronDriver.errorCodeName(result)
})", })",
null null
) )
@ -135,7 +135,7 @@ internal class Handshaker<CONNECTION : Connection>(
// more critical error sending the message. we shouldn't retry or anything. // more critical error sending the message. we shouldn't retry or anything.
// this exception will be a ClientException or a ServerException // this exception will be a ClientException or a ServerException
val exception = newException("[$aeronLogInfo] Error sending handshake message. $message (${EndPoint.errorCodeName(result)})", null) val exception = newException("[$aeronLogInfo] Error sending handshake message. $message (${AeronDriver.errorCodeName(result)})", null)
exception.cleanStackTraceInternal() exception.cleanStackTraceInternal()
listenerManager.notifyError(exception) listenerManager.notifyError(exception)
throw exception throw exception