Log a warning if 'akka.remote.log-frame-size-exceeding' contains a bad value (#25284)

* Log a warning if 'akka.remote.log-frame-size-exceeding' contains a bad value

Currently, if 'akka.remote.log-frame-size-exceeding' is accidentally set
to an invalid value (e.g. 'on') the developer does not get warned but
remote communication fails with a not-very-helpful error message:

```
[INFO] [06/29/2018 15:07:41.657] [run-main-0] [akka.remote.Remoting] Starting remoting
[INFO] [06/29/2018 15:07:41.847] [run-main-0] [akka.remote.Remoting] Remoting started; listening on addresses :[akka.tcp://akkaremotenull@localhost:2553]
[INFO] [06/29/2018 15:07:41.849] [run-main-0] [akka.remote.Remoting] Remoting now listens on addresses: [akka.tcp://akkaremotenull@localhost:2553]
[WARN] [06/29/2018 15:07:41.986] [akkaremotenull-akka.remote.default-remote-dispatcher-5] [akka.tcp://akkaremotenull@localhost:2553/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Fakkaremotenull%40localhost%3A2552-0] Association with remote system [akka.tcp://akkaremotenull@localhost:2552] has failed, address is now gated for [5000] ms. Reason: [akka://akkaremotenull/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2Fakkaremotenull%40localhost%3A2552-0/endpointWriter: exception during creation] Caused by: [null]
[INFO] [06/29/2018 15:07:41.993] [akkaremotenull-akka.actor.default-dispatcher-3] [akka://akkaremotenull/deadLetters] Message [io.ino.akkaremotenull.Greeter$Greet] from Actor[akka://akkaremotenull/temp/$a] to Actor[akka://akkaremotenull/deadLetters] was not delivered. [1] dead letters encountered. If this is not an expected behavior, then [Actor[akka://akkaremotenull/deadLetters]] may have terminated unexpectedly, This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
```

This commit fixes the issue by a) printing a warning message and b)
ignoring the config setting.

* Adress review comments

Allows value 'off' for 'akka.remote.log-frame-size-exceeding' to be more
tolerant and now logs the original error message of the ConfigException
caught when parsing an invalid value:

```
[WARN] [07/05/2018 09:13:19.544] [akkaremotenull-akka.remote.default-remote-dispatcher-13] [RemoteMetricsOn(akka://akkaremotenull)] application.conf @ file:/Users/danbim/coding/akka-remote-null/target/scala-2.12/classes/application.conf: 19: Invalid value at 'akka.remote.log-frame-size-exceeding': No number in size-in-bytes value 'test'. For reference, check https://github.com/lightbend/config/blob/master/HOCON.md
```

* Check logFrameSizeExceeding against Int.MaxValue to allow JIT optimizations

* Load 'akka.remote.log-frame-size-exceeding' in RemoteSettings
This commit is contained in:
Daniel Bimschas 2018-12-03 15:59:09 +01:00 committed by Christopher Batey
parent cea5fbcbf5
commit f18a00e4d8
2 changed files with 8 additions and 4 deletions

View file

@ -26,7 +26,7 @@ private[akka] object RemoteMetricsExtension extends ExtensionId[RemoteMetrics] w
override def lookup = RemoteMetricsExtension
override def createExtension(system: ExtendedActorSystem): RemoteMetrics =
if (system.settings.config.getString("akka.remote.log-frame-size-exceeding").toLowerCase == "off")
if (RARP(system).provider.remoteSettings.LogFrameSizeExceeding.isEmpty)
new RemoteMetricsOff
else
new RemoteMetricsOn(system)
@ -56,8 +56,8 @@ private[akka] class RemoteMetricsOff extends RemoteMetrics {
*/
private[akka] class RemoteMetricsOn(system: ExtendedActorSystem) extends RemoteMetrics {
private val logFrameSizeExceeding: Int = system.settings.config.getBytes(
"akka.remote.log-frame-size-exceeding").toInt
private val logFrameSizeExceeding: Int = RARP(system).provider.remoteSettings.LogFrameSizeExceeding
.getOrElse(Int.MaxValue)
private val log = Logging(system, this.getClass)
private val maxPayloadBytes: ConcurrentHashMap[Class[_], Integer] = new ConcurrentHashMap
@ -87,4 +87,3 @@ private[akka] class RemoteMetricsOn(system: ExtendedActorSystem) extends RemoteM
check()
}
}

View file

@ -26,6 +26,11 @@ final class RemoteSettings(val config: Config) {
val LogSend: Boolean = getBoolean("akka.remote.log-sent-messages")
val LogFrameSizeExceeding: Option[Int] = {
if (config.getString("akka.remote.log-frame-size-exceeding").toLowerCase == "off") None
else Some(getInt("akka.remote.log-frame-size-exceeding"))
}
val UntrustedMode: Boolean = getBoolean("akka.remote.untrusted-mode")
val TrustedSelectionPaths: Set[String] =