Skip to content

Instantly share code, notes, and snippets.

/**
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.event.japi
/**
* Java API: See documentation for [[akka.event.EventBus]]
* E is the Event type
* S is the Subscriber type
* C is the Classifier type
@patriknw
patriknw / gist:3feec3899cd8c9870d7d
Created September 22, 2014 06:48
akka-data-replication performance v0.6 vs v0.5

Results of running PerformanceSpec for version 0.6 and 0.5 of akka-data-replication

== Version 0.6 ==

500 ORSet Update WriteOne took 43 ms, 11627 TPS
500 ORSet Update WriteOne took 9 ms, 55555 TPS
500 ORSet Update WriteOne took 8 ms, 62500 TPS
500 ORSet Update WriteOne took 8 ms, 62500 TPS
500 ORSet Update WriteOne took 5 ms, 100000 TPS

500 ORSet Update WriteOne took 6 ms, 83333 TPS

@patriknw
patriknw / AgentStmSample.scala
Created April 26, 2011 12:12
Agent with STM
package agent
import akka.agent.Agent
import akka.stm._
object AgentStmSample {
def transfer(from: Agent[Int], to: Agent[Int], amount: Int): Boolean = {
atomic {
if (from.get < amount) false
@patriknw
patriknw / Sample.scala
Created January 22, 2012 12:42
FaultHandling Sample
package sample
import akka.actor.Actor
import akka.actor.Props
import akka.dispatch.Await
import akka.util.duration._
import akka.util.Timeout
import akka.actor.ActorRef
import akka.actor.Terminated
import akka.actor.ActorSystem
@patriknw
patriknw / AkkaConfigBean.scala
Created February 9, 2012 09:21
Illustrates a POJO API on top of Config
package akka.config.bean
import java.util.{ List ⇒ JList }
import java.util.{ ArrayList ⇒ JArrayList }
import java.util.{ HashMap ⇒ JHashMap }
import scala.reflect.BeanProperty
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory
class AkkaConfigBean {
@patriknw
patriknw / TellThroughputPerformanceSpec2.scala
Created April 2, 2012 18:56
TellThroughputPerformanceSpec used for the 50 million msg/s test
case object Run
case object Msg
class Destination extends Actor {
def receive = {
case Msg ⇒ sender ! Msg
}
}
class Client(
@patriknw
patriknw / RouterApp.scala
Created May 21, 2012 19:07
Mailinglist question about watching routees for termination
package question
import java.io.IOException
import scala.util.Random
import akka.actor.Actor
import akka.actor.ActorRef
import akka.actor.ActorSystem
import akka.actor.OneForOneStrategy
@patriknw
patriknw / RouterPerf.scala
Created September 14, 2012 08:07
Microbenchmark of akka routers
package perf
import akka.actor.ActorSystem
import akka.actor.Actor
import akka.actor.Props
import scala.concurrent.forkjoin.ThreadLocalRandom
import akka.routing.ConsistentHashingRouter
import akka.routing.ConsistentHashingRouter.ConsistentHashableEnvelope
import scala.util.Random
import akka.routing.Broadcast
@patriknw
patriknw / ConsistentHashingRouterSpotlight.scala
Created October 3, 2012 12:16
Spotlight for ConsistentHashingRouter
import akka.routing.ConsistentHashingRouter
import akka.routing.ConsistentHashingRouter.ConsistentHashMapping
import akka.actor.Actor
import akka.pattern.ask
case class Entry(key: String, value: String)
class Cache extends Actor {
var cache = Map.empty[String, String]
@patriknw
patriknw / ClusterRouter.conf
Created October 8, 2012 12:15
Spotlight for Cluster Aware Routers
akka.actor.deployment {
/statsService/workerRouter {
router = round-robin
nr-of-instances = 100
cluster {
enabled = on
routees-path = "/user/statsWorker"
}
}
}