Skip to content

Instantly share code, notes, and snippets.

Created October 11, 2010 12:25
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
@Typed package org.mbte.akkatest
import java.util.concurrent.TimeUnit
import java.util.concurrent.CountDownLatch
import se.scalablesolutions.akka.config.JavaConfig.AllForOne
import se.scalablesolutions.akka.config.JavaConfig.RestartStrategy
import se.scalablesolutions.akka.config.ScalaConfig.Server
class Akka {
static ActorRef actor(Function1 handler) {
UntypedActor.actorOf{{ msg -> handler(msg) }}
static ActorRef leftShift(ActorRef ref, msg) {
ref.sendOneWay msg
static Supervisor leftShift(Supervisor supervisor, ActorRef ref) { ref
static Supervisor supervisor(RestartStrategy restart, Server [] servers) {
SupervisorFactory.apply([restart.transform(), scala.collection.immutable.List.fromIterator(scala.collection.JavaConversions.asIterator(servers.toList().iterator()))]).newInstance()
def start = System.currentTimeMillis()
def supervisor = Akka.supervisor([new AllForOne(), 3, 5000])
ActorRef prev
int nMessages = 500
int nActors = 10000
CountDownLatch cdl = [nActors*nMessages]
for (i in 0..<nActors) {
prev ={ o ->
prev << o
supervisor << prev
for(i in 0..<nMessages)
prev << "Hi"
assert cdl.await(60,TimeUnit.SECONDS)
Copy link

alanland commented May 6, 2013

Is there a groovy version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment