pekko/akka-cluster/src/test/scala/akka/cluster/sample/ComputeGridSample.scala
Jonas Bonér 4d649c3903 Removed all @author tags for Jonas Bonér since it has lost its meaning.
Signed-off-by: Jonas Bonér <jonas@jonasboner.com>
2011-12-09 18:44:59 +01:00

91 lines
2.7 KiB
Scala

/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.cluster.sample
import akka.cluster._
import akka.dispatch.Futures
object ComputeGridSample {
//sample.cluster.ComputeGridSample.fun2
// FIXME rewrite as multi-jvm test
/*
// run all
def run {
fun1
fun2
fun3
fun4
}
// Send Function0[Unit]
def fun1 = {
Cluster.startLocalCluster()
val node = Cluster newNode (NodeAddress("test", "local", port = 9991)) start
val remote1 = Cluster newNode (NodeAddress("test", "remote1", port = 9992)) start
Thread.sleep(100)
val fun = () ⇒ println("=============>>> AKKA ROCKS <<<=============")
node send (fun, 2) // send and invoke function on to two cluster nodes
node.stop
remote1.stop
Cluster.shutdownLocalCluster()
}
// Send Function0[Any]
def fun2 = {
Cluster.startLocalCluster()
val local = Cluster newNode (NodeAddress("test", "local", port = 9991)) start
val remote1 = Cluster newNode (NodeAddress("test", "remote1", port = 9992)) start
Thread.sleep(100)
val fun = () ⇒ "AKKA ROCKS"
val futures = local send (fun, 2) // send and invoke function on to two cluster nodes and get result
val result = Futures.fold("")(futures)(_ + " - " + _).await.resultOrException
println("===================>>> Cluster says [" + result + "]")
local.stop
remote1.stop
Cluster.shutdownLocalCluster()
}
// Send Function1[Any, Unit]
def fun3 = {
Cluster.startLocalCluster()
val local = Cluster newNode (NodeAddress("test", "local", port = 9991)) start
val remote1 = Cluster newNode (NodeAddress("test", "remote1", port = 9992)) start
val fun = ((s: String) ⇒ println("=============>>> " + s + " <<<=============")).asInstanceOf[Function1[Any, Unit]]
local send (fun, "AKKA ROCKS", 2) // send and invoke function on to two cluster nodes
local.stop
remote1.stop
Cluster.shutdownLocalCluster()
}
// Send Function1[Any, Any]
def fun4 = {
Cluster.startLocalCluster()
val local = Cluster newNode (NodeAddress("test", "local", port = 9991)) start
val remote1 = Cluster newNode (NodeAddress("test", "remote1", port = 9992)) start
val fun = ((i: Int) ⇒ i * i).asInstanceOf[Function1[Any, Any]]
val future1 = local send (fun, 2, 1) head // send and invoke function on one cluster node and get result
val future2 = local send (fun, 2, 1) head // send and invoke function on one cluster node and get result
// grab the result from the first one that returns
val result = Futures.firstCompletedOf(List(future1, future2)).await.resultOrException
println("===================>>> Cluster says [" + result.get + "]")
local.stop
remote1.stop
Cluster.shutdownLocalCluster()
}
*/
}