Added multi-jvm test for ClusterDeployer
This commit is contained in:
parent
426b1328f2
commit
5a04095c6b
11 changed files with 99 additions and 116 deletions
|
|
@ -121,7 +121,6 @@ trait ClusterNodeMBean {
|
|||
*/
|
||||
object Cluster {
|
||||
val EMPTY_STRING = "".intern
|
||||
val UUID_PREFIX = "uuid:".intern
|
||||
|
||||
// config options
|
||||
val name = Config.clusterName
|
||||
|
|
|
|||
|
|
@ -1,70 +0,0 @@
|
|||
package akka.cluster
|
||||
|
||||
import org.scalatest.WordSpec
|
||||
import org.scalatest.matchers.MustMatchers
|
||||
import org.scalatest.{ BeforeAndAfterAll, BeforeAndAfterEach }
|
||||
|
||||
import org.I0Itec.zkclient._
|
||||
|
||||
import akka.actor._
|
||||
import Actor._
|
||||
|
||||
object ClusterDeployerSpec {
|
||||
class HelloWorld extends Actor with Serializable {
|
||||
def receive = {
|
||||
case "Hello" ⇒ self.reply("World")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ClusterDeployerSpec extends WordSpec with MustMatchers with BeforeAndAfterAll with BeforeAndAfterEach {
|
||||
import ClusterDeployerSpec._
|
||||
|
||||
val dataPath = "_akka_cluster/data"
|
||||
val logPath = "_akka_cluster/log"
|
||||
|
||||
var zkServer: ZkServer = _
|
||||
|
||||
// FIXME create multi-jvm test for ClusterDeployer to make sure that only one node can make the deployment and that all other nicely waits until he is done
|
||||
|
||||
"A ClusterDeployer" should {
|
||||
"be able to deploy deployments in akka.conf into ZooKeeper and then lookup the deployments by 'address'" in {
|
||||
val deployments = Deployer.deploymentsInConfig
|
||||
deployments must not equal (Nil)
|
||||
ClusterDeployer.init(deployments)
|
||||
|
||||
deployments map { oldDeployment ⇒
|
||||
val newDeployment = ClusterDeployer.lookupDeploymentFor(oldDeployment.address)
|
||||
newDeployment must be('defined)
|
||||
oldDeployment must equal(newDeployment.get)
|
||||
}
|
||||
}
|
||||
|
||||
"be able to fetch deployments from ZooKeeper" in {
|
||||
val deployments1 = Deployer.deploymentsInConfig
|
||||
deployments1 must not equal (Nil)
|
||||
ClusterDeployer.init(deployments1)
|
||||
|
||||
val deployments2 = ClusterDeployer.fetchDeploymentsFromCluster
|
||||
deployments2.size must equal(1)
|
||||
deployments2.head must equal(deployments1.head)
|
||||
}
|
||||
}
|
||||
|
||||
override def beforeAll() {
|
||||
try {
|
||||
zkServer = Cluster.startLocalCluster(dataPath, logPath)
|
||||
Thread.sleep(5000)
|
||||
Actor.cluster.start()
|
||||
} catch {
|
||||
case e ⇒ e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override def afterAll() {
|
||||
Actor.cluster.shutdown()
|
||||
ClusterDeployer.shutdown()
|
||||
Cluster.shutdownLocalCluster()
|
||||
Actor.registry.local.shutdownAll()
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
akka.event-handler-level = "DEBUG"
|
||||
|
|
@ -1 +0,0 @@
|
|||
-Dakka.cluster.nodename=node3 -Dakka.cluster.port=9993
|
||||
|
|
@ -91,42 +91,3 @@ class MigrationAutomaticMultiJvmNode2 extends WordSpec with MustMatchers with Be
|
|||
shutdownLocalCluster()
|
||||
}
|
||||
}
|
||||
/*
|
||||
class MigrationAutomaticMultiJvmNode3 extends WordSpec with MustMatchers {
|
||||
import MigrationAutomaticMultiJvmSpec._
|
||||
|
||||
"A cluster" must {
|
||||
|
||||
"be able to migrate an actor from one node to another" in {
|
||||
|
||||
barrier("start-node-1", NrOfNodes) {
|
||||
}
|
||||
|
||||
barrier("start-node-2", NrOfNodes) {
|
||||
node.start()
|
||||
}
|
||||
|
||||
barrier("store-1-in-node-1", NrOfNodes) {
|
||||
}
|
||||
|
||||
barrier("use-1-in-node-2", NrOfNodes) {
|
||||
val actorOrOption = node.use("hello-world")
|
||||
if (actorOrOption.isEmpty) fail("Actor could not be retrieved")
|
||||
|
||||
val actorRef = actorOrOption.get
|
||||
actorRef.address must be("hello-world")
|
||||
|
||||
(actorRef ? "Hello").as[String].get must be("World from node [node2]")
|
||||
}
|
||||
|
||||
barrier("migrate-from-node2-to-node1", NrOfNodes) {
|
||||
node.migrate(NodeAddress(node.nodeAddress.clusterName, "node1"), "hello-world")
|
||||
Thread.sleep(2000)
|
||||
}
|
||||
|
||||
barrier("check-actor-is-moved-to-node1", NrOfNodes) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
akka.event-handler-level = "DEBUG"
|
||||
akka.actor.deployment.service-hello.router = "round-robin"
|
||||
akka.actor.deployment.service-hello.clustered.home = "node:node1"
|
||||
akka.actor.deployment.service-hello.clustered.replicas = 1
|
||||
|
|
@ -0,0 +1 @@
|
|||
-Dakka.cluster.nodename=node1 -Dakka.cluster.port=9991
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
akka.event-handler-level = "DEBUG"
|
||||
akka.actor.deployment.service-hello.router = "round-robin"
|
||||
akka.actor.deployment.service-hello.clustered.home = "node:node1"
|
||||
akka.actor.deployment.service-hello.clustered.replicas = 1
|
||||
|
|
@ -0,0 +1 @@
|
|||
-Dakka.cluster.nodename=node2 -Dakka.cluster.port=9992
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2011 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package akka.cluster.deployment
|
||||
|
||||
import org.scalatest.WordSpec
|
||||
import org.scalatest.matchers.MustMatchers
|
||||
import org.scalatest.BeforeAndAfterAll
|
||||
|
||||
import akka.actor._
|
||||
import Actor._
|
||||
import akka.cluster._
|
||||
import Cluster._
|
||||
|
||||
object DeploymentMultiJvmSpec {
|
||||
var NrOfNodes = 2
|
||||
}
|
||||
|
||||
class DeploymentMultiJvmNode1 extends WordSpec with MustMatchers with BeforeAndAfterAll {
|
||||
import DeploymentMultiJvmSpec._
|
||||
|
||||
"A ClusterDeployer" must {
|
||||
|
||||
"be able to deploy deployments in akka.conf and lookup the deployments by 'address'" in {
|
||||
|
||||
barrier("start-node-1", NrOfNodes) {
|
||||
node.start()
|
||||
}
|
||||
|
||||
barrier("start-node-2", NrOfNodes) {
|
||||
}
|
||||
|
||||
barrier("perform-deployment-on-node-1", NrOfNodes) {
|
||||
Deployer.start()
|
||||
// val deployments = Deployer.deploymentsInConfig
|
||||
// deployments must not equal (Nil)
|
||||
// ClusterDeployer.init(deployments)
|
||||
}
|
||||
|
||||
barrier("lookup-deployment-node-2", NrOfNodes) {
|
||||
}
|
||||
|
||||
node.shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
override def beforeAll() = {
|
||||
startLocalCluster()
|
||||
}
|
||||
|
||||
override def afterAll() = {
|
||||
shutdownLocalCluster()
|
||||
// ClusterDeployer.shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
class DeploymentMultiJvmNode2 extends WordSpec with MustMatchers {
|
||||
import DeploymentMultiJvmSpec._
|
||||
|
||||
"A cluster" must {
|
||||
|
||||
"be able to store, read and remove custom configuration data" in {
|
||||
|
||||
barrier("start-node-1", NrOfNodes) {
|
||||
}
|
||||
|
||||
barrier("start-node-2", NrOfNodes) {
|
||||
node.start()
|
||||
}
|
||||
|
||||
barrier("perform-deployment-on-node-1", NrOfNodes) {
|
||||
}
|
||||
|
||||
barrier("lookup-deployment-node-2", NrOfNodes) {
|
||||
Deployer.start()
|
||||
val deployments = Deployer.deploymentsInConfig
|
||||
deployments map { oldDeployment ⇒
|
||||
val newDeployment = ClusterDeployer.lookupDeploymentFor(oldDeployment.address)
|
||||
newDeployment must be('defined)
|
||||
oldDeployment must equal(newDeployment.get)
|
||||
}
|
||||
}
|
||||
|
||||
node.shutdown()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,12 +4,9 @@ Benchmarks
|
|||
Scalability, Throughput and Latency benchmark
|
||||
---------------------------------------------
|
||||
|
||||
.. image:: ../images/benchmark-akka-sample-trading-throughput.png
|
||||
|
||||
Simple Trading system.
|
||||
|
||||
- `Here is the result with some graphs <https://spreadsheets.google.com/ccc?key=0AqkhZTxa6-dOdERaQnNvOEZpMDdnazRWOVNHMWIxZ0E&hl=en&authkey=CLyksoEI#gid=0>`_
|
||||
- `Here is the article <http://blog.jayway.com/2010/08/10/yet-another-akka-benchmark/>`_
|
||||
- `Here is the result with some graphs <https://github.com/patriknw/akka-sample-trading/wiki/Results>`_
|
||||
- `Here is the code <http://github.com/patriknw/akka-sample-trading>`_
|
||||
|
||||
Compares:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue