pjfanning commented on code in PR #2479:
URL: https://github.com/apache/pekko/pull/2479#discussion_r2517334108


##########
actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala:
##########
@@ -697,7 +713,56 @@ abstract class ActorSystem extends ActorRefFactory with 
ClassicActorSystemProvid
    * such as `thenRunAsync`, on the dispatchers (`Executor`) of this actor 
system as they
    * will have been shut down before this CompletionStage completes.
    */
-  def getWhenTerminated: CompletionStage[Terminated]
+  @deprecated(
+    "Use the .getWhenTerminated() function on an ActorSystem created by 
org.apache.pekko.actor.javadsl.ActorSystem.create",
+    "1.3.0")
+  def getWhenTerminated: CompletionStage[Terminated] = 
whenTerminatedImpl.asJava
+
+  /**
+   * Terminates this actor system by running [[CoordinatedShutdown]] with 
reason
+   * [[CoordinatedShutdown.ActorSystemTerminateReason]]. This method will block
+   * until either the actor system is terminated or
+   * `pekko.coordinated-shutdown.close-actor-system-timeout` timeout duration 
is
+   * passed, in which case a [[TimeoutException]] is thrown.
+   *
+   * If `pekko.coordinated-shutdown.run-by-actor-system-terminate` is 
configured to `off`
+   * it will not run `CoordinatedShutdown`, but the `ActorSystem` and its 
actors
+   * will still be terminated.
+   *
+   * This will stop the guardian actor, which in turn
+   * will recursively stop all its child actors, and finally the system 
guardian
+   * (below which the logging actors reside) and then execute all registered
+   * termination handlers (see [[ActorSystem#registerOnTermination]]).
+   * @since 1.3.0
+   */
+  @throws(classOf[TimeoutException])
+  override def close(): Unit = {
+    terminateImpl()
+    Await.ready(whenTerminatedImpl,
+      
Duration(settings.config.getDuration("coordinated-shutdown.close-actor-system-timeout").toMillis,
+        TimeUnit.MILLISECONDS))
+  }
+
+  /**
+   * Asynchronously terminates this actor system by running 
[[CoordinatedShutdown]] with reason
+   * [[CoordinatedShutdown.ActorSystemTerminateReason]]. This method will block
+   * until either the actor system is terminated or
+   * `pekko.coordinated-shutdown.close-actor-system-timeout` timeout duration 
is
+   * passed, in which case a [[TimeoutException]] is thrown.

Review Comment:
   if a TimeoutException can be thrown, why not add it as an 
`@throws(classOf[TimeoutException])`?



##########
actor/src/main/scala/org/apache/pekko/actor/javadsl/ActorSystem.scala:
##########
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * license agreements; and to You under the Apache License, version 2.0:
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * This file is part of the Apache Pekko project, which was derived from Akka.
+ */
+
+/*
+ * Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>
+ */
+
+package org.apache.pekko.actor.javadsl
+
+import java.util.concurrent.CompletionStage
+
+import scala.concurrent.ExecutionContext
+
+import com.typesafe.config.{ Config, ConfigFactory }
+
+import org.apache.pekko
+import pekko.actor.ActorSystem.findClassLoader
+import pekko.actor._
+import pekko.actor.setup.ActorSystemSetup
+import pekko.util.FutureConverters.FutureOps
+
+trait ActorSystem extends org.apache.pekko.actor.ActorSystem {
+
+  /**
+   * Asynchronously terminates this actor system by running 
[[CoordinatedShutdown]] with reason
+   * [[CoordinatedShutdown.ActorSystemTerminateReason]].
+   *
+   * If `pekko.coordinated-shutdown.run-by-actor-system-terminate` is 
configured to `off`
+   * it will not run `CoordinatedShutdown`, but the `ActorSystem` and its 
actors
+   * will still be terminated.
+   *
+   * This will stop the guardian actor, which in turn
+   * will recursively stop all its child actors, and finally the system 
guardian
+   * (below which the logging actors reside) and then execute all registered
+   * termination handlers (see [[ActorSystem.registerOnTermination]]).
+   * Be careful to not schedule any operations on completion of the returned 
future
+   * using the dispatcher of this actor system as it will have been shut down 
before the
+   * future completes.
+   */
+  def terminateAsync(): CompletionStage[Terminated] = terminateImpl().asJava
+
+  /**
+   * Returns a [[CompletionStage]] which will be completed after the 
[[ActorSystem]] has been terminated
+   * and termination hooks have been executed. If you registered any callback 
with
+   * [[ActorSystem.registerOnTermination]], the returned Future from this 
method will not complete
+   * until all the registered callbacks are finished. Be careful to not 
schedule any operations,
+   * such as `onComplete`, on the dispatchers (`ExecutionContext`) of this 
actor system as they
+   * will have been shut down before this future completes.
+   */
+  override def getWhenTerminated: CompletionStage[Terminated] = 
whenTerminatedImpl.asJava
+}
+
+object ActorSystem {
+
+  /**
+   * Creates a new ActorSystem with the name "default",
+   * obtains the current ClassLoader by first inspecting the current threads' 
getContextClassLoader,
+   * then tries to walk the stack to find the callers class loader, then falls 
back to the ClassLoader
+   * associated with the ActorSystem class.
+   * Then it loads the default reference configuration using the ClassLoader.
+   */
+  def create(): ActorSystem = create("default")
+
+  /**
+   * Creates a new ActorSystem with the specified name,
+   * obtains the current ClassLoader by first inspecting the current threads' 
getContextClassLoader,
+   * then tries to walk the stack to find the callers class loader, then falls 
back to the ClassLoader
+   * associated with the ActorSystem class.
+   * Then it loads the default reference configuration using the ClassLoader.
+   */
+  def create(name: String): ActorSystem = create(name, None, None, None)
+
+  /**
+   * Scala API: Creates a new actor system with the specified name and settings

Review Comment:
   This can't be a Scala API if it's in a Java DSL class - this appears in 
other places in this class too



##########
actor/src/main/scala/org/apache/pekko/actor/scaladsl/ActorSystem.scala:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * license agreements; and to You under the Apache License, version 2.0:
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * This file is part of the Apache Pekko project, which was derived from Akka.
+ */
+
+/*
+ * Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>
+ */
+
+package org.apache.pekko.actor.scaladsl
+
+import scala.concurrent.{ ExecutionContext, Future }
+
+import com.typesafe.config.{ Config, ConfigFactory }
+
+import org.apache.pekko
+import pekko.actor.ActorSystem.findClassLoader
+import pekko.actor._
+import pekko.actor.setup.ActorSystemSetup
+
+trait ActorSystem extends org.apache.pekko.actor.ActorSystem {
+
+  /**
+   * Asynchronously terminates this actor system by running 
[[CoordinatedShutdown]] with reason
+   * [[CoordinatedShutdown.ActorSystemTerminateReason]].
+   *
+   * If `pekko.coordinated-shutdown.run-by-actor-system-terminate` is 
configured to `off`
+   * it will not run `CoordinatedShutdown`, but the `ActorSystem` and its 
actors
+   * will still be terminated.
+   *
+   * This will stop the guardian actor, which in turn
+   * will recursively stop all its child actors, and finally the system 
guardian
+   * (below which the logging actors reside) and then execute all registered
+   * termination handlers (see [[ActorSystem.registerOnTermination]]).
+   * Be careful to not schedule any operations on completion of the returned 
future
+   * using the dispatcher of this actor system as it will have been shut down 
before the
+   * future completes.
+   */
+  def terminateAsync(): Future[Terminated] = terminateImpl()
+
+  /**
+   * Returns a [[Future]] which will be completed after the [[ActorSystem]] 
has been terminated
+   * and termination hooks have been executed. If you registered any callback 
with
+   * [[ActorSystem.registerOnTermination]], the returned Future from this 
method will not complete
+   * until all the registered callbacks are finished. Be careful to not 
schedule any operations,
+   * such as `onComplete`, on the dispatchers (`ExecutionContext`) of this 
actor system as they
+   * will have been shut down before this future completes.
+   */
+  override def whenTerminated: Future[Terminated] = whenTerminatedImpl
+}
+
+object ActorSystem {
+
+  /**
+   * Creates a new ActorSystem with the name "default",
+   * obtains the current ClassLoader by first inspecting the current threads' 
getContextClassLoader,
+   * then tries to walk the stack to find the callers class loader, then falls 
back to the ClassLoader
+   * associated with the ActorSystem class.
+   * Then it loads the default reference configuration using the ClassLoader.
+   */
+  def apply(): ActorSystem = apply("default")
+
+  /**
+   * Creates a new ActorSystem with the specified name,
+   * obtains the current ClassLoader by first inspecting the current threads' 
getContextClassLoader,
+   * then tries to walk the stack to find the callers class loader, then falls 
back to the ClassLoader
+   * associated with the ActorSystem class.
+   * Then it loads the default reference configuration using the ClassLoader.
+   */
+  def apply(name: String): ActorSystem = apply(name, None, None, None)
+
+  /**
+   * Scala API: Creates a new actor system with the specified name and settings

Review Comment:
   Why do we need 'Scala API' in the scaladoc of ScalaDSL classes? This appears 
in other methods in this class too.



##########
actor/src/main/scala/org/apache/pekko/actor/ActorSystem.scala:
##########
@@ -17,17 +17,13 @@ import java.io.Closeable
 import java.util.Optional
 import java.util.concurrent._
 import java.util.concurrent.atomic.AtomicReference
-

Review Comment:
   can we keep the whitspace separating different groups of imports?



##########
actor/src/main/resources/reference.conf:
##########
@@ -1212,6 +1212,9 @@ pekko {
     # Terminate the ActorSystem in the last phase actor-system-terminate.
     terminate-actor-system = on
 
+    # The timeout that will be used when calling .close on an ActorSystem
+    close-actor-system-timeout = 10 s

Review Comment:
   Is this long enough?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to