| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Akka/Scala example source code file (RemoteDeploymentDeathWatchSpec.scala)

This example Akka source code file (RemoteDeploymentDeathWatchSpec.scala) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Akka and Scala source code examples by using tags.

All credit for the original source code belongs to; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Akka tags/keywords

actor, akka, concurrent, failed, implicitsender, multinodeconfig, remotedeploymentdeathwatchfastmultijvmnode3, remotedeploymentdeathwatchslowmultijvmnode2, remotedeploymentdeathwatchspec, remotedeploymentnodedeathwatchfastspec, remotedeploymentnodedeathwatchslowspec, string, test, testing, time, unit

The RemoteDeploymentDeathWatchSpec.scala Akka example source code

 * Copyright (C) 2009-2014 Typesafe Inc. <>
package akka.remote

import language.postfixOps
import java.util.concurrent.TimeoutException
import scala.concurrent.duration._
import com.typesafe.config.ConfigFactory
import akka.remote.testkit.MultiNodeConfig
import akka.remote.testkit.MultiNodeSpec
import akka.remote.testkit.STMultiNodeSpec
import akka.testkit._
import akka.testkit.TestEvent._

object RemoteDeploymentDeathWatchMultiJvmSpec extends MultiNodeConfig {
  val first = role("first")
  val second = role("second")
  val third = role("third")

  commonConfig(debugConfig(on = false).withFallback(
      akka.loglevel = INFO
      akka.remote.log-remote-lifecycle-events = off

  deployOn(second, """/hello.remote = "@third@" """)

  class Hello extends Actor {
    def receive = Actor.emptyBehavior

// Several different variations of the test

class RemoteDeploymentDeathWatchFastMultiJvmNode1 extends RemoteDeploymentNodeDeathWatchFastSpec
class RemoteDeploymentDeathWatchFastMultiJvmNode2 extends RemoteDeploymentNodeDeathWatchFastSpec
class RemoteDeploymentDeathWatchFastMultiJvmNode3 extends RemoteDeploymentNodeDeathWatchFastSpec
abstract class RemoteDeploymentNodeDeathWatchFastSpec extends RemoteDeploymentDeathWatchSpec {
  override def scenario = "fast"

class RemoteDeploymentDeathWatchSlowMultiJvmNode1 extends RemoteDeploymentNodeDeathWatchSlowSpec
class RemoteDeploymentDeathWatchSlowMultiJvmNode2 extends RemoteDeploymentNodeDeathWatchSlowSpec
class RemoteDeploymentDeathWatchSlowMultiJvmNode3 extends RemoteDeploymentNodeDeathWatchSlowSpec
abstract class RemoteDeploymentNodeDeathWatchSlowSpec extends RemoteDeploymentDeathWatchSpec {
  override def scenario = "slow"
  override def sleep(): Unit = Thread.sleep(3000)

abstract class RemoteDeploymentDeathWatchSpec
  extends MultiNodeSpec(RemoteDeploymentDeathWatchMultiJvmSpec)
  with STMultiNodeSpec with ImplicitSender {

  import RemoteDeploymentDeathWatchMultiJvmSpec._

  def scenario: String
  // Possible to override to let them heartbeat for a while.
  def sleep(): Unit = ()

  override def initialParticipants = roles.size

  "An actor system that deploys actors on another node" must {

    "be able to shutdown when remote node crash" taggedAs LongRunningTest in within(20 seconds) {
      runOn(second) {
        // remote deployment to third
        val hello = system.actorOf(Props[Hello], "hello")
        hello.path.address should be(node(third).address)


        // if the remote deployed actor is not removed the system will not shutdown
        val timeout = remainingOrDefault
        try system.awaitTermination(timeout) catch {
          case _: TimeoutException ⇒
            fail("Failed to stop [%s] within [%s] \n%s".format(, timeout,

      runOn(third) {

      runOn(first) {
        testConductor.exit(third, 0).await

        // second system will be shutdown




Other Akka source code examples

Here is a short list of links related to this Akka RemoteDeploymentDeathWatchSpec.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.