eager initialization of CoordinatedShutdown, #22191
* e.g. the jvm shutdown hook should be installed immediately * noticed that it was initialized from artery shutdown * run-by-jvm-shutdown-hook=off in multi-jvm tests
This commit is contained in:
parent
04846f4528
commit
9de19bf312
4 changed files with 12 additions and 4 deletions
|
|
@ -938,6 +938,9 @@ private[akka] class ActorSystemImpl(
|
|||
}
|
||||
}
|
||||
|
||||
// eager initialization of CoordinatedShutdown
|
||||
CoordinatedShutdown(this)
|
||||
|
||||
loadExtensions("akka.library-extensions", throwOnLoadFail = true)
|
||||
loadExtensions("akka.extensions", throwOnLoadFail = false)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ final class CoordinatedShutdown private[akka] (
|
|||
|
||||
/**
|
||||
* Scala API: Add a JVM shutdown hook that will be run when the JVM process
|
||||
* begins its shutdown sequence. Added hooks may run in an order
|
||||
* begins its shutdown sequence. Added hooks may run in any order
|
||||
* concurrently, but they are running before Akka internal shutdown
|
||||
* hooks, e.g. those shutting down Artery.
|
||||
*/
|
||||
|
|
@ -382,11 +382,16 @@ final class CoordinatedShutdown private[akka] (
|
|||
val currentLatch = _jvmHooksLatch.get
|
||||
val newLatch = new CountDownLatch(currentLatch.getCount.toInt + 1)
|
||||
if (_jvmHooksLatch.compareAndSet(currentLatch, newLatch)) {
|
||||
Runtime.getRuntime.addShutdownHook(new Thread {
|
||||
try Runtime.getRuntime.addShutdownHook(new Thread {
|
||||
override def run(): Unit = {
|
||||
try hook() finally _jvmHooksLatch.get.countDown()
|
||||
}
|
||||
})
|
||||
}) catch {
|
||||
case e: IllegalStateException ⇒
|
||||
// Shutdown in progress, if CoordinatedShutdown is created via a JVM shutdown hook (Artery)
|
||||
log.warning("Could not addJvmShutdownHook, due to: {}", e.getMessage)
|
||||
_jvmHooksLatch.get.countDown()
|
||||
}
|
||||
} else
|
||||
addJvmShutdownHook(hook) // lost CAS, retry
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ object MultiNodeSpec {
|
|||
loggers = ["akka.testkit.TestEventListener"]
|
||||
loglevel = "WARNING"
|
||||
stdout-loglevel = "WARNING"
|
||||
coordinated-shutdown.run-by-jvm-shutdown-hook = off
|
||||
actor {
|
||||
default-dispatcher {
|
||||
executor = "fork-join-executor"
|
||||
|
|
|
|||
|
|
@ -324,7 +324,6 @@ private[remote] class ArteryTransport(_system: ExtendedActorSystem, _provider: R
|
|||
*/
|
||||
private[this] val _inboundCompressions = {
|
||||
if (settings.Advanced.Compression.Enabled) {
|
||||
println(s"settings.Advanced.Compression.Enabled = ${settings.Advanced.Compression.Enabled}")
|
||||
val eventSink = createFlightRecorderEventSink(synchr = false)
|
||||
new InboundCompressionsImpl(system, this, settings.Advanced.Compression, eventSink)
|
||||
} else NoInboundCompressions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue