当前位置: 首页>>代码示例>>Scala>>正文


Scala MultiNodeSpec类代码示例

本文整理汇总了Scala中akka.remote.testkit.MultiNodeSpec的典型用法代码示例。如果您正苦于以下问题:Scala MultiNodeSpec类的具体用法?Scala MultiNodeSpec怎么用?Scala MultiNodeSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MultiNodeSpec类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: LeaderDowningAllOtherNodesMultiJvmSpec

//设置package包名称以及导入依赖的类
package akka.cluster

import scala.concurrent.duration._
import akka.remote.testkit.MultiNodeConfig
import akka.remote.testkit.MultiNodeSpec
import akka.testkit._
import com.typesafe.config.ConfigFactory

object LeaderDowningAllOtherNodesMultiJvmSpec extends MultiNodeConfig {
  val first = role("first")
  val second = role("second")
  val third = role("third")
  val fourth = role("fourth")
  val fifth = role("fifth")
  val sixth = role("sixth")

  commonConfig(debugConfig(on = false).withFallback(
    ConfigFactory.parseString("""
      akka.cluster.failure-detector.monitored-by-nr-of-members = 2
      akka.cluster.auto-down-unreachable-after = 1s
      """)).
    withFallback(MultiNodeClusterSpec.clusterConfig))
}

class LeaderDowningAllOtherNodesMultiJvmNode1 extends LeaderDowningAllOtherNodesSpec
class LeaderDowningAllOtherNodesMultiJvmNode2 extends LeaderDowningAllOtherNodesSpec
class LeaderDowningAllOtherNodesMultiJvmNode3 extends LeaderDowningAllOtherNodesSpec
class LeaderDowningAllOtherNodesMultiJvmNode4 extends LeaderDowningAllOtherNodesSpec
class LeaderDowningAllOtherNodesMultiJvmNode5 extends LeaderDowningAllOtherNodesSpec
class LeaderDowningAllOtherNodesMultiJvmNode6 extends LeaderDowningAllOtherNodesSpec

abstract class LeaderDowningAllOtherNodesSpec
  extends MultiNodeSpec(LeaderDowningAllOtherNodesMultiJvmSpec)
  with MultiNodeClusterSpec {

  import LeaderDowningAllOtherNodesMultiJvmSpec._
  import ClusterEvent._

  "A cluster of 6 nodes with monitored-by-nr-of-members=2" must {
    "setup" taggedAs LongRunningTest in {
      // start some
      awaitClusterUp(roles: _*)
      enterBarrier("after-1")
    }

    "remove all shutdown nodes" taggedAs LongRunningTest in {
      val others = roles.drop(1)
      val shutdownAddresses = others.map(address).toSet
      enterBarrier("before-all-other-shutdown")
      runOn(first) {
        for (node ? others)
          testConductor.exit(node, 0).await
      }
      enterBarrier("all-other-shutdown")
      awaitMembersUp(numberOfMembers = 1, canNotBePartOfMemberRing = shutdownAddresses, 30.seconds)
    }

  }
} 
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:60,代码来源:LeaderDowningAllOtherNodesSpec.scala

示例2: ClusterMetricsDisabledMultiJvmSpec

//设置package包名称以及导入依赖的类
package akka.cluster

import akka.remote.testkit.{ MultiNodeSpec, MultiNodeConfig }
import com.typesafe.config.ConfigFactory
import akka.testkit.LongRunningTest
import akka.cluster.ClusterEvent._

object ClusterMetricsDisabledMultiJvmSpec extends MultiNodeConfig {
  val first = role("first")
  val second = role("second")
  commonConfig(ConfigFactory.parseString("akka.cluster.metrics.enabled = off")
    .withFallback(MultiNodeClusterSpec.clusterConfigWithFailureDetectorPuppet))
}

class ClusterMetricsDisabledMultiJvmNode1 extends ClusterMetricsDisabledSpec
class ClusterMetricsDisabledMultiJvmNode2 extends ClusterMetricsDisabledSpec

abstract class ClusterMetricsDisabledSpec extends MultiNodeSpec(ClusterMetricsDisabledMultiJvmSpec) with MultiNodeClusterSpec {
  "Cluster metrics" must {
    "not collect metrics, not publish ClusterMetricsChanged, and not gossip metrics" taggedAs LongRunningTest in {
      awaitClusterUp(roles: _*)
      clusterView.clusterMetrics.size should be(0)
      cluster.subscribe(testActor, classOf[ClusterMetricsChanged])
      expectMsgType[CurrentClusterState]
      expectNoMsg
      clusterView.clusterMetrics.size should be(0)
      enterBarrier("after")
    }
  }
} 
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:31,代码来源:ClusterMetricsDisabledSpec.scala

示例3: JoinInProgressMultiJvmSpec

//设置package包名称以及导入依赖的类
package akka.cluster

import com.typesafe.config.ConfigFactory
import org.scalatest.BeforeAndAfter
import akka.remote.testkit.MultiNodeConfig
import akka.remote.testkit.MultiNodeSpec
import akka.testkit._
import scala.concurrent.duration._

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

  commonConfig(
    debugConfig(on = false)
      .withFallback(ConfigFactory.parseString("""
          akka.cluster {
            # simulate delay in gossip by turning it off
            gossip-interval = 300 s
            failure-detector {
              threshold = 4
              acceptable-heartbeat-pause = 1 second
            }
          }""")
        .withFallback(MultiNodeClusterSpec.clusterConfig)))
}

class JoinInProgressMultiJvmNode1 extends JoinInProgressSpec
class JoinInProgressMultiJvmNode2 extends JoinInProgressSpec

abstract class JoinInProgressSpec
  extends MultiNodeSpec(JoinInProgressMultiJvmSpec)
  with MultiNodeClusterSpec {

  import JoinInProgressMultiJvmSpec._

  "A cluster node" must {
    "send heartbeats immediately when joining to avoid false failure detection due to delayed gossip" taggedAs LongRunningTest in {

      runOn(first) {
        startClusterNode()
      }

      enterBarrier("first-started")

      runOn(second) {
        cluster.join(first)
      }

      runOn(first) {
        val until = Deadline.now + 5.seconds
        while (!until.isOverdue) {
          Thread.sleep(200)
          cluster.failureDetector.isAvailable(second) should be(true)
        }
      }

      enterBarrier("after")
    }
  }
} 
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:62,代码来源:JoinInProgressSpec.scala

示例4: LSNodeSpec

//设置package包名称以及导入依赖的类
package csw.services.location.helpers

import akka.remote.testkit.{MultiNodeSpec, MultiNodeSpecCallbacks}
import akka.testkit.ImplicitSender
import csw.services.location.commons.CswCluster
import csw.services.location.scaladsl.{LocationService, LocationServiceFactory}
import org.scalatest.{BeforeAndAfterAll, FunSuiteLike, Matchers}

abstract class LSNodeSpec[T <: NMembersAndSeed](val config: T)
    extends MultiNodeSpec(config, config.makeSystem)
    with ImplicitSender
    with MultiNodeSpecCallbacks
    with FunSuiteLike
    with Matchers
    with BeforeAndAfterAll {

  protected val cswCluster: CswCluster           = CswCluster.withSystem(system)
  protected val locationService: LocationService = LocationServiceFactory.withCluster(cswCluster)

  override def initialParticipants: Int = roles.size

  override def beforeAll(): Unit = multiNodeSpecBeforeAll()

  override def afterAll(): Unit = multiNodeSpecAfterAll()

  test("ensure that location service is up for all the nodes") {
    locationService.list.await
    enterBarrier("cluster-formed")
  }

} 
开发者ID:tmtsoftware,项目名称:csw-prod,代码行数:32,代码来源:LSNodeSpec.scala

示例5: MultiNodeSampleSpecMultiJvmNode1

//设置package包名称以及导入依赖的类
package com.github.rozyhead.kotan

import akka.actor.{Actor, Props}
import akka.remote.testkit.MultiNodeSpec
import akka.testkit.ImplicitSender

class MultiNodeSampleSpecMultiJvmNode1 extends MultiNodeSample
class MultiNodeSampleSpecMultiJvmNode2 extends MultiNodeSample

object MultiNodeSample {
  class Ponger extends Actor {
    def receive = {
      case "ping" => sender() ! "pong"
    }
  }
}

class MultiNodeSample extends MultiNodeSpec(MultiNodeSampleConfig)
  with STMultiNodeSpec with ImplicitSender {

  import MultiNodeSampleConfig._
  import MultiNodeSample._

  def initialParticipants = roles.size

  "A MultiNodeSample" must {

    "wait for all nodes to enter a barrier" in {
      enterBarrier("startup")
    }

    "send to and receive from a remote node" in {
      runOn(node1) {
        enterBarrier("deployed")
        val ponger = system.actorSelection(node(node2) / "user" / "ponger")
        ponger ! "ping"
        import scala.concurrent.duration._
        expectMsg(10.seconds, "pong")
      }

      runOn(node2) {
        system.actorOf(Props[Ponger], "ponger")
        enterBarrier("deployed")
      }

      enterBarrier("finished")
    }
  }
} 
开发者ID:rozyhead,项目名称:kotan,代码行数:50,代码来源:MultiNodeSampleSpec.scala

示例6: AbstractMultiNodeSpec

//设置package包名称以及导入依赖的类
package com.evolutiongaming.multinode.common

import java.time.LocalTime

import akka.actor.{ActorSystem, Address}
import akka.cluster.MultiNodeClusterSpec
import akka.remote.testconductor.RoleName
import akka.remote.testkit.MultiNodeSpec
import akka.testkit.ImplicitSender
import com.typesafe.config.ConfigFactory
import com.typesafe.scalalogging.LazyLogging

import scala.collection.immutable
import scala.concurrent.duration._
import scala.util.Properties

abstract class AbstractMultiNodeSpec(multiJvmConfig: CommonMultiNodeConfig)
  extends MultiNodeSpec(
    multiJvmConfig,
    config => {
      ConfigFactory.invalidateCaches()
      Properties.setProp("config.resource", s"${multiJvmConfig.configName}.conf")
      val system = ActorSystem("clusterTest", config)
      system
    }) with MultiNodeClusterSpec with ImplicitSender with LazyLogging {

  import multiJvmConfig._

  def seedNodes: immutable.IndexedSeq[Address] = Vector(first)

  override def enterBarrier(name: String*): Unit = {
    logger info  s"Entering barrier: ${name.mkString}"
    println(s"${LocalTime.now()} Entering barrier: ${name.mkString}")
    super.enterBarrier(name: _*)
    println(s"${LocalTime.now()} ENTERED BARRIER: ${name.mkString}")
  }

  def runExcluded(nodes: RoleName*)(f: => Unit): Unit = if (!isNode(nodes: _*)) f

  protected trait MultiNodeScope {
    val DefaultMultiNodeTimeout = 5.minutes
    val selfIndex = ourRoles indexOf myself
  }
} 
开发者ID:evolution-gaming,项目名称:akka-cluster-tests,代码行数:45,代码来源:AbstractMultiNodeSpec.scala


注:本文中的akka.remote.testkit.MultiNodeSpec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。