From 120f12d739d727bbb3cba3c4f9375cd62ba6803c Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Thu, 21 Apr 2011 15:12:47 -0600 Subject: [PATCH 001/112] Adding delimited continuations to Future --- .../test/scala/akka/dispatch/FutureSpec.scala | 95 +++++++++++++++---- .../src/main/scala/akka/dispatch/Future.scala | 34 ++++--- project/build/AkkaProject.scala | 10 +- 3 files changed, 106 insertions(+), 33 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index e12294a70d..34edbb653f 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -351,34 +351,93 @@ class FutureSpec extends JUnitSuite { val latch = new StandardLatch val f = Future({ latch.await; 5}) - val f2 = Future({ f() + 5 }) + val f2 = Future({ f.get + 5 }) assert(f2.resultOrException === None) latch.open - assert(f2() === 10) + assert(f2.get === 10) val f3 = Future({ Thread.sleep(100); 5}, 10) intercept[FutureTimeoutException] { - f3() + f3.get } } - @Test def lesslessIsMore { - import akka.actor.Actor.spawn - val dataflowVar, dataflowVar2 = new DefaultCompletableFuture[Int](Long.MaxValue) - val begin, end = new StandardLatch - spawn { - begin.await - dataflowVar2 << dataflowVar - end.open + @Test def futureComposingWithContinuations { + import Future.flow + + val actor = actorOf[TestActor].start + + val x = Future("Hello") + val y = x flatMap (actor !!! _) + + val r = flow(x() + " " + y[String]() + "!") + + assert(r.get === "Hello World!") + + actor.stop + } + + @Test def futureComposingWithContinuationsFailureDivideZero { + import Future.flow + + val x = Future("Hello") + val y = x map (_.length) + + val r = flow(x() + " " + y.map(_ / 0).map(_.toString)(), 100) + + intercept[java.lang.ArithmeticException](r.get) + } + + @Test def futureComposingWithContinuationsFailureCastInt { + import Future.flow + + val actor = actorOf[TestActor].start + + val x = Future(3) + val y = actor !!! "Hello" + + val r = flow(x() + y[Int](), 100) + + intercept[ClassCastException](r.get) + } + + @Test def futureComposingWithContinuationsFailureCastNothing { + import Future.flow + + val actor = actorOf[TestActor].start + + val x = Future("Hello") + val y = actor !!! "Hello" + + val r = flow(x() + y()) + + intercept[ClassCastException](r.get) + } + + @Test def futureCompletingWithContinuations { + import Future.flow + + val x, y, z = new DefaultCompletableFuture[Int](Actor.TIMEOUT) + val ly, lz = new StandardLatch + + val result = flow { + y completeWith x + ly.open // not within continuation + + z << x + lz.open // within continuation, will wait for 'z' to complete + z() + y() } - spawn { - dataflowVar << 5 - } - begin.open - end.await - assert(dataflowVar2() === 5) - assert(dataflowVar.get === 5) + assert(ly.tryAwaitUninterruptible(100, TimeUnit.MILLISECONDS)) + assert(!lz.tryAwaitUninterruptible(100, TimeUnit.MILLISECONDS)) + + x << 5 + + assert(y.get === 5) + assert(z.get === 5) + assert(lz.isOpen) + assert(result.get === 10) } } diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index c69ca82bad..f66d1ab25b 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -10,6 +10,8 @@ import akka.actor.Actor import akka.routing.Dispatcher import akka.japi.{ Procedure, Function => JFunc } +import scala.util.continuations._ + import java.util.concurrent.locks.ReentrantLock import java.util.concurrent. {ConcurrentLinkedQueue, TimeUnit, Callable} import java.util.concurrent.TimeUnit.{NANOSECONDS => NANOS, MILLISECONDS => MILLIS} @@ -261,22 +263,30 @@ object Future { val fb = fn(a.asInstanceOf[A]) for (r <- fr; b <-fb) yield (r += b) }.map(_.result) + + def flow[A](body: => A @cpsParam[Future[Any],Future[Any]], timeout: Long = Actor.TIMEOUT): Future[A] = { + + val future = new DefaultCompletableFuture[A](timeout) + + reset(future completeWithResult body) onComplete { f => + val ex = f.exception + if (ex.isDefined) future.completeWithException(ex.get) + } + + future + } } sealed trait Future[+T] { - /** - * Returns the result of this future after waiting for it to complete, - * this method will throw any throwable that this Future was completed with - * and will throw a java.util.concurrent.TimeoutException if there is no result - * within the Futures timeout - */ - def apply(): T = this.await.resultOrException.get + def apply[A >: T](): A @cpsParam[Future[Any],Future[Any]] = shift { f: (A => Future[Any]) => + (new DefaultCompletableFuture[Any](timeoutInNanos, NANOS)) completeWith (this flatMap f) + } /** * Java API for apply() */ - def get: T = apply() + def get: T = this.await.resultOrException.get /** * Blocks the current thread until the Future has been completed or the @@ -581,10 +591,10 @@ trait CompletableFuture[T] extends Future[T] { */ final def << (value: T): Future[T] = complete(Right(value)) - /** - * Alias for completeWith(other). - */ - final def << (other : Future[T]): Future[T] = completeWith(other) + final def << (other: Future[T]): T @cpsParam[Future[Any],Future[Any]] = shift { k: (T => Future[Any]) => + this completeWith other flatMap k + } + } /** diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index 8073d8831b..db1f97ae80 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -10,7 +10,7 @@ import sbt._ import sbt.CompileOrder._ import spde._ -class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { +class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) with AutoCompilerPlugins { // ------------------------------------------------------------------------------------------------------------------- // Compile settings @@ -273,8 +273,10 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { // akka-actor subproject // ------------------------------------------------------------------------------------------------------------------- - class AkkaActorProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with OsgiProject { + class AkkaActorProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with OsgiProject with AutoCompilerPlugins { override def bndExportPackage = super.bndExportPackage ++ Seq("com.eaio.*;version=3.2") + val cont = compilerPlugin("org.scala-lang.plugins" % "continuations" % "2.9.0.RC1") + override def compileOptions = super.compileOptions ++ compileOptions("-P:continuations:enable") } // ------------------------------------------------------------------------------------------------------------------- @@ -436,11 +438,13 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { // akka-actor-tests subproject // ------------------------------------------------------------------------------------------------------------------- - class AkkaActorTestsProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + class AkkaActorTestsProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with AutoCompilerPlugins { // testing val junit = Dependencies.junit val scalatest = Dependencies.scalatest val multiverse_test = Dependencies.multiverse_test // StandardLatch + val cont = compilerPlugin("org.scala-lang.plugins" % "continuations" % "2.9.0.RC1") + override def compileOptions = super.compileOptions ++ compileOptions("-P:continuations:enable") } // ------------------------------------------------------------------------------------------------------------------- From eecfea5c5ef5d026a74bb41e51e31c73c689af1b Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sat, 23 Apr 2011 07:42:30 -0600 Subject: [PATCH 002/112] Add additional test to make sure Future.flow does not block on long running Futures --- .../test/scala/akka/dispatch/FutureSpec.scala | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 34edbb653f..a7c0590161 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -440,4 +440,24 @@ class FutureSpec extends JUnitSuite { assert(lz.isOpen) assert(result.get === 10) } + + @Test def futureContinuationsShouldNotBlock { + import Future.flow + + val latch = new StandardLatch + val future = Future { + latch.await + "Hello" + } + + val result = flow { + Some(future()).filter(_ == "Hello") + } + + assert(!result.isCompleted) + + latch.open + + assert(result.get === Some("Hello")) + } } From 62c3419f31e8b11c787a474dee2a2527bd882fbd Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sat, 23 Apr 2011 07:43:44 -0600 Subject: [PATCH 003/112] Remove redundant Future --- akka-actor/src/main/scala/akka/dispatch/Future.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index f66d1ab25b..ebf643cc01 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -279,9 +279,7 @@ object Future { sealed trait Future[+T] { - def apply[A >: T](): A @cpsParam[Future[Any],Future[Any]] = shift { f: (A => Future[Any]) => - (new DefaultCompletableFuture[Any](timeoutInNanos, NANOS)) completeWith (this flatMap f) - } + def apply[A >: T](): A @cpsParam[Future[Any],Future[Any]] = shift(this.flatMap(_)) /** * Java API for apply() From b692a8c5dd33e049895c858c0bb2667f5686e9ae Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sat, 23 Apr 2011 07:49:06 -0600 Subject: [PATCH 004/112] Use simpler annotation --- akka-actor/src/main/scala/akka/dispatch/Future.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index ebf643cc01..35ff398d54 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -264,7 +264,7 @@ object Future { for (r <- fr; b <-fb) yield (r += b) }.map(_.result) - def flow[A](body: => A @cpsParam[Future[Any],Future[Any]], timeout: Long = Actor.TIMEOUT): Future[A] = { + def flow[A](body: => A @cps[Future[Any]], timeout: Long = Actor.TIMEOUT): Future[A] = { val future = new DefaultCompletableFuture[A](timeout) @@ -279,7 +279,7 @@ object Future { sealed trait Future[+T] { - def apply[A >: T](): A @cpsParam[Future[Any],Future[Any]] = shift(this.flatMap(_)) + def apply[A >: T](): A @cps[Future[Any]] = shift(this.flatMap(_)) /** * Java API for apply() @@ -589,7 +589,7 @@ trait CompletableFuture[T] extends Future[T] { */ final def << (value: T): Future[T] = complete(Right(value)) - final def << (other: Future[T]): T @cpsParam[Future[Any],Future[Any]] = shift { k: (T => Future[Any]) => + final def << (other: Future[T]): T @cps[Future[Any]] = shift { k: (T => Future[Any]) => this completeWith other flatMap k } From 530be7b95dbe5d33b939c4bbea32d865cae093fc Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sat, 23 Apr 2011 09:14:20 -0600 Subject: [PATCH 005/112] Fix CompletableFuture.<<(other: Future) to return a Future instead of the result --- .../test/scala/akka/dispatch/FutureSpec.scala | 41 +++++++++++++++++++ .../src/main/scala/akka/dispatch/Future.scala | 16 ++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index a7c0590161..bcb1a8f8ab 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -439,6 +439,47 @@ class FutureSpec extends JUnitSuite { assert(z.get === 5) assert(lz.isOpen) assert(result.get === 10) + + val a, b, c = new DefaultCompletableFuture[Int](Actor.TIMEOUT) + + val result2 = flow { + a << (c() - 2) + val n = c() + 10 + val bb = b << a + a() + n * bb() + } + + c completeWith Future(5) + + assert(a.get === 3) + assert(b.get === 3) + assert(result2.get === 48) + } + + @Test def futureCompletingWithContinuationsFailure { + import Future.flow + + val x, y, z = new DefaultCompletableFuture[Int](Actor.TIMEOUT) + val ly, lz = new StandardLatch + + val result = flow { + y << x + ly.open + val oops = 1 / 0 + z << x + lz.open + z() + y() + oops + } + + assert(!ly.tryAwaitUninterruptible(100, TimeUnit.MILLISECONDS)) + assert(!lz.tryAwaitUninterruptible(100, TimeUnit.MILLISECONDS)) + + x << 5 + + assert(y.get === 5) + intercept[java.lang.ArithmeticException](result.get) + assert(z.value === None) + assert(!lz.isOpen) } @Test def futureContinuationsShouldNotBlock { diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 35ff398d54..f93696f925 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -279,7 +279,7 @@ object Future { sealed trait Future[+T] { - def apply[A >: T](): A @cps[Future[Any]] = shift(this.flatMap(_)) + def apply[A >: T](): A @cps[Future[Any]] = shift(this flatMap _) /** * Java API for apply() @@ -589,8 +589,18 @@ trait CompletableFuture[T] extends Future[T] { */ final def << (value: T): Future[T] = complete(Right(value)) - final def << (other: Future[T]): T @cps[Future[Any]] = shift { k: (T => Future[Any]) => - this completeWith other flatMap k + final def << (other: Future[T]): Future[T] @cps[Future[Any]] = shift { cont: (Future[T] => Future[Any]) => + val fr = new DefaultCompletableFuture[Any](Actor.TIMEOUT) + this completeWith other onComplete { f => + try { + fr completeWith cont(f) + } catch { + case e: Exception => + EventHandler.error(e, this, e.getMessage) + fr completeWithException e + } + } + fr } } From 5dfc416607c26ce24f78560fcd885ccf0bc5f9d3 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sat, 23 Apr 2011 09:21:04 -0600 Subject: [PATCH 006/112] make test more aggressive --- .../src/test/scala/akka/dispatch/FutureSpec.scala | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index bcb1a8f8ab..e88799161e 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -443,17 +443,16 @@ class FutureSpec extends JUnitSuite { val a, b, c = new DefaultCompletableFuture[Int](Actor.TIMEOUT) val result2 = flow { - a << (c() - 2) - val n = c() + 10 - val bb = b << a - a() + n * bb() + val n = (a << c).result.get + 10 + b << (c() - 2) + a() + n * b() } c completeWith Future(5) - assert(a.get === 3) + assert(a.get === 5) assert(b.get === 3) - assert(result2.get === 48) + assert(result2.get === 50) } @Test def futureCompletingWithContinuationsFailure { From 2c9a813eb61c7b6fcb331c8b54233bd10450bbd7 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sat, 23 Apr 2011 11:53:51 -0600 Subject: [PATCH 007/112] Refactor Future.flow --- .../src/main/scala/akka/dispatch/Future.scala | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index f93696f925..fc8e8ecf3f 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -264,17 +264,8 @@ object Future { for (r <- fr; b <-fb) yield (r += b) }.map(_.result) - def flow[A](body: => A @cps[Future[Any]], timeout: Long = Actor.TIMEOUT): Future[A] = { - - val future = new DefaultCompletableFuture[A](timeout) - - reset(future completeWithResult body) onComplete { f => - val ex = f.exception - if (ex.isDefined) future.completeWithException(ex.get) - } - - future - } + def flow[A](body: => A @cps[Future[A]], timeout: Long = Actor.TIMEOUT): Future[A] = + reset(new DefaultCompletableFuture[A](timeout).completeWithResult(body)) } sealed trait Future[+T] { From e74aa8f09fbda2597167f1d4e639775016ac4782 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sat, 23 Apr 2011 12:57:28 -0600 Subject: [PATCH 008/112] Add documentation to Future.flow and Future.apply --- .../src/main/scala/akka/dispatch/Future.scala | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index fc8e8ecf3f..ac2ee9bbe0 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -264,12 +264,38 @@ object Future { for (r <- fr; b <-fb) yield (r += b) }.map(_.result) + /** + * Captures a block that will be transformed into 'Continuation Passing Style' using Scala's Delimited + * Continuations plugin. + * + * Within the block, the result of a Future may be accessed by calling Future.apply. At that point + * execution is suspended with the rest of the block being stored in a continuation until the result + * of the Future is available. If an Exception is thrown while processing, it will be contained + * within the resulting Future. + * + * This allows working with Futures in an imperative style without blocking for each result. + * + * Completing a Future using 'CompletableFuture << Future' will also suspend execution until the + * value of the other Future is available. + * + * The Delimited Continuations compiler plugin must be enabled in order to use this method. + */ def flow[A](body: => A @cps[Future[A]], timeout: Long = Actor.TIMEOUT): Future[A] = reset(new DefaultCompletableFuture[A](timeout).completeWithResult(body)) } sealed trait Future[+T] { + /** + * For use only within a Future.flow block or another compatible Delimited Continuations reset block. + * + * Returns the result of this Future without blocking, by suspending execution and storing it as a + * continuation until the result is available. + * + * If this Future is untyped (a Future[Nothing]), a type parameter must be explicitly provided or + * execution will fail. The normal result of getting a Future from an ActorRef using !!! will return + * an untyped Future. + */ def apply[A >: T](): A @cps[Future[Any]] = shift(this flatMap _) /** From 7613d8e2c4eb3c83400275ab5f9330d9cee9d7c5 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sun, 24 Apr 2011 14:07:04 -0600 Subject: [PATCH 009/112] Fix continuation dependency. Building from clean project was causing errors --- project/build/AkkaProject.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index db1f97ae80..597d01f490 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -443,7 +443,6 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) with Aut val junit = Dependencies.junit val scalatest = Dependencies.scalatest val multiverse_test = Dependencies.multiverse_test // StandardLatch - val cont = compilerPlugin("org.scala-lang.plugins" % "continuations" % "2.9.0.RC1") override def compileOptions = super.compileOptions ++ compileOptions("-P:continuations:enable") } From 997151e49c7cef9ea74fb49937cf5f508d47f628 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sun, 24 Apr 2011 16:05:28 -0600 Subject: [PATCH 010/112] Improve pattern matching within for comprehensions with Future --- .../test/scala/akka/dispatch/FutureSpec.scala | 30 +++++++++---------- .../src/main/scala/akka/dispatch/Future.scala | 4 +-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index e88799161e..336a650177 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -62,9 +62,9 @@ class FutureSpec extends JUnitSuite { val future1 = actor1 !!! "Hello" flatMap ((s: String) => actor2 !!! s) val future2 = actor1 !!! "Hello" flatMap (actor2 !!! (_: String)) val future3 = actor1 !!! "Hello" flatMap (actor2 !!! (_: Int)) - assert(Some(Right("WORLD")) === future1.await.value) - assert(Some(Right("WORLD")) === future2.await.value) - intercept[ClassCastException] { future3.await.resultOrException } + assert(future1.get === "WORLD") + assert(future2.get === "WORLD") + intercept[ClassCastException] { future3.get } actor1.stop() actor2.stop() } @@ -74,8 +74,8 @@ class FutureSpec extends JUnitSuite { val actor2 = actorOf(new Actor { def receive = { case s: String => self reply s.toUpperCase } } ).start() val future1 = actor1 !!! "Hello" collect { case (s: String) => s } flatMap (actor2 !!! _) val future2 = actor1 !!! "Hello" collect { case (n: Int) => n } flatMap (actor2 !!! _) - assert(Some(Right("WORLD")) === future1.await.value) - intercept[MatchError] { future2.await.resultOrException } + assert(future1.get === "WORLD") + intercept[MatchError] { future2.get } actor1.stop() actor2.stop() } @@ -102,8 +102,8 @@ class FutureSpec extends JUnitSuite { c: String <- actor !!! 7 } yield b + "-" + c - assert(Some(Right("10-14")) === future1.await.value) - intercept[ClassCastException] { future2.await.resultOrException } + assert(future1.get === "10-14") + intercept[MatchError] { future2.get } actor.stop() } @@ -118,19 +118,19 @@ class FutureSpec extends JUnitSuite { }).start() val future1 = for { - a <- actor !!! Req("Hello") collect { case Res(x: Int) => x } - b <- actor !!! Req(a) collect { case Res(x: String) => x } - c <- actor !!! Req(7) collect { case Res(x: String) => x } + Res(a: Int) <- actor !!! Req("Hello") + Res(b: String) <- actor !!! Req(a) + Res(c: String) <- actor !!! Req(7) } yield b + "-" + c val future2 = for { - a <- actor !!! Req("Hello") collect { case Res(x: Int) => x } - b <- actor !!! Req(a) collect { case Res(x: Int) => x } - c <- actor !!! Req(7) collect { case Res(x: String) => x } + Res(a: Int) <- actor !!! Req("Hello") + Res(b: Int) <- actor !!! Req(a) + Res(c: Int) <- actor !!! Req(7) } yield b + "-" + c - assert(Some(Right("10-14")) === future1.await.value) - intercept[MatchError] { future2.await.resultOrException } + assert(future1.get === "10-14") + intercept[MatchError] { future2.get } actor.stop() } diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index ac2ee9bbe0..354832e31a 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -520,7 +520,7 @@ sealed trait Future[+T] { f(optr.get) } - final def filter(p: T => Boolean): Future[T] = { + final def filter(p: Any => Boolean): Future[Any] = { val f = new DefaultCompletableFuture[T](timeoutInNanos, NANOS) onComplete { ft => val optv = ft.value @@ -565,7 +565,7 @@ sealed trait Future[+T] { final def foreach[A >: T](proc: Procedure[A]): Unit = foreach(proc(_)) - final def filter[A >: T](p: JFunc[A,Boolean]): Future[T] = filter(p(_)) + final def filter(p: JFunc[Any,Boolean]): Future[Any] = filter(p(_)) } From da8e5064ef2ed7de03a7dfb86eae31725c8ad9a9 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Mon, 25 Apr 2011 14:55:49 -0600 Subject: [PATCH 011/112] Fix failing tests --- .../src/test/scala/akka/dispatch/FutureSpec.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 336a650177..37900a7b2e 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -62,8 +62,8 @@ class FutureSpec extends JUnitSuite { val future1 = actor1 !!! "Hello" flatMap ((s: String) => actor2 !!! s) val future2 = actor1 !!! "Hello" flatMap (actor2 !!! (_: String)) val future3 = actor1 !!! "Hello" flatMap (actor2 !!! (_: Int)) - assert(future1.get === "WORLD") - assert(future2.get === "WORLD") + assert((future1.get: Any) === "WORLD") + assert((future2.get: Any) === "WORLD") intercept[ClassCastException] { future3.get } actor1.stop() actor2.stop() @@ -74,7 +74,7 @@ class FutureSpec extends JUnitSuite { val actor2 = actorOf(new Actor { def receive = { case s: String => self reply s.toUpperCase } } ).start() val future1 = actor1 !!! "Hello" collect { case (s: String) => s } flatMap (actor2 !!! _) val future2 = actor1 !!! "Hello" collect { case (n: Int) => n } flatMap (actor2 !!! _) - assert(future1.get === "WORLD") + assert((future1.get: Any) === "WORLD") intercept[MatchError] { future2.get } actor1.stop() actor2.stop() @@ -103,7 +103,7 @@ class FutureSpec extends JUnitSuite { } yield b + "-" + c assert(future1.get === "10-14") - intercept[MatchError] { future2.get } + intercept[ClassCastException] { future2.get } actor.stop() } From 74fcef3891a70774178434178ed381748a4ef891 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Mon, 25 Apr 2011 16:14:07 -0600 Subject: [PATCH 012/112] Add Future.failure --- .../test/scala/akka/dispatch/FutureSpec.scala | 45 +++++++++++++ .../src/main/scala/akka/dispatch/Future.scala | 65 +++++++++++++------ 2 files changed, 91 insertions(+), 19 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 37900a7b2e..3ce5021441 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -134,6 +134,51 @@ class FutureSpec extends JUnitSuite { actor.stop() } + @Test def shouldMapMatchedExceptionsToResult { + val future1 = Future(5) + val future2 = future1 map (_ / 0) + val future3 = future2 map (_.toString) + + val future4 = future1 failure { + case e: ArithmeticException => 0 + } map (_.toString) + + val future5 = future2 failure { + case e: ArithmeticException => 0 + } map (_.toString) + + val future6 = future2 failure { + case e: MatchError => 0 + } map (_.toString) + + val future7 = future3 failure { case e: ArithmeticException => "You got ERROR" } + + val actor = actorOf[TestActor].start() + + val future8 = actor !!! "Failure" + val future9 = actor !!! "Failure" failure { + case e: RuntimeException => "FAIL!" + } + val future10 = actor !!! "Hello" failure { + case e: RuntimeException => "FAIL!" + } + val future11 = actor !!! "Failure" failure { case _ => "Oops!" } + + assert(future1.get === 5) + intercept[ArithmeticException] { future2.get } + intercept[ArithmeticException] { future3.get } + assert(future4.get === "5") + assert(future5.get === "0") + intercept[ArithmeticException] { future6.get } + assert(future7.get === "You got ERROR") + intercept[RuntimeException] { future8.get } + assert(future9.get === "FAIL!") + assert(future10.get === "World") + assert(future11.get === "Oops!") + + actor.stop() + } + @Test def shouldFutureAwaitEitherLeft = { val actor1 = actorOf[TestActor].start() val actor2 = actorOf[TestActor].start() diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 354832e31a..2b6f107a34 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -201,7 +201,7 @@ object Futures { // ===================================== // Deprecations // ===================================== - + /** * (Blocking!) */ @@ -421,21 +421,18 @@ sealed trait Future[+T] { final def collect[A](pf: PartialFunction[Any, A]): Future[A] = { val fa = new DefaultCompletableFuture[A](timeoutInNanos, NANOS) onComplete { ft => - val optv = ft.value - if (optv.isDefined) { - val v = optv.get - fa complete { - if (v.isLeft) v.asInstanceOf[Either[Throwable, A]] - else { - try { - val r = v.right.get - if (pf isDefinedAt r) Right(pf(r)) - else Left(new MatchError(r)) - } catch { - case e: Exception => - EventHandler.error(e, this, e.getMessage) - Left(e) - } + val v = ft.value.get + fa complete { + if (v.isLeft) v.asInstanceOf[Either[Throwable, A]] + else { + try { + val r = v.right.get + if (pf isDefinedAt r) Right(pf(r)) + else Left(new MatchError(r)) + } catch { + case e: Exception => + EventHandler.error(e, this, e.getMessage) + Left(e) } } } @@ -443,6 +440,36 @@ sealed trait Future[+T] { fa } + /** + * Creates a new Future that will handle any matching Throwable that this + * Future might contain. If there is no match, or if this Future contains + * a valid result then the new Future will contain the same. + * Example: + *
+   * Future(6 / 0) failure { case e: ArithmeticException => 0 } // result: 0
+   * Future(6 / 0) failure { case e: NotFoundException   => 0 } // result: exception
+   * Future(6 / 2) failure { case e: ArithmeticException => 0 } // result: 3
+   * 
+ */ + final def failure[A >: T](pf: PartialFunction[Throwable, A]): Future[A] = { + val fa = new DefaultCompletableFuture[A](timeoutInNanos, NANOS) + onComplete { ft => + val opte = ft.exception + fa complete { + if (opte.isDefined) { + val e = opte.get + try { + if (pf isDefinedAt e) Right(pf(e)) + else Left(e) + } catch { + case x: Exception => Left(x) + } + } else ft.value.get + } + } + fa + } + /** * Creates a new Future by applying a function to the successful result of * this Future. If this Future is completed with an exception then the new @@ -468,7 +495,7 @@ sealed trait Future[+T] { fa complete (try { Right(f(v.right.get)) } catch { - case e: Exception => + case e: Exception => EventHandler.error(e, this, e.getMessage) Left(e) }) @@ -504,7 +531,7 @@ sealed trait Future[+T] { try { fa.completeWith(f(v.right.get)) } catch { - case e: Exception => + case e: Exception => EventHandler.error(e, this, e.getMessage) fa completeWithException e } @@ -534,7 +561,7 @@ sealed trait Future[+T] { if (p(r)) Right(r) else Left(new MatchError(r)) } catch { - case e: Exception => + case e: Exception => EventHandler.error(e, this, e.getMessage) Left(e) }) From 2432101d6fc314b9fe511b78c96b8508343efac2 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 26 Apr 2011 10:49:52 +0200 Subject: [PATCH 013/112] Fixing docs for Future.get --- akka-actor/src/main/scala/akka/dispatch/Future.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 2b6f107a34..762beb8ba3 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -299,7 +299,12 @@ sealed trait Future[+T] { def apply[A >: T](): A @cps[Future[Any]] = shift(this flatMap _) /** - * Java API for apply() + * Blocks awaiting completion of this Future, then returns the resulting value, + * or throws the completed exception + * + * Scala & Java API + * + * throws FutureTimeoutException if this Future times out when waiting for completion */ def get: T = this.await.resultOrException.get From 25f2824b638bc595b6525833212360b9cc3b5d19 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 26 Apr 2011 11:17:29 +0200 Subject: [PATCH 014/112] Adding a test for the emulation of blocking --- .../test/scala/akka/dispatch/FutureSpec.scala | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 3ce5021441..9140cd236a 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -500,6 +500,39 @@ class FutureSpec extends JUnitSuite { assert(result2.get === 50) } + @Test def futureDataFlowShouldEmulateBlocking { + import Future.flow + val x1, x2, y1, y2 = new DefaultCompletableFuture[Int](1000 * 60) + val lx, ly, lz = new StandardLatch + val result = flow { + lx.open() + x1 << y1 + ly.open() + x2 << y2 + lz.open() + x1() + x2() + } + assert(lx.isOpen) + assert(!ly.isOpen) + assert(!lz.isOpen) + assert(List(x1,x2,y1,y2).forall(_.isCompleted == false)) + + y1 << 1 // When this is set, it should cascade down the line + + assert(ly.tryAwaitUninterruptible(2000, TimeUnit.MILLISECONDS)) + assert(x1.await.result.get === 1) + assert(!lz.isOpen) + + y2 << 9 // When this is set, it should cascade down the line + + assert(lz.tryAwaitUninterruptible(2000, TimeUnit.MILLISECONDS)) + assert(x2.await.result.get === 9) + + assert(List(x1,x2,y1,y2).forall(_.isCompleted == true)) + + assert(result.await.get === 10) + } + @Test def futureCompletingWithContinuationsFailure { import Future.flow From 0b5ab2112889104cd682a7af8b2feab113bef99c Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 26 Apr 2011 11:41:26 +0200 Subject: [PATCH 015/112] Adding yet another CPS test --- .../test/scala/akka/dispatch/FutureSpec.scala | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 9140cd236a..3749cc4bbd 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -500,7 +500,29 @@ class FutureSpec extends JUnitSuite { assert(result2.get === 50) } - @Test def futureDataFlowShouldEmulateBlocking { + @Test def futureDataFlowShouldEmulateBlocking1 { + import Future.flow + + val one, two = new DefaultCompletableFuture[Int](1000 * 60) + val simpleResult = flow { + one() + two() + } + + assert(List(one, two, simpleResult).forall(_.isCompleted == false)) + + one << 1 + + assert(one.isCompleted) + assert(List(two, simpleResult).forall(_.isCompleted == false)) + + two << 9 + + assert(List(one, two).forall(_.isCompleted == true)) + assert(simpleResult.await.result.get === 10) + + } + + @Test def futureDataFlowShouldEmulateBlocking2 { import Future.flow val x1, x2, y1, y2 = new DefaultCompletableFuture[Int](1000 * 60) val lx, ly, lz = new StandardLatch From d567a088499acfa0369b64509bc2919f585eaf8f Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 26 Apr 2011 13:37:06 +0200 Subject: [PATCH 016/112] =?UTF-8?q?Added=20a=20test=20to=20validate=20the?= =?UTF-8?q?=20API,=20it=C2=B4s=20gorgeous?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/scala/akka/dispatch/FutureSpec.scala | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 3749cc4bbd..03232aac13 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -518,7 +518,7 @@ class FutureSpec extends JUnitSuite { two << 9 assert(List(one, two).forall(_.isCompleted == true)) - assert(simpleResult.await.result.get === 10) + assert(simpleResult.get === 10) } @@ -542,17 +542,30 @@ class FutureSpec extends JUnitSuite { y1 << 1 // When this is set, it should cascade down the line assert(ly.tryAwaitUninterruptible(2000, TimeUnit.MILLISECONDS)) - assert(x1.await.result.get === 1) + assert(x1.get === 1) assert(!lz.isOpen) y2 << 9 // When this is set, it should cascade down the line assert(lz.tryAwaitUninterruptible(2000, TimeUnit.MILLISECONDS)) - assert(x2.await.result.get === 9) + assert(x2.get === 9) assert(List(x1,x2,y1,y2).forall(_.isCompleted == true)) - assert(result.await.get === 10) + assert(result.get === 10) + } + + @Test def dataFlowAPIshouldbeSlick { + import Future.flow + + def callService1 = Future { 1 } + def callService2 = Future { 9 } + + val result = flow { + callService1() + callService2() + } + + assert(result.get === 10) } @Test def futureCompletingWithContinuationsFailure { From 0fbf8d3c652fee1b949b44d612453f8ea7bce033 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 26 Apr 2011 13:37:06 +0200 Subject: [PATCH 017/112] =?UTF-8?q?Added=20a=20test=20to=20validate=20the?= =?UTF-8?q?=20API,=20it=C2=B4s=20gorgeous?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/scala/akka/dispatch/FutureSpec.scala | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 3749cc4bbd..bbbb187dbb 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -518,7 +518,7 @@ class FutureSpec extends JUnitSuite { two << 9 assert(List(one, two).forall(_.isCompleted == true)) - assert(simpleResult.await.result.get === 10) + assert(simpleResult.get === 10) } @@ -542,17 +542,36 @@ class FutureSpec extends JUnitSuite { y1 << 1 // When this is set, it should cascade down the line assert(ly.tryAwaitUninterruptible(2000, TimeUnit.MILLISECONDS)) - assert(x1.await.result.get === 1) + assert(x1.get === 1) assert(!lz.isOpen) y2 << 9 // When this is set, it should cascade down the line assert(lz.tryAwaitUninterruptible(2000, TimeUnit.MILLISECONDS)) - assert(x2.await.result.get === 9) + assert(x2.get === 9) assert(List(x1,x2,y1,y2).forall(_.isCompleted == true)) - assert(result.await.get === 10) + assert(result.get === 10) + } + + @Test def dataFlowAPIshouldbeSlick { + import Future.flow + val s1, s2 = new StandardLatch + + def callService1 = Future { s1.awaitUninterruptible; 1 } + def callService2 = Future { s2.awaitUninterruptible; 9 } + + val result = flow { + callService1() + callService2() + } + + assert(!s1.isOpen) + assert(!s2.isOpen) + assert(!result.isCompleted) + s1.open + s2.open + assert(result.get === 10) } @Test def futureCompletingWithContinuationsFailure { From c60f46813d6d3f0b8f52062d5f9a73dc0024366e Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 26 Apr 2011 17:19:07 +0200 Subject: [PATCH 018/112] Removing some boiler in Future --- .../src/main/scala/akka/dispatch/Future.scala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 2b3fc6425d..863d9c1283 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -616,6 +616,9 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com private var _value: Option[Either[Throwable, T]] = None private var _listeners: List[Future[T] => Unit] = Nil + /** + * Must be called inside _lock.lock<->_lock.unlock + */ @tailrec private def awaitUnsafe(wait: Long): Boolean = { if (_value.isEmpty && wait > 0) { @@ -635,7 +638,7 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com def awaitValue: Option[Either[Throwable, T]] = { _lock.lock try { - awaitUnsafe(timeoutInNanos - (currentTimeInNanos - _startTimeInNanos)) + awaitUnsafe(timeLeft()) _value } finally { _lock.unlock @@ -645,7 +648,7 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com def valueWithin(time: Long, unit: TimeUnit): Option[Either[Throwable, T]] = { _lock.lock try { - awaitUnsafe(unit.toNanos(time).min(timeoutInNanos - (currentTimeInNanos - _startTimeInNanos))) + awaitUnsafe(unit toNanos time min timeLeft()) _value } finally { _lock.unlock @@ -654,7 +657,7 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com def await = { _lock.lock - if (try { awaitUnsafe(timeoutInNanos - (currentTimeInNanos - _startTimeInNanos)) } finally { _lock.unlock }) this + if (try { awaitUnsafe(timeLeft()) } finally { _lock.unlock }) this else throw new FutureTimeoutException("Futures timed out after [" + NANOS.toMillis(timeoutInNanos) + "] milliseconds") } @@ -670,7 +673,7 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com } } - def isExpired: Boolean = timeoutInNanos - (currentTimeInNanos - _startTimeInNanos) <= 0 + def isExpired: Boolean = timeLeft() <= 0 def value: Option[Either[Throwable, T]] = { _lock.lock @@ -725,7 +728,8 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com } } - private def currentTimeInNanos: Long = MILLIS.toNanos(System.currentTimeMillis) + @inline private def currentTimeInNanos: Long = MILLIS.toNanos(System.currentTimeMillis) + @inline private def timeLeft(): Long = timeoutInNanos - (currentTimeInNanos - _startTimeInNanos) } /** From d0447c76cb4568eccc5762cd9ebc517bdae66596 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 20:16:31 +0200 Subject: [PATCH 019/112] Minor, added import --- akka-docs/pending/untyped-actors-java.rst | 3 +++ akka-docs/scala/actors.rst | 3 +++ 2 files changed, 6 insertions(+) diff --git a/akka-docs/pending/untyped-actors-java.rst b/akka-docs/pending/untyped-actors-java.rst index 35e97011af..539f0a86a6 100644 --- a/akka-docs/pending/untyped-actors-java.rst +++ b/akka-docs/pending/untyped-actors-java.rst @@ -16,6 +16,9 @@ Here is an example: .. code-block:: java + import akka.actor.UntypedActor; + import akka.event.EventHandler; + public class SampleUntypedActor extends UntypedActor { public void onReceive(Object message) throws Exception { diff --git a/akka-docs/scala/actors.rst b/akka-docs/scala/actors.rst index 2da7f2d57b..62db0ad619 100644 --- a/akka-docs/scala/actors.rst +++ b/akka-docs/scala/actors.rst @@ -26,6 +26,9 @@ Here is an example: .. code-block:: scala + import akka.actor.Actor + import akka.event.EventHandler + class MyActor extends Actor { def receive = { case "test" => EventHandler.info(this, "received test") From bce7d176f419cad9e8cdc1bb6b58edebaed786af Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 20:31:08 +0200 Subject: [PATCH 020/112] Added parens to override of preStart and postStop --- .../src/test/scala/akka/actor/actor/Bench.scala | 2 +- .../scala/akka/actor/supervisor/RestartStrategySpec.scala | 8 ++++---- .../test/scala/akka/actor/supervisor/Ticket669Spec.scala | 2 +- akka-actor/src/main/scala/akka/actor/UntypedActor.scala | 4 ++-- akka-actor/src/main/scala/akka/routing/Pool.scala | 2 +- akka-docs/intro/examples/Pi.scala | 4 ++-- akka-docs/intro/getting-started-first-scala-eclipse.rst | 4 ++-- akka-docs/intro/getting-started-first-scala.rst | 8 ++++---- akka-docs/pending/fault-tolerance-scala.rst | 2 +- akka-docs/pending/http.rst | 4 ++-- akka-docs/pending/tutorial-chat-server-scala.rst | 4 ++-- akka-docs/scala/actors.rst | 4 ++-- akka-http/src/main/scala/akka/http/Mist.scala | 2 +- .../remote/ServerInitiatedRemoteSessionActorSpec.scala | 4 ++-- .../akka-sample-chat/src/main/scala/ChatServer.scala | 4 ++-- .../akka-tutorial-first/src/main/scala/Pi.scala | 4 ++-- .../akka-tutorial-second/src/main/scala/Pi.scala | 2 +- .../src/main/scala/akka/actor/TypedActor.scala | 8 ++++---- 18 files changed, 36 insertions(+), 36 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/actor/actor/Bench.scala b/akka-actor-tests/src/test/scala/akka/actor/actor/Bench.scala index f018de635c..1f121babd5 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/actor/Bench.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/actor/Bench.scala @@ -78,7 +78,7 @@ object Chameneos { var sumMeetings = 0 var numFaded = 0 - override def preStart = { + override def preStart() = { for (i <- 0 until numChameneos) actorOf(new Chameneo(self, colours(i % 3), i)) } diff --git a/akka-actor-tests/src/test/scala/akka/actor/supervisor/RestartStrategySpec.scala b/akka-actor-tests/src/test/scala/akka/actor/supervisor/RestartStrategySpec.scala index f2a3103d08..c2af94ba1a 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/supervisor/RestartStrategySpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/supervisor/RestartStrategySpec.scala @@ -46,7 +46,7 @@ class RestartStrategySpec extends JUnitSuite { secondRestartLatch.open } - override def postStop = { + override def postStop() = { stopLatch.open } }) @@ -131,7 +131,7 @@ class RestartStrategySpec extends JUnitSuite { thirdRestartLatch.open } - override def postStop = { + override def postStop() = { if (restartLatch.isOpen) { secondRestartLatch.open } @@ -189,7 +189,7 @@ class RestartStrategySpec extends JUnitSuite { secondRestartLatch.open } - override def postStop = { + override def postStop() = { stopLatch.open } }) @@ -243,7 +243,7 @@ class RestartStrategySpec extends JUnitSuite { restartLatch.open } - override def postStop = { + override def postStop() = { stopLatch.open } }) diff --git a/akka-actor-tests/src/test/scala/akka/actor/supervisor/Ticket669Spec.scala b/akka-actor-tests/src/test/scala/akka/actor/supervisor/Ticket669Spec.scala index 206d06d1c4..33f7a72434 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/supervisor/Ticket669Spec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/supervisor/Ticket669Spec.scala @@ -65,7 +65,7 @@ object Ticket669Spec { self.reply_?("failure1") } - override def postStop { + override def postStop() { self.reply_?("failure2") } } diff --git a/akka-actor/src/main/scala/akka/actor/UntypedActor.scala b/akka-actor/src/main/scala/akka/actor/UntypedActor.scala index 41bf7ac048..71904288ef 100644 --- a/akka-actor/src/main/scala/akka/actor/UntypedActor.scala +++ b/akka-actor/src/main/scala/akka/actor/UntypedActor.scala @@ -88,14 +88,14 @@ abstract class UntypedActor extends Actor { *

* Is called when an Actor is started by invoking 'actor.start()'. */ - override def preStart {} + override def preStart() {} /** * User overridable callback. *

* Is called when 'actor.stop()' is invoked. */ - override def postStop {} + override def postStop() {} /** * User overridable callback. diff --git a/akka-actor/src/main/scala/akka/routing/Pool.scala b/akka-actor/src/main/scala/akka/routing/Pool.scala index 6ab6aa0c4d..5a906df851 100644 --- a/akka-actor/src/main/scala/akka/routing/Pool.scala +++ b/akka-actor/src/main/scala/akka/routing/Pool.scala @@ -54,7 +54,7 @@ trait DefaultActorPool extends ActorPool { this: Actor => private var _lastCapacityChange = 0 private var _lastSelectorCount = 0 - override def postStop = _delegates foreach { + override def postStop() = _delegates foreach { delegate => try { delegate ! PoisonPill } catch { case e: Exception => } //Ignore any exceptions here diff --git a/akka-docs/intro/examples/Pi.scala b/akka-docs/intro/examples/Pi.scala index 1635229802..41f8e88b9f 100644 --- a/akka-docs/intro/examples/Pi.scala +++ b/akka-docs/intro/examples/Pi.scala @@ -91,11 +91,11 @@ object Pi extends App { } //#master-receive - override def preStart { + override def preStart() { start = now } - override def postStop { + override def postStop() { // tell the world that the calculation is complete println( "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis" diff --git a/akka-docs/intro/getting-started-first-scala-eclipse.rst b/akka-docs/intro/getting-started-first-scala-eclipse.rst index ebd0064620..5c3987866a 100644 --- a/akka-docs/intro/getting-started-first-scala-eclipse.rst +++ b/akka-docs/intro/getting-started-first-scala-eclipse.rst @@ -307,11 +307,11 @@ Here is the master actor:: def receive = { ... } - override def preStart { + override def preStart() { start = System.currentTimeMillis } - override def postStop { + override def postStop() { // tell the world that the calculation is complete println( "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis" diff --git a/akka-docs/intro/getting-started-first-scala.rst b/akka-docs/intro/getting-started-first-scala.rst index c6ea2f4fe1..364c0d276b 100644 --- a/akka-docs/intro/getting-started-first-scala.rst +++ b/akka-docs/intro/getting-started-first-scala.rst @@ -291,11 +291,11 @@ Here is the master actor:: def receive = { ... } - override def preStart { + override def preStart() { start = System.currentTimeMillis } - override def postStop { + override def postStop() { // tell the world that the calculation is complete println( "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis" @@ -451,11 +451,11 @@ But before we package it up and run it, let's take a look at the full code now, if (nrOfResults == nrOfMessages) self.stop() } - override def preStart { + override def preStart() { start = System.currentTimeMillis } - override def postStop { + override def postStop() { // tell the world that the calculation is complete println( "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis" diff --git a/akka-docs/pending/fault-tolerance-scala.rst b/akka-docs/pending/fault-tolerance-scala.rst index 6070f9e01e..84cc48d549 100644 --- a/akka-docs/pending/fault-tolerance-scala.rst +++ b/akka-docs/pending/fault-tolerance-scala.rst @@ -316,7 +316,7 @@ Supervised actors have the option to reply to the initial sender within preResta self.reply_?(reason.getMessage) } - override def postStop { + override def postStop() { self.reply_?("stopped by supervisor") } } diff --git a/akka-docs/pending/http.rst b/akka-docs/pending/http.rst index 801b786da0..9de34d05e7 100644 --- a/akka-docs/pending/http.rst +++ b/akka-docs/pending/http.rst @@ -269,7 +269,7 @@ Finally, bind the *handleHttpRequest* function of the *Endpoint* trait to the ac // // this is where you want attach your endpoint hooks // - override def preStart = { + override def preStart() = { // // we expect there to be one root and that it's already been started up // obviously there are plenty of other ways to obtaining this actor @@ -397,7 +397,7 @@ As noted above, hook functions are non-exclusive. This means multiple actors can // // this is where you want attach your endpoint hooks // - override def preStart = { + override def preStart() = { // // we expect there to be one root and that it's already been started up // obviously there are plenty of other ways to obtaining this actor diff --git a/akka-docs/pending/tutorial-chat-server-scala.rst b/akka-docs/pending/tutorial-chat-server-scala.rst index 830bf75c22..afec3e948f 100644 --- a/akka-docs/pending/tutorial-chat-server-scala.rst +++ b/akka-docs/pending/tutorial-chat-server-scala.rst @@ -221,7 +221,7 @@ I'll try to show you how we can make use Scala's mixins to decouple the Actor im protected def sessionManagement: Receive protected def shutdownSessions(): Unit - override def postStop = { + override def postStop() = { EventHandler.info(this, "Chat server is shutting down...") shutdownSessions self.unlink(storage) @@ -422,7 +422,7 @@ We have now created the full functionality for the chat server, all nicely decou SessionManagement with ChatManagement with MemoryChatStorageFactory { - override def preStart = { + override def preStart() = { remote.start("localhost", 2552); remote.register("chat:service", self) //Register the actor with the specified service id } diff --git a/akka-docs/scala/actors.rst b/akka-docs/scala/actors.rst index 62db0ad619..a3e0bbd28f 100644 --- a/akka-docs/scala/actors.rst +++ b/akka-docs/scala/actors.rst @@ -385,7 +385,7 @@ When you start the ``Actor`` then it will automatically call the ``def preStart` .. code-block:: scala - override def preStart = { + override def preStart() = { ... // initialization code } @@ -402,7 +402,7 @@ When stop is called then a call to the ``def postStop`` callback method will tak .. code-block:: scala - override def postStop = { + override def postStop() = { ... // clean up resources } diff --git a/akka-http/src/main/scala/akka/http/Mist.scala b/akka-http/src/main/scala/akka/http/Mist.scala index 379cbfb36d..99e717281a 100644 --- a/akka-http/src/main/scala/akka/http/Mist.scala +++ b/akka-http/src/main/scala/akka/http/Mist.scala @@ -269,7 +269,7 @@ class RootEndpoint extends Actor with Endpoint { // adopt the configured id if (RootActorBuiltin) self.id = RootActorID - override def preStart = + override def preStart() = _attachments = Tuple2((uri: String) => {uri eq Root}, (uri: String) => this.actor) :: _attachments def recv: Receive = { diff --git a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala index c2277200b1..09a5f96bde 100644 --- a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala +++ b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala @@ -19,8 +19,8 @@ object ServerInitiatedRemoteSessionActorSpec { class RemoteStatefullSessionActorSpec extends Actor { - override def preStart = instantiatedSessionActors.add(self) - override def postStop = instantiatedSessionActors.remove(self) + override def preStart() = instantiatedSessionActors.add(self) + override def postStop() = instantiatedSessionActors.remove(self) var user: String = "anonymous" def receive = { diff --git a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala index a19ed26da0..90f6f2701e 100644 --- a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala +++ b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala @@ -186,7 +186,7 @@ protected def sessionManagement: Receive protected def shutdownSessions(): Unit - override def postStop = { + override def postStop() = { EventHandler.info(this, "Chat server is shutting down...") shutdownSessions self.unlink(storage) @@ -206,7 +206,7 @@ SessionManagement with ChatManagement with MemoryChatStorageFactory { - override def preStart = { + override def preStart() = { remote.start("localhost", 2552); remote.register("chat:service", self) //Register the actor with the specified service id } diff --git a/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala b/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala index e6d8b87c14..41f562791a 100644 --- a/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala +++ b/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala @@ -104,11 +104,11 @@ object Pi extends App { if (nrOfResults == nrOfMessages) self.stop() } - override def preStart { + override def preStart() { start = System.currentTimeMillis } - override def postStop { + override def postStop() { // tell the world that the calculation is complete println( "\n\tPi estimate: \t\t%s\n\tCalculation time: \t%s millis" diff --git a/akka-tutorials/akka-tutorial-second/src/main/scala/Pi.scala b/akka-tutorials/akka-tutorial-second/src/main/scala/Pi.scala index e7e10f56ef..35d29f8f6c 100644 --- a/akka-tutorials/akka-tutorial-second/src/main/scala/Pi.scala +++ b/akka-tutorials/akka-tutorial-second/src/main/scala/Pi.scala @@ -111,7 +111,7 @@ object Pi extends App { def receive = scatter // when we are stopped, stop our team of workers and our router - override def postStop { + override def postStop() { // send a PoisonPill to all workers telling them to shut down themselves router ! Broadcast(PoisonPill) // send a PoisonPill to the router, telling him to shut himself down diff --git a/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala b/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala index 7103c3fd5b..591613a203 100644 --- a/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala +++ b/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala @@ -83,11 +83,11 @@ import scala.reflect.BeanProperty * * def square(x: Int): Future[Integer] = future(x * x) * - * override def preStart = { + * override def preStart() = { * ... // optional initialization on start * } * - * override def postStop = { + * override def postStop() = { * ... // optional cleanup on stop * } * @@ -160,14 +160,14 @@ abstract class TypedActor extends Actor with Proxyable { *

* Is called when an Actor is started by invoking 'actor.start()'. */ - override def preStart {} + override def preStart() {} /** * User overridable callback. *

* Is called when 'actor.stop()' is invoked. */ - override def postStop {} + override def postStop() {} /** * User overridable callback. From 9c7242f374927c7ad7a6454af125234bb2a0071b Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 20:48:30 +0200 Subject: [PATCH 021/112] Moved untyped-actors from pending --- .../{pending/untyped-actors-java.rst => java/untyped-actors.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename akka-docs/{pending/untyped-actors-java.rst => java/untyped-actors.rst} (100%) diff --git a/akka-docs/pending/untyped-actors-java.rst b/akka-docs/java/untyped-actors.rst similarity index 100% rename from akka-docs/pending/untyped-actors-java.rst rename to akka-docs/java/untyped-actors.rst From 88d400a4e9c41151a48d6743c387386aa2b432a8 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 20:57:05 +0200 Subject: [PATCH 022/112] index for java api --- akka-docs/index.rst | 1 + akka-docs/java/index.rst | 7 +++++++ akka-docs/java/untyped-actors.rst | 17 ++++++++--------- 3 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 akka-docs/java/index.rst diff --git a/akka-docs/index.rst b/akka-docs/index.rst index fbb2506fab..11bfef862a 100644 --- a/akka-docs/index.rst +++ b/akka-docs/index.rst @@ -7,6 +7,7 @@ Contents intro/index general/index scala/index + java/index dev/index Links diff --git a/akka-docs/java/index.rst b/akka-docs/java/index.rst new file mode 100644 index 0000000000..ca3a84c5de --- /dev/null +++ b/akka-docs/java/index.rst @@ -0,0 +1,7 @@ +Java API +========= + +.. toctree:: + :maxdepth: 2 + + untyped-actors diff --git a/akka-docs/java/untyped-actors.rst b/akka-docs/java/untyped-actors.rst index 539f0a86a6..e7977801a3 100644 --- a/akka-docs/java/untyped-actors.rst +++ b/akka-docs/java/untyped-actors.rst @@ -1,7 +1,5 @@ -Actors (Java) -============= - -= +Actors +====== Module stability: **SOLID** @@ -412,8 +410,9 @@ Actor life-cycle The actor has a well-defined non-circular life-cycle. -``_ -NEW (newly created actor) - can't receive messages (yet) - => STARTED (when 'start' is invoked) - can receive messages - => SHUT DOWN (when 'exit' or 'stop' is invoked) - can't do anything -``_ +:: + + NEW (newly created actor) - can't receive messages (yet) + => STARTED (when 'start' is invoked) - can receive messages + => SHUT DOWN (when 'exit' or 'stop' is invoked) - can't do anything + From a0f52113aaf895a5b0e95afea17ddb828724b0ef Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:11:58 +0200 Subject: [PATCH 023/112] Moved actor-registry from pending --- .../actor-registry.rst} | 0 akka-docs/java/index.rst | 1 + akka-docs/java/untyped-actors.rst | 11 ++++++++--- .../actor-registry.rst} | 0 akka-docs/scala/actors.rst | 8 ++++++-- akka-docs/scala/index.rst | 1 + 6 files changed, 16 insertions(+), 5 deletions(-) rename akka-docs/{pending/actor-registry-java.rst => java/actor-registry.rst} (100%) rename akka-docs/{pending/actor-registry-scala.rst => scala/actor-registry.rst} (100%) diff --git a/akka-docs/pending/actor-registry-java.rst b/akka-docs/java/actor-registry.rst similarity index 100% rename from akka-docs/pending/actor-registry-java.rst rename to akka-docs/java/actor-registry.rst diff --git a/akka-docs/java/index.rst b/akka-docs/java/index.rst index ca3a84c5de..412e76d1cd 100644 --- a/akka-docs/java/index.rst +++ b/akka-docs/java/index.rst @@ -5,3 +5,4 @@ Java API :maxdepth: 2 untyped-actors + actor-registry diff --git a/akka-docs/java/untyped-actors.rst b/akka-docs/java/untyped-actors.rst index e7977801a3..5a29d13ae5 100644 --- a/akka-docs/java/untyped-actors.rst +++ b/akka-docs/java/untyped-actors.rst @@ -1,5 +1,9 @@ -Actors -====== +Actors (Java) +============= + +.. sidebar:: Contents + + .. contents:: :local: Module stability: **SOLID** @@ -21,7 +25,8 @@ Here is an example: public void onReceive(Object message) throws Exception { if (message instanceof String) - EventHandler.info(this, String.format("Received String message: %s", message)); + EventHandler.info(this, String.format("Received String message: %s", + message)); else throw new IllegalArgumentException("Unknown message: " + message); } diff --git a/akka-docs/pending/actor-registry-scala.rst b/akka-docs/scala/actor-registry.rst similarity index 100% rename from akka-docs/pending/actor-registry-scala.rst rename to akka-docs/scala/actor-registry.rst diff --git a/akka-docs/scala/actors.rst b/akka-docs/scala/actors.rst index a3e0bbd28f..ed186e17ba 100644 --- a/akka-docs/scala/actors.rst +++ b/akka-docs/scala/actors.rst @@ -1,5 +1,9 @@ -Actors -====== +Actors (Scala) +============== + +.. sidebar:: Contents + + .. contents:: :local: Module stability: **SOLID** diff --git a/akka-docs/scala/index.rst b/akka-docs/scala/index.rst index e54c88b979..adc2843f1e 100644 --- a/akka-docs/scala/index.rst +++ b/akka-docs/scala/index.rst @@ -5,5 +5,6 @@ Scala API :maxdepth: 2 actors + actor-registry fsm testing From 2efa82fc8e08319e0c68bee1a05d1e019892809a Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:27:49 +0200 Subject: [PATCH 024/112] Moved typed-actors from pending --- akka-docs/java/index.rst | 1 + .../{pending/typed-actors-java.rst => java/typed-actors.rst} | 0 akka-docs/scala/index.rst | 1 + .../{pending/typed-actors-scala.rst => scala/typed-actors.rst} | 0 4 files changed, 2 insertions(+) rename akka-docs/{pending/typed-actors-java.rst => java/typed-actors.rst} (100%) rename akka-docs/{pending/typed-actors-scala.rst => scala/typed-actors.rst} (100%) diff --git a/akka-docs/java/index.rst b/akka-docs/java/index.rst index 412e76d1cd..e9d77b30f6 100644 --- a/akka-docs/java/index.rst +++ b/akka-docs/java/index.rst @@ -5,4 +5,5 @@ Java API :maxdepth: 2 untyped-actors + typed-actors actor-registry diff --git a/akka-docs/pending/typed-actors-java.rst b/akka-docs/java/typed-actors.rst similarity index 100% rename from akka-docs/pending/typed-actors-java.rst rename to akka-docs/java/typed-actors.rst diff --git a/akka-docs/scala/index.rst b/akka-docs/scala/index.rst index adc2843f1e..ede84e0917 100644 --- a/akka-docs/scala/index.rst +++ b/akka-docs/scala/index.rst @@ -5,6 +5,7 @@ Scala API :maxdepth: 2 actors + typed-actors actor-registry fsm testing diff --git a/akka-docs/pending/typed-actors-scala.rst b/akka-docs/scala/typed-actors.rst similarity index 100% rename from akka-docs/pending/typed-actors-scala.rst rename to akka-docs/scala/typed-actors.rst From 89b1814d1c04819e1ec2a21d67f057fb4f738632 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:29:08 +0200 Subject: [PATCH 025/112] Added sidebar toc --- akka-docs/java/typed-actors.rst | 4 ++++ akka-docs/scala/typed-actors.rst | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/akka-docs/java/typed-actors.rst b/akka-docs/java/typed-actors.rst index 0f6c9563b5..edbb1d43c6 100644 --- a/akka-docs/java/typed-actors.rst +++ b/akka-docs/java/typed-actors.rst @@ -1,6 +1,10 @@ Typed Actors (Java) =================== +.. sidebar:: Contents + + .. contents:: :local: + Module stability: **SOLID** The Typed Actors are implemented through `Typed Actors `_. It uses AOP through `AspectWerkz `_ to turn regular POJOs into asynchronous non-blocking Actors with semantics of the Actor Model. E.g. each message dispatch is turned into a message that is put on a queue to be processed by the Typed Actor sequentially one by one. diff --git a/akka-docs/scala/typed-actors.rst b/akka-docs/scala/typed-actors.rst index e9aa061672..9fc6d327c1 100644 --- a/akka-docs/scala/typed-actors.rst +++ b/akka-docs/scala/typed-actors.rst @@ -1,6 +1,10 @@ Typed Actors (Scala) ==================== +.. sidebar:: Contents + + .. contents:: :local: + Module stability: **SOLID** The Typed Actors are implemented through `Typed Actors `_. It uses AOP through `AspectWerkz `_ to turn regular POJOs into asynchronous non-blocking Actors with semantics of the Actor Model. E.g. each message dispatch is turned into a message that is put on a queue to be processed by the Typed Actor sequentially one by one. From 054403325d39e7f368f6af6c53d6b4bfa4d9543d Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:31:13 +0200 Subject: [PATCH 026/112] Added serialize-messages description to scala typed actors doc --- akka-docs/scala/typed-actors.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/akka-docs/scala/typed-actors.rst b/akka-docs/scala/typed-actors.rst index 9fc6d327c1..912ac234be 100644 --- a/akka-docs/scala/typed-actors.rst +++ b/akka-docs/scala/typed-actors.rst @@ -173,3 +173,15 @@ Messages and immutability ------------------------- **IMPORTANT**: Messages can be any kind of object but have to be immutable (there is a workaround, see next section). Java or Scala can’t enforce immutability (yet) so this has to be by convention. Primitives like String, int, Long are always immutable. Apart from these you have to create your own immutable objects to send as messages. If you pass on a reference to an instance that is mutable then this instance can be modified concurrently by two different Typed Actors and the Actor model is broken leaving you with NO guarantees and most likely corrupt data. + +Akka can help you in this regard. It allows you to turn on an option for serializing all messages, e.g. all parameters to the Typed Actor effectively making a deep clone/copy of the parameters. This will make sending mutable messages completely safe. This option is turned on in the ‘$AKKA_HOME/config/akka.conf’ config file like this: + +.. code-block:: ruby + + akka { + actor { + serialize-messages = on # does a deep clone of messages to ensure immutability + } + } + +This will make a deep clone (using Java serialization) of all parameters. From b19bd275d2e9e204d96dfb279579090a278a8948 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:34:04 +0200 Subject: [PATCH 027/112] typo --- akka-docs/java/typed-actors.rst | 2 +- akka-docs/scala/typed-actors.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/akka-docs/java/typed-actors.rst b/akka-docs/java/typed-actors.rst index edbb1d43c6..acd99b7fcf 100644 --- a/akka-docs/java/typed-actors.rst +++ b/akka-docs/java/typed-actors.rst @@ -175,7 +175,7 @@ Here is an example how you can use it to in a 'void' (e.g. fire-forget) method t } } -If the sender, sender future etc. is not available, then these methods will return 'null' so you should have a way of dealing with scenario. +If the sender, sender future etc. is not available, then these methods will return 'null' so you should have a way of dealing with that scenario. Messages and immutability ------------------------- diff --git a/akka-docs/scala/typed-actors.rst b/akka-docs/scala/typed-actors.rst index 912ac234be..7e5a327113 100644 --- a/akka-docs/scala/typed-actors.rst +++ b/akka-docs/scala/typed-actors.rst @@ -167,7 +167,7 @@ Here is an example how you can use it to in a 'void' (e.g. fire-forget) method t } } -If the sender, sender future etc. is not available, then these methods will return 'null' so you should have a way of dealing with scenario. +If the sender, sender future etc. is not available, then these methods will return 'null' so you should have a way of dealing with that scenario. Messages and immutability ------------------------- From 40533a73341a3d8fb832fd4215b4808917bd0337 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:39:10 +0200 Subject: [PATCH 028/112] Moved event-handler from pending --- akka-docs/{pending => general}/event-handler.rst | 0 akka-docs/general/index.rst | 1 + 2 files changed, 1 insertion(+) rename akka-docs/{pending => general}/event-handler.rst (100%) diff --git a/akka-docs/pending/event-handler.rst b/akka-docs/general/event-handler.rst similarity index 100% rename from akka-docs/pending/event-handler.rst rename to akka-docs/general/event-handler.rst diff --git a/akka-docs/general/index.rst b/akka-docs/general/index.rst index 5b0e3c24d6..81cee4fcf2 100644 --- a/akka-docs/general/index.rst +++ b/akka-docs/general/index.rst @@ -5,4 +5,5 @@ General :maxdepth: 2 migration-guides + event-handler util From 850536bd2aa4e613f070e40eae3ed9d513cfb30d Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:42:11 +0200 Subject: [PATCH 029/112] cleanup --- akka-docs/general/event-handler.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/akka-docs/general/event-handler.rst b/akka-docs/general/event-handler.rst index 18eefefb0a..e43bb20eb0 100644 --- a/akka-docs/general/event-handler.rst +++ b/akka-docs/general/event-handler.rst @@ -12,7 +12,8 @@ You can configure which event handlers should be registered at boot time. That i .. code-block:: ruby akka { - event-handlers = ["akka.event.EventHandler$DefaultListener"] # event handlers to register at boot time (EventHandler$DefaultListener logs to STDOUT) + # event handlers to register at boot time (EventHandler$DefaultListener logs to STDOUT) + event-handlers = ["akka.event.EventHandler$DefaultListener"] event-handler-level = "DEBUG" # Options: ERROR, WARNING, INFO, DEBUG } @@ -88,9 +89,10 @@ The methods take a call-by-name parameter for the message to avoid object alloca From Java you need to nest the call in an if statement to achieve the same thing. -``_ -if (EventHandler.isDebugEnabled()) { - EventHandler.debug(this, String.format("Processing took %s ms", duration)); -} +.. code-block:: java + + if (EventHandler.isDebugEnabled()) { + EventHandler.debug(this, String.format("Processing took %s ms", duration)); + } + -``_ From e2c0d11c101f614773f47c289f40825da7f7146c Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:45:33 +0200 Subject: [PATCH 030/112] Moved dispatchers from pending --- akka-docs/{pending/dispatchers-java.rst => java/dispatchers.rst} | 0 akka-docs/java/index.rst | 1 + .../{pending/dispatchers-scala.rst => scala/dispatchers.rst} | 0 akka-docs/scala/index.rst | 1 + 4 files changed, 2 insertions(+) rename akka-docs/{pending/dispatchers-java.rst => java/dispatchers.rst} (100%) rename akka-docs/{pending/dispatchers-scala.rst => scala/dispatchers.rst} (100%) diff --git a/akka-docs/pending/dispatchers-java.rst b/akka-docs/java/dispatchers.rst similarity index 100% rename from akka-docs/pending/dispatchers-java.rst rename to akka-docs/java/dispatchers.rst diff --git a/akka-docs/java/index.rst b/akka-docs/java/index.rst index e9d77b30f6..70fefd1f53 100644 --- a/akka-docs/java/index.rst +++ b/akka-docs/java/index.rst @@ -7,3 +7,4 @@ Java API untyped-actors typed-actors actor-registry + dispatchers diff --git a/akka-docs/pending/dispatchers-scala.rst b/akka-docs/scala/dispatchers.rst similarity index 100% rename from akka-docs/pending/dispatchers-scala.rst rename to akka-docs/scala/dispatchers.rst diff --git a/akka-docs/scala/index.rst b/akka-docs/scala/index.rst index ede84e0917..e772d2d926 100644 --- a/akka-docs/scala/index.rst +++ b/akka-docs/scala/index.rst @@ -7,5 +7,6 @@ Scala API actors typed-actors actor-registry + dispatchers fsm testing From 884a9ae2ef144e01c0ba6d3fa2bac2cfc9265a37 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:52:45 +0200 Subject: [PATCH 031/112] Cleanup --- akka-docs/java/dispatchers.rst | 27 ++++++++++++++++----------- akka-docs/scala/dispatchers.rst | 24 +++++++++++++++--------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/akka-docs/java/dispatchers.rst b/akka-docs/java/dispatchers.rst index b9d5ee9ee8..a7fe7ce19a 100644 --- a/akka-docs/java/dispatchers.rst +++ b/akka-docs/java/dispatchers.rst @@ -1,6 +1,10 @@ Dispatchers (Java) ================== +.. sidebar:: Contents + + .. contents:: :local: + Module stability: **SOLID** The Dispatcher is an important piece that allows you to configure the right semantics and parameters for optimal performance, throughput and scalability. Different Actors have different needs. @@ -128,7 +132,7 @@ If you don't define a the 'throughput' option in the configuration file then the Browse the `ScalaDoc `_ or look at the code for all the options available. Priority event-based -^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ Sometimes it's useful to be able to specify priority order of messages, that is done by using PriorityExecutorBasedEventDrivenDispatcher and supply a java.util.Comparator[MessageInvocation] or use a akka.dispatch.PriorityGenerator (recommended): @@ -137,7 +141,7 @@ Creating a PriorityExecutorBasedEventDrivenDispatcher using PriorityGenerator: .. code-block:: java - package some.package; + package some.pkg; import akka.actor.*; import akka.dispatch.*; @@ -249,13 +253,14 @@ For the 'ExecutorBasedEventDrivenDispatcher' and the 'ExecutorBasedWorkStealingD For the 'ThreadBasedDispatcher', it is non-shareable between actors, and associates a dedicated Thread with the actor. Making it bounded (by specifying a capacity) is optional, but if you do, you need to provide a pushTimeout (default is 10 seconds). When trying to send a message to the Actor it will throw a MessageQueueAppendFailedException("BlockingMessageTransferQueue transfer timed out") if the message cannot be added to the mailbox within the time specified by the pushTimeout. -``_ -class MyActor extends UntypedActor { - public MyActor() { - int mailboxCapacity = 100; - Duration pushTimeout = new FiniteDuration(10, TimeUnit.SECONDS); - getContext().setDispatcher(Dispatchers.newThreadBasedDispatcher(getContext(), mailboxCapacity, pushTimeout)); +.. code-block:: java + + class MyActor extends UntypedActor { + public MyActor() { + int mailboxCapacity = 100; + Duration pushTimeout = new FiniteDuration(10, TimeUnit.SECONDS); + getContext().setDispatcher(Dispatchers.newThreadBasedDispatcher(getContext(), mailboxCapacity, pushTimeout)); + } + ... } - ... -} -``_ + diff --git a/akka-docs/scala/dispatchers.rst b/akka-docs/scala/dispatchers.rst index 62584835a4..35285c20fa 100644 --- a/akka-docs/scala/dispatchers.rst +++ b/akka-docs/scala/dispatchers.rst @@ -1,6 +1,10 @@ Dispatchers (Scala) =================== +.. sidebar:: Contents + + .. contents:: :local: + Module stability: **SOLID** The Dispatcher is an important piece that allows you to configure the right semantics and parameters for optimal performance, throughput and scalability. Different Actors have different needs. @@ -124,7 +128,7 @@ If you don't define a the 'throughput' option in the configuration file then the Browse the `ScalaDoc `_ or look at the code for all the options available. Priority event-based -^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ Sometimes it's useful to be able to specify priority order of messages, that is done by using PriorityExecutorBasedEventDrivenDispatcher and supply a java.util.Comparator[MessageInvocation] or use a akka.dispatch.PriorityGenerator (recommended): @@ -231,11 +235,13 @@ For the 'ExecutorBasedEventDrivenDispatcher' and the 'ExecutorBasedWorkStealingD For the 'ThreadBasedDispatcher', it is non-shareable between actors, and associates a dedicated Thread with the actor. Making it bounded (by specifying a capacity) is optional, but if you do, you need to provide a pushTimeout (default is 10 seconds). When trying to send a message to the Actor it will throw a MessageQueueAppendFailedException("BlockingMessageTransferQueue transfer timed out") if the message cannot be added to the mailbox within the time specified by the pushTimeout. -``_ -class MyActor extends Actor { - import akka.util.duration._ - self.dispatcher = Dispatchers.newThreadBasedDispatcher(self, mailboxCapacity = 100, - pushTimeOut = 10 seconds) - ... -} -``_ +.. code-block:: scala + + class MyActor extends Actor { + import akka.util.duration._ + self.dispatcher = Dispatchers.newThreadBasedDispatcher(self, mailboxCapacity = 100, + pushTimeOut = 10 seconds) + ... + } + + From a44031d0782be2be32a6e2089f8697c42c48e468 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:55:24 +0200 Subject: [PATCH 032/112] Moved agents from pending --- akka-docs/{pending/agents-scala.rst => scala/agents.rst} | 0 akka-docs/scala/index.rst | 1 + 2 files changed, 1 insertion(+) rename akka-docs/{pending/agents-scala.rst => scala/agents.rst} (100%) diff --git a/akka-docs/pending/agents-scala.rst b/akka-docs/scala/agents.rst similarity index 100% rename from akka-docs/pending/agents-scala.rst rename to akka-docs/scala/agents.rst diff --git a/akka-docs/scala/index.rst b/akka-docs/scala/index.rst index e772d2d926..1138ad803a 100644 --- a/akka-docs/scala/index.rst +++ b/akka-docs/scala/index.rst @@ -7,6 +7,7 @@ Scala API actors typed-actors actor-registry + agents dispatchers fsm testing From e3a5aa724093d71b97982cf39af43e9fd430e56c Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:56:34 +0200 Subject: [PATCH 033/112] Sidebar toc --- akka-docs/scala/agents.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/akka-docs/scala/agents.rst b/akka-docs/scala/agents.rst index c6a4ee9b73..1e9ea128a3 100644 --- a/akka-docs/scala/agents.rst +++ b/akka-docs/scala/agents.rst @@ -1,6 +1,10 @@ Agents (Scala) ============== +.. sidebar:: Contents + + .. contents:: :local: + Module stability: **SOLID** Agents in Akka were inspired by `agents in Clojure `_. From 0cc6499a4ae95f1d2bfdc1b5c20dd6e2c6cb3283 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 21:58:36 +0200 Subject: [PATCH 034/112] Moved stm from pending --- akka-docs/java/index.rst | 1 + akka-docs/{pending/stm-java.rst => java/stm.rst} | 0 akka-docs/scala/index.rst | 1 + akka-docs/{pending/stm-scala.rst => scala/stm.rst} | 0 4 files changed, 2 insertions(+) rename akka-docs/{pending/stm-java.rst => java/stm.rst} (100%) rename akka-docs/{pending/stm-scala.rst => scala/stm.rst} (100%) diff --git a/akka-docs/java/index.rst b/akka-docs/java/index.rst index 70fefd1f53..d4fed805d4 100644 --- a/akka-docs/java/index.rst +++ b/akka-docs/java/index.rst @@ -7,4 +7,5 @@ Java API untyped-actors typed-actors actor-registry + stm dispatchers diff --git a/akka-docs/pending/stm-java.rst b/akka-docs/java/stm.rst similarity index 100% rename from akka-docs/pending/stm-java.rst rename to akka-docs/java/stm.rst diff --git a/akka-docs/scala/index.rst b/akka-docs/scala/index.rst index 1138ad803a..186cc0b949 100644 --- a/akka-docs/scala/index.rst +++ b/akka-docs/scala/index.rst @@ -8,6 +8,7 @@ Scala API typed-actors actor-registry agents + stm dispatchers fsm testing diff --git a/akka-docs/pending/stm-scala.rst b/akka-docs/scala/stm.rst similarity index 100% rename from akka-docs/pending/stm-scala.rst rename to akka-docs/scala/stm.rst From 929f8458ff96fad9626c53e5631016a616ed7ec2 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 22:23:23 +0200 Subject: [PATCH 035/112] Cleanup --- akka-docs/java/stm.rst | 49 +++++++++++++++++++------------------ akka-docs/scala/stm.rst | 53 +++++++++++++++++++---------------------- 2 files changed, 49 insertions(+), 53 deletions(-) diff --git a/akka-docs/java/stm.rst b/akka-docs/java/stm.rst index 1b06fc94a7..221c706183 100644 --- a/akka-docs/java/stm.rst +++ b/akka-docs/java/stm.rst @@ -1,10 +1,14 @@ Software Transactional Memory (Java) ==================================== +.. sidebar:: Contents + + .. contents:: :local: + Module stability: **SOLID** Overview of STM -=============== +--------------- An `STM `_ turns the Java heap into a transactional data set with begin/commit/rollback semantics. Very much like a regular database. It implements the first three letters in ACID; ACI: * (failure) Atomicity: all changes during the execution of a transaction make it, or none make it. This only counts for transactional datastructures. @@ -24,7 +28,7 @@ The STM is based on Transactional References (referred to as Refs). Refs are mem Working with immutable collections can sometimes give bad performance due to extensive copying. Scala provides so-called persistent datastructures which makes working with immutable collections fast. They are immutable but with constant time access and modification. The use of structural sharing and an insert or update does not ruin the old structure, hence “persistent”. Makes working with immutable composite types fast. The persistent datastructures currently consist of a Map and Vector. Simple example -============== +-------------- Here is a simple example of an incremental counter using STM. This shows creating a ``Ref``, a transactional reference, and then modifying it within a transaction, which is delimited by an ``Atomic`` anonymous inner class. @@ -50,15 +54,14 @@ Here is a simple example of an incremental counter using STM. This shows creatin counter(); // -> 2 ----- Ref -=== +--- Refs (transactional references) are mutable references to values and through the STM allow the safe sharing of mutable data. To ensure safety the value stored in a Ref should be immutable. The value referenced by a Ref can only be accessed or swapped within a transaction. Refs separate identity from value. Creating a Ref --------------- +^^^^^^^^^^^^^^ You can create a Ref with or without an initial value. @@ -73,7 +76,7 @@ You can create a Ref with or without an initial value. final Ref ref = new Ref(); Accessing the value of a Ref ----------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use ``get`` to access the value of a Ref. Note that if no initial value has been given then the value is initially ``null``. @@ -91,7 +94,7 @@ Use ``get`` to access the value of a Ref. Note that if no initial value has been // -> value = 0 Changing the value of a Ref ---------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^ To set a new value for a Ref you can use ``set`` (or equivalently ``swap``), which sets the new value and returns the old value. @@ -107,10 +110,9 @@ To set a new value for a Ref you can use ``set`` (or equivalently ``swap``), whi } }.execute(); ----- Transactions -============ +------------ A transaction is delimited using an ``Atomic`` anonymous inner class. @@ -125,24 +127,24 @@ A transaction is delimited using an ``Atomic`` anonymous inner class. All changes made to transactional objects are isolated from other changes, all make it or non make it (so failure atomicity) and are consistent. With the AkkaSTM you automatically have the Oracle version of the SERIALIZED isolation level, lower isolation is not possible. To make it fully serialized, set the writeskew property that checks if a writeskew problem is allowed to happen. Retries -------- +^^^^^^^ A transaction is automatically retried when it runs into some read or write conflict, until the operation completes, an exception (throwable) is thrown or when there are too many retries. When a read or writeconflict is encountered, the transaction uses a bounded exponential backoff to prevent cause more contention and give other transactions some room to complete. If you are using non transactional resources in an atomic block, there could be problems because a transaction can be retried. If you are using print statements or logging, it could be that they are called more than once. So you need to be prepared to deal with this. One of the possible solutions is to work with a deferred or compensating task that is executed after the transaction aborts or commits. Unexpected retries ------------------- +^^^^^^^^^^^^^^^^^^ It can happen for the first few executions that you get a few failures of execution that lead to unexpected retries, even though there is not any read or writeconflict. The cause of this is that speculative transaction configuration/selection is used. There are transactions optimized for a single transactional object, for 1..n and for n to unlimited. So based on the execution of the transaction, the system learns; it begins with a cheap one and upgrades to more expensive ones. Once it has learned, it will reuse this knowledge. It can be activated/deactivated using the speculative property on the TransactionFactoryBuilder. In most cases it is best use the default value (enabled) so you get more out of performance. Coordinated transactions and Transactors ----------------------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If you need coordinated transactions across actors or threads then see `Transactors `_. Configuring transactions ------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^ It's possible to configure transactions. The ``Atomic`` class can take a ``TransactionFactory``, which can determine properties of the transaction. A default transaction factory is used if none is specified. You can create a ``TransactionFactory`` with a ``TransactionFactoryBuilder``. @@ -197,7 +199,7 @@ You can also specify the default values for some of these options in akka.conf. } Transaction lifecycle listeners -------------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It's possible to have code that will only run on the successful commit of a transaction, or when a transaction aborts. You can do this by adding ``deferred`` or ``compensating`` blocks to a transaction. @@ -225,7 +227,7 @@ It's possible to have code that will only run on the successful commit of a tran }.execute(); Blocking transactions ---------------------- +^^^^^^^^^^^^^^^^^^^^^ You can block in a transaction until a condition is met by using an explicit ``retry``. To use ``retry`` you also need to configure the transaction to allow explicit retries. @@ -338,7 +340,7 @@ Here is an example of using ``retry`` to block until an account has enough money } Alternative blocking transactions ---------------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can also have two alternative blocking transactions, one of which can succeed first, with ``EitherOrElse``. @@ -443,10 +445,9 @@ You can also have two alternative blocking transactions, one of which can succee } } ----- Transactional datastructures -============================ +---------------------------- Akka provides two datastructures that are managed by the STM. @@ -510,15 +511,14 @@ Here is an example of creating and accessing a TransactionalVector: } }.execute(); ----- Persistent datastructures -========================= +------------------------- Akka's STM should only be used with immutable data. This can be costly if you have large datastructures and are using a naive copy-on-write. In order to make working with immutable datastructures fast enough Scala provides what are called Persistent Datastructures. There are currently two different ones: -- HashMap (`scaladoc `_) -- Vector (`scaladoc `_) +- HashMap (`scaladoc `__) +- Vector (`scaladoc `__) They are immutable and each update creates a completely new version but they are using clever structural sharing in order to make them almost as fast, for both read and update, as regular mutable datastructures. @@ -526,10 +526,9 @@ This illustration is taken from Rich Hickey's presentation. Copyright Rich Hicke .. image:: http://eclipsesource.com/blogs/wp-content/uploads/2009/12/clojure-trees.png ----- JTA integration -=============== +--------------- The STM has JTA (Java Transaction API) integration. This means that it will, if enabled, hook in to JTA and start a JTA transaction when the STM transaction is started. It will also rollback the STM transaction if the JTA transaction has failed and vice versa. This does not mean that the STM is made durable, if you need that you should use one of the `persistence modules `_. It simply means that the STM will participate and interact with and external JTA provider, for example send a message using JMS atomically within an STM transaction, or use Hibernate to persist STM managed data etc. @@ -555,4 +554,4 @@ You also have to configure which JTA provider to use etc in the 'jta' config sec timeout = 60 } ----- + diff --git a/akka-docs/scala/stm.rst b/akka-docs/scala/stm.rst index 1db74895d8..4917a7cd96 100644 --- a/akka-docs/scala/stm.rst +++ b/akka-docs/scala/stm.rst @@ -1,10 +1,14 @@ Software Transactional Memory (Scala) ===================================== +.. sidebar:: Contents + + .. contents:: :local: + Module stability: **SOLID** Overview of STM -=============== +--------------- An `STM `_ turns the Java heap into a transactional data set with begin/commit/rollback semantics. Very much like a regular database. It implements the first three letters in ACID; ACI: * Atomic @@ -24,7 +28,7 @@ The STM is based on Transactional References (referred to as Refs). Refs are mem Working with immutable collections can sometimes give bad performance due to extensive copying. Scala provides so-called persistent datastructures which makes working with immutable collections fast. They are immutable but with constant time access and modification. They use structural sharing and an insert or update does not ruin the old structure, hence “persistent”. Makes working with immutable composite types fast. The persistent datastructures currently consist of a Map and Vector. Simple example -============== +-------------- Here is a simple example of an incremental counter using STM. This shows creating a ``Ref``, a transactional reference, and then modifying it within a transaction, which is delimited by ``atomic``. @@ -44,15 +48,14 @@ Here is a simple example of an incremental counter using STM. This shows creatin counter // -> 2 ----- Ref -=== +--- Refs (transactional references) are mutable references to values and through the STM allow the safe sharing of mutable data. Refs separate identity from value. To ensure safety the value stored in a Ref should be immutable (they can of course contain refs themselves). The value referenced by a Ref can only be accessed or swapped within a transaction. If a transaction is not available, the call will be executed in its own transaction (the call will be atomic). This is a different approach than the Clojure Refs, where a missing transaction results in an error. Creating a Ref --------------- +^^^^^^^^^^^^^^ You can create a Ref with or without an initial value. @@ -67,7 +70,7 @@ You can create a Ref with or without an initial value. val ref = Ref[Int] Accessing the value of a Ref ----------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use ``get`` to access the value of a Ref. Note that if no initial value has been given then the value is initially ``null``. @@ -97,7 +100,7 @@ If there is a chance that the value of a Ref is null then you can use ``opt``, w } Changing the value of a Ref ---------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^ To set a new value for a Ref you can use ``set`` (or equivalently ``swap``), which sets the new value and returns the old value. @@ -138,7 +141,7 @@ You can also use ``alter`` which accepts a function that takes the old value and // -> 6 Refs in for-comprehensions --------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^ Ref is monadic and can be used in for-comprehensions. @@ -174,10 +177,9 @@ Ref is monadic and can be used in for-comprehensions. } // -> Ref[Int] ----- Transactions -============ +------------ A transaction is delimited using ``atomic``. @@ -190,24 +192,24 @@ A transaction is delimited using ``atomic``. All changes made to transactional objects are isolated from other changes, all make it or non make it (so failure atomicity) and are consistent. With the AkkaSTM you automatically have the Oracle version of the SERIALIZED isolation level, lower isolation is not possible. To make it fully serialized, set the writeskew property that checks if a writeskew problem is allowed to happen. Retries -------- +^^^^^^^ A transaction is automatically retried when it runs into some read or write conflict, until the operation completes, an exception (throwable) is thrown or when there are too many retries. When a read or writeconflict is encountered, the transaction uses a bounded exponential backoff to prevent cause more contention and give other transactions some room to complete. If you are using non transactional resources in an atomic block, there could be problems because a transaction can be retried. If you are using print statements or logging, it could be that they are called more than once. So you need to be prepared to deal with this. One of the possible solutions is to work with a deferred or compensating task that is executed after the transaction aborts or commits. Unexpected retries ------------------- +^^^^^^^^^^^^^^^^^^ It can happen for the first few executions that you get a few failures of execution that lead to unexpected retries, even though there is not any read or writeconflict. The cause of this is that speculative transaction configuration/selection is used. There are transactions optimized for a single transactional object, for 1..n and for n to unlimited. So based on the execution of the transaction, the system learns; it begins with a cheap one and upgrades to more expensive ones. Once it has learned, it will reuse this knowledge. It can be activated/deactivated using the speculative property on the TransactionFactory. In most cases it is best use the default value (enabled) so you get more out of performance. Coordinated transactions and Transactors ----------------------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If you need coordinated transactions across actors or threads then see `Transactors `_. Configuring transactions ------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^ It's possible to configure transactions. The ``atomic`` method can take an implicit or explicit ``TransactionFactory``, which can determine properties of the transaction. A default transaction factory is used if none is specified explicitly or there is no implicit ``TransactionFactory`` in scope. @@ -311,7 +313,7 @@ Here's a similar example with an individual transaction factory for each instanc } Transaction lifecycle listeners -------------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It's possible to have code that will only run on the successful commit of a transaction, or when a transaction aborts. You can do this by adding ``deferred`` or ``compensating`` blocks to a transaction. @@ -329,7 +331,7 @@ It's possible to have code that will only run on the successful commit of a tran } Blocking transactions ---------------------- +^^^^^^^^^^^^^^^^^^^^^ You can block in a transaction until a condition is met by using an explicit ``retry``. To use ``retry`` you also need to configure the transaction to allow explicit retries. @@ -383,7 +385,7 @@ Here is an example of using ``retry`` to block until an account has enough money transferer.stop() Alternative blocking transactions ---------------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can also have two alternative blocking transactions, one of which can succeed first, with ``either-orElse``. @@ -434,10 +436,9 @@ You can also have two alternative blocking transactions, one of which can succee brancher.stop() ----- Transactional datastructures -============================ +---------------------------- Akka provides two datastructures that are managed by the STM. @@ -511,14 +512,13 @@ Here is the same example using TransactionalMap: } // -> User("bill") ----- Persistent datastructures -========================= +------------------------- Akka's STM should only be used with immutable data. This can be costly if you have large datastructures and are using a naive copy-on-write. In order to make working with immutable datastructures fast enough Scala provides what are called Persistent Datastructures. There are currently two different ones: -* HashMap (`scaladoc `_) -* Vector (`scaladoc `_) +* HashMap (`scaladoc `__) +* Vector (`scaladoc `__) They are immutable and each update creates a completely new version but they are using clever structural sharing in order to make them almost as fast, for both read and update, as regular mutable datastructures. @@ -527,10 +527,8 @@ This illustration is taken from Rich Hickey's presentation. Copyright Rich Hicke .. image:: http://eclipsesource.com/blogs/wp-content/uploads/2009/12/clojure-trees.png ----- - JTA integration -=============== +--------------- The STM has JTA (Java Transaction API) integration. This means that it will, if enabled, hook in to JTA and start a JTA transaction when the STM transaction is started. It will also rollback the STM transaction if the JTA transaction has failed and vice versa. This does not mean that the STM is made durable, if you need that you should use one of the `persistence modules `_. It simply means that the STM will participate and interact with and external JTA provider, for example send a message using JMS atomically within an STM transaction, or use Hibernate to persist STM managed data etc. @@ -556,9 +554,8 @@ You also have to configure which JTA provider to use etc in the 'jta' config sec timeout = 60 } ----- Ants simulation sample -====================== +---------------------- One fun and very enlightening visual demo of STM, actors and transactional references is the `Ant simulation sample `_. I encourage you to run it and read through the code since it's a good example of using actors with STM. From ce99b60060450b4d0d7e0ec04edd6dbb855eedf9 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 22:26:21 +0200 Subject: [PATCH 036/112] Moved tutorial-chat-server from pending --- akka-docs/scala/index.rst | 1 + .../tutorial-chat-server.rst} | 0 2 files changed, 1 insertion(+) rename akka-docs/{pending/tutorial-chat-server-scala.rst => scala/tutorial-chat-server.rst} (100%) diff --git a/akka-docs/scala/index.rst b/akka-docs/scala/index.rst index 186cc0b949..8897cfc17b 100644 --- a/akka-docs/scala/index.rst +++ b/akka-docs/scala/index.rst @@ -12,3 +12,4 @@ Scala API dispatchers fsm testing + tutorial-chat-server diff --git a/akka-docs/pending/tutorial-chat-server-scala.rst b/akka-docs/scala/tutorial-chat-server.rst similarity index 100% rename from akka-docs/pending/tutorial-chat-server-scala.rst rename to akka-docs/scala/tutorial-chat-server.rst From 0b405aa37d6c6c28f54f9d61bbaa4dde616d0329 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 26 Apr 2011 22:30:19 +0200 Subject: [PATCH 037/112] Cleanup --- akka-docs/scala/tutorial-chat-server.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/akka-docs/scala/tutorial-chat-server.rst b/akka-docs/scala/tutorial-chat-server.rst index afec3e948f..4a10af9a45 100644 --- a/akka-docs/scala/tutorial-chat-server.rst +++ b/akka-docs/scala/tutorial-chat-server.rst @@ -1,6 +1,10 @@ Tutorial: write a scalable, fault-tolerant, persistent network chat server and client (Scala) ============================================================================================= +.. sidebar:: Contents + + .. contents:: :local: + Introduction ------------ @@ -44,6 +48,8 @@ Here is a little example before we dive into a more interesting one. .. code-block:: scala + import akka.actor.Actor + class MyActor extends Actor { def receive = { case "test" => println("received test") @@ -118,7 +124,8 @@ Sometimes however, there is a need for sequential logic, sending a message and w def login = chat ! Login(name) def logout = chat ! Logout(name) def post(message: String) = chat ! ChatMessage(name, name + ": " + message) - def chatLog = (chat !! GetChatLog(name)).as[ChatLog].getOrElse(throw new Exception("Couldn't get the chat log from ChatServer")) + def chatLog = (chat !! GetChatLog(name)).as[ChatLog] + .getOrElse(throw new Exception("Couldn't get the chat log from ChatServer")) } As you can see, we are using the 'Actor.remote.actorFor' to lookup the chat server on the remote node. From this call we will get a handle to the remote instance and can use it as it is local. From 735252d12c6dd59aa843111940137cf9248577dd Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Wed, 27 Apr 2011 09:34:11 +1200 Subject: [PATCH 038/112] Update building akka docs --- akka-docs/intro/building-akka.rst | 205 ++++++++---------------------- 1 file changed, 50 insertions(+), 155 deletions(-) diff --git a/akka-docs/intro/building-akka.rst b/akka-docs/intro/building-akka.rst index 2f2a745eeb..02765172d3 100644 --- a/akka-docs/intro/building-akka.rst +++ b/akka-docs/intro/building-akka.rst @@ -1,5 +1,11 @@ -Building Akka -============= + +.. highlightlang:: none + +.. _building-akka: + +############### + Building Akka +############### This page describes how to build and run Akka from the latest source code. @@ -7,16 +13,18 @@ This page describes how to build and run Akka from the latest source code. Get the source code -------------------- +=================== -Akka uses `Git `_ and is hosted at `Github -`_. +Akka uses `Git`_ and is hosted at `Github`_. + +.. _Git: http://git-scm.com +.. _Github: http://github.com You first need Git installed on your machine. You can then clone the source repositories: -- Akka repository from ``_ -- Akka Modules repository from ``_ +- Akka repository from http://github.com/jboner/akka +- Akka Modules repository from http://github.com/jboner/akka-modules For example:: @@ -30,24 +38,27 @@ code with ``git pull``:: SBT - Simple Build Tool ------------------------ +======================= -Akka is using the excellent `SBT `_ -build system. So the first thing you have to do is to download and install -SBT. You can read more about how to do that `here -`_ . +Akka is using the excellent `SBT`_ build system. So the first thing you have to +do is to download and install SBT. You can read more about how to do that in the +`SBT setup`_ documentation. + +.. _SBT: http://code.google.com/p/simple-build-tool +.. _SBT setup: http://code.google.com/p/simple-build-tool/wiki/Setup The SBT commands that you'll need to build Akka are all included below. If you want to find out more about SBT and using it for your own projects do read the -`SBT documentation -`_. +`SBT documentation`_. + +.. _SBT documentation: http://code.google.com/p/simple-build-tool/wiki/RunningSbt The Akka SBT build file is ``project/build/AkkaProject.scala`` with some properties defined in ``project/build.properties``. Building Akka -------------- +============= First make sure that you are in the akka code directory:: @@ -55,7 +66,7 @@ First make sure that you are in the akka code directory:: Fetching dependencies -^^^^^^^^^^^^^^^^^^^^^ +--------------------- SBT does not fetch dependencies automatically. You need to manually do this with the ``update`` command:: @@ -70,7 +81,7 @@ or when the dependencies have changed.* Building -^^^^^^^^ +-------- To compile all the Akka core modules use the ``compile`` command:: @@ -85,7 +96,7 @@ latest Akka development version. Publish to local Ivy repository -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +------------------------------- If you want to deploy the artifacts to your local Ivy repository (for example, to use from an SBT project) use the ``publish-local`` command:: @@ -94,7 +105,7 @@ to use from an SBT project) use the ``publish-local`` command:: Publish to local Maven repository -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +--------------------------------- If you want to deploy the artifacts to your local Maven repository use:: @@ -102,7 +113,7 @@ If you want to deploy the artifacts to your local Maven repository use:: SBT interactive mode -^^^^^^^^^^^^^^^^^^^^ +-------------------- Note that in the examples above we are calling ``sbt compile`` and ``sbt test`` and so on. SBT also has an interactive mode. If you just run ``sbt`` you enter @@ -110,9 +121,7 @@ the interactive SBT prompt and can enter the commands directly. This saves starting up a new JVM instance for each command and can be much faster and more convenient. -For example, building Akka as above is more commonly done like this: - -.. code-block:: none +For example, building Akka as above is more commonly done like this:: % sbt [info] Building project akka 1.1-SNAPSHOT against Scala 2.9.0.RC1 @@ -131,7 +140,7 @@ For example, building Akka as above is more commonly done like this: SBT batch mode -^^^^^^^^^^^^^^ +-------------- It's also possible to combine commands in a single call. For example, updating, testing, and publishing Akka to the local Ivy repository can be done with:: @@ -140,7 +149,7 @@ testing, and publishing Akka to the local Ivy repository can be done with:: Building Akka Modules ---------------------- +===================== To build Akka Modules first build and publish Akka to your local Ivy repository as described above. Or using:: @@ -157,7 +166,7 @@ test, or publish-local as needed. For example:: Microkernel distribution -^^^^^^^^^^^^^^^^^^^^^^^^ +------------------------ To build the Akka Modules microkernel (the same as the Akka Modules distribution download) use the ``dist`` command:: @@ -169,9 +178,7 @@ The distribution zip can be found in the dist directory and is called To run the microkernel, unzip the zip file, change into the unzipped directory, set the ``AKKA_HOME`` environment variable, and run the main jar file. For -example: - -.. code-block:: none +example:: unzip dist/akka-modules-1.1-SNAPSHOT.zip cd akka-modules-1.1-SNAPSHOT @@ -184,10 +191,10 @@ into the ``deploy`` directory as well. Scripts -------- +======= Linux/Unix init script -^^^^^^^^^^^^^^^^^^^^^^ +---------------------- Here is a Linux/Unix init script that can be very useful: @@ -197,7 +204,7 @@ Copy and modify as needed. Simple startup shell script -^^^^^^^^^^^^^^^^^^^^^^^^^^^ +--------------------------- This little script might help a bit. Just make sure you have the Akka distribution in the '$AKKA_HOME/dist' directory and then invoke this script to @@ -210,131 +217,19 @@ Copy and modify as needed. Dependencies ------------- +============ -If you are managing dependencies by hand you can find out what all the compile -dependencies are for each module by looking in the ``lib_managed/compile`` -directories. For example, you can run this to create a listing of dependencies -(providing you have the source code and have run ``sbt update``):: +If you are managing dependencies by hand you can find the dependencies for each +module by looking in the ``lib_managed`` directories. For example, this will +list all compile dependencies (providing you have the source code and have run +``sbt update``):: cd akka ls -1 */lib_managed/compile - -Dependencies used by the Akka core modules ------------------------------------------- - -akka-actor -^^^^^^^^^^ - -* No dependencies - -akka-stm -^^^^^^^^ - -* Depends on akka-actor -* multiverse-alpha-0.6.2.jar - -akka-typed-actor -^^^^^^^^^^^^^^^^ - -* Depends on akka-stm -* aopalliance-1.0.jar -* aspectwerkz-2.2.3.jar -* guice-all-2.0.jar - -akka-remote -^^^^^^^^^^^ - -* Depends on akka-typed-actor -* commons-codec-1.4.jar -* commons-io-2.0.1.jar -* dispatch-json_2.8.1-0.7.8.jar -* guice-all-2.0.jar -* h2-lzf-1.0.jar -* jackson-core-asl-1.7.1.jar -* jackson-mapper-asl-1.7.1.jar -* junit-4.8.1.jar -* netty-3.2.3.Final.jar -* objenesis-1.2.jar -* protobuf-java-2.3.0.jar -* sjson_2.8.1-0.9.1.jar - -akka-http -^^^^^^^^^ - -* Depends on akka-remote -* jsr250-api-1.0.jar -* jsr311-api-1.1.jar - - -Dependencies used by the Akka modules -------------------------------------- - -akka-amqp -^^^^^^^^^ - -* Depends on akka-remote -* commons-cli-1.1.jar -* amqp-client-1.8.1.jar - -akka-camel -^^^^^^^^^^ - -* Depends on akka-actor -* camel-core-2.7.0.jar -* commons-logging-api-1.1.jar -* commons-management-1.0.jar - -akka-camel-typed -^^^^^^^^^^^^^^^^ - -* Depends on akka-typed-actor -* camel-core-2.7.0.jar -* commons-logging-api-1.1.jar -* commons-management-1.0.jar - -akka-spring -^^^^^^^^^^^ - -* Depends on akka-camel -* akka-camel-typed -* commons-logging-1.1.1.jar -* spring-aop-3.0.4.RELEASE.jar -* spring-asm-3.0.4.RELEASE.jar -* spring-beans-3.0.4.RELEASE.jar -* spring-context-3.0.4.RELEASE.jar -* spring-core-3.0.4.RELEASE.jar -* spring-expression-3.0.4.RELEASE.jar - -akka-scalaz -^^^^^^^^^^^ - -* Depends on akka-actor -* hawtdispatch-1.1.jar -* hawtdispatch-scala-1.1.jar -* scalaz-core_2.8.1-6.0-SNAPSHOT.jar - -akka-kernel -^^^^^^^^^^^ - -* Depends on akka-http, akka-amqp, and akka-spring -* activation-1.1.jar -* asm-3.1.jar -* jaxb-api-2.1.jar -* jaxb-impl-2.1.12.jar -* jersey-core-1.3.jar -* jersey-json-1.3.jar -* jersey-scala-1.3.jar -* jersey-server-1.3.jar -* jettison-1.1.jar -* jetty-continuation-7.1.6.v20100715.jar -* jetty-http-7.1.6.v20100715.jar -* jetty-io-7.1.6.v20100715.jar -* jetty-security-7.1.6.v20100715.jar -* jetty-server-7.1.6.v20100715.jar -* jetty-servlet-7.1.6.v20100715.jar -* jetty-util-7.1.6.v20100715.jar -* jetty-xml-7.1.6.v20100715.jar -* servlet-api-2.5.jar -* stax-api-1.0.1.jar +You can also look at the Ivy dependency resolution information that is created +on ``sbt update`` and found in ``~/.ivy2/cache``. For example, the +``.ivy2/cache/se.scalablesolutions.akka-akka-remote-compile.xml`` file contains +the resolution information for the akka-remote module compile dependencies. If +you open this file in a web browser you will get an easy to navigate view of +dependencies. From 2a4e9673538b8f6a9ef74b190f0309d63cda5545 Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Wed, 27 Apr 2011 09:37:14 +1200 Subject: [PATCH 039/112] Move building and configuration to general --- akka-docs/{intro => general}/building-akka.rst | 0 akka-docs/{intro => general}/configuration.rst | 0 akka-docs/general/index.rst | 2 ++ akka-docs/intro/index.rst | 2 -- 4 files changed, 2 insertions(+), 2 deletions(-) rename akka-docs/{intro => general}/building-akka.rst (100%) rename akka-docs/{intro => general}/configuration.rst (100%) diff --git a/akka-docs/intro/building-akka.rst b/akka-docs/general/building-akka.rst similarity index 100% rename from akka-docs/intro/building-akka.rst rename to akka-docs/general/building-akka.rst diff --git a/akka-docs/intro/configuration.rst b/akka-docs/general/configuration.rst similarity index 100% rename from akka-docs/intro/configuration.rst rename to akka-docs/general/configuration.rst diff --git a/akka-docs/general/index.rst b/akka-docs/general/index.rst index 81cee4fcf2..367e45b9d5 100644 --- a/akka-docs/general/index.rst +++ b/akka-docs/general/index.rst @@ -5,5 +5,7 @@ General :maxdepth: 2 migration-guides + building-akka + configuration event-handler util diff --git a/akka-docs/intro/index.rst b/akka-docs/intro/index.rst index 8df1a87a5d..6550f1bd79 100644 --- a/akka-docs/intro/index.rst +++ b/akka-docs/intro/index.rst @@ -8,5 +8,3 @@ Introduction getting-started-first-scala getting-started-first-scala-eclipse getting-started-first-java - building-akka - configuration From ad0b55ca7f297d8556a2a5b3a99bb70fc074a3ca Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Wed, 27 Apr 2011 10:04:18 +1200 Subject: [PATCH 040/112] Fix warnings in docs --- akka-docs/conf.py | 2 +- .../{intro => disabled}/examples/Pi.scala | 0 .../getting-started-first.rst | 7 ++++-- .../general/migration-guide-1.0.x-1.1.x.rst | 2 +- akka-docs/{intro => images}/build-path.png | Bin akka-docs/images/clojure-trees.png | Bin 0 -> 72431 bytes .../{intro => images}/diagnostics-window.png | Bin akka-docs/{intro => images}/example-code.png | Bin .../{intro => images}/import-project.png | Bin .../install-beta2-updatesite.png | Bin akka-docs/{intro => images}/pi-formula.png | Bin akka-docs/{intro => images}/quickfix.png | Bin akka-docs/{intro => images}/run-config.png | Bin .../intro/getting-started-first-java.rst | 7 ++++-- .../getting-started-first-scala-eclipse.rst | 21 ++++++++++-------- .../intro/getting-started-first-scala.rst | 7 ++++-- akka-docs/java/stm.rst | 2 +- akka-docs/scala/stm.rst | 2 +- akka-docs/scala/typed-actors.rst | 1 + 19 files changed, 32 insertions(+), 19 deletions(-) rename akka-docs/{intro => disabled}/examples/Pi.scala (100%) rename akka-docs/{intro => disabled}/getting-started-first.rst (98%) rename akka-docs/{intro => images}/build-path.png (100%) create mode 100644 akka-docs/images/clojure-trees.png rename akka-docs/{intro => images}/diagnostics-window.png (100%) rename akka-docs/{intro => images}/example-code.png (100%) rename akka-docs/{intro => images}/import-project.png (100%) rename akka-docs/{intro => images}/install-beta2-updatesite.png (100%) rename akka-docs/{intro => images}/pi-formula.png (100%) rename akka-docs/{intro => images}/quickfix.png (100%) rename akka-docs/{intro => images}/run-config.png (100%) diff --git a/akka-docs/conf.py b/akka-docs/conf.py index 209f747afc..712a3d10c8 100644 --- a/akka-docs/conf.py +++ b/akka-docs/conf.py @@ -13,7 +13,7 @@ extensions = ['sphinx.ext.todo', 'includecode'] templates_path = ['_templates'] source_suffix = '.rst' master_doc = 'index' -exclude_patterns = ['_build', 'pending'] +exclude_patterns = ['_build', 'pending', 'disabled'] project = u'Akka' copyright = u'2009-2011, Scalable Solutions AB' diff --git a/akka-docs/intro/examples/Pi.scala b/akka-docs/disabled/examples/Pi.scala similarity index 100% rename from akka-docs/intro/examples/Pi.scala rename to akka-docs/disabled/examples/Pi.scala diff --git a/akka-docs/intro/getting-started-first.rst b/akka-docs/disabled/getting-started-first.rst similarity index 98% rename from akka-docs/intro/getting-started-first.rst rename to akka-docs/disabled/getting-started-first.rst index 79c220d14a..63683a8c17 100644 --- a/akka-docs/intro/getting-started-first.rst +++ b/akka-docs/disabled/getting-started-first.rst @@ -19,14 +19,17 @@ We will be using an algorithm that is called "embarrassingly parallel" which jus Here is the formula for the algorithm we will use: -.. image:: pi-formula.png +.. image:: ../images/pi-formula.png In this particular algorithm the master splits the series into chunks which are sent out to each worker actor to be processed. When each worker has processed its chunk it sends a result back to the master which aggregates the total result. Tutorial source code -------------------- -If you want don't want to type in the code and/or set up an SBT project then you can check out the full tutorial from the Akka GitHub repository. It is in the ``akka-tutorials/akka-tutorial-first`` module. You can also browse it online `here `_, with the actual source code `here `_. +If you want don't want to type in the code and/or set up an SBT project then you can check out the full tutorial from the Akka GitHub repository. It is in the ``akka-tutorials/akka-tutorial-first`` module. You can also browse it online `here`__, with the actual source code `here`__. + +__ https://github.com/jboner/akka/tree/master/akka-tutorials/akka-tutorial-first +__ https://github.com/jboner/akka/blob/master/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala Prerequisites ------------- diff --git a/akka-docs/general/migration-guide-1.0.x-1.1.x.rst b/akka-docs/general/migration-guide-1.0.x-1.1.x.rst index 3fc555abaf..e9b27c5032 100644 --- a/akka-docs/general/migration-guide-1.0.x-1.1.x.rst +++ b/akka-docs/general/migration-guide-1.0.x-1.1.x.rst @@ -38,4 +38,4 @@ Akka Remote Akka Testkit ------------ -The TestKit moved into the akka-testkit subproject and correspondingly into the :code:`akka.testkit` package. +The TestKit moved into the akka-testkit subproject and correspondingly into the ``akka.testkit`` package. diff --git a/akka-docs/intro/build-path.png b/akka-docs/images/build-path.png similarity index 100% rename from akka-docs/intro/build-path.png rename to akka-docs/images/build-path.png diff --git a/akka-docs/images/clojure-trees.png b/akka-docs/images/clojure-trees.png new file mode 100644 index 0000000000000000000000000000000000000000..60127d52b2ef65420879616461dda0b0da5ac9d3 GIT binary patch literal 72431 zcmeAS@N?(olHy`uVBq!ia0y~yU}|7sU<~76V_;zT>7>)cz`(#*9OUlAuNSs54@I14-?iy0XB4ude`@%$Aj3=9mCC9V-A!TD(=<%vb93;~Im zc_n&&t|1C##(JiDhJMd2eljrpZ}4<+45^5FbC-RFPUu#%2hL)StVcVZ%qbT0^m1c8 zsUR5=5@5hSiK$ESXba=fH4jXaosRNc|1tZq>Fd4M=diBXf3G&?dETsfFJHY|^={V8 zRnK3hpPRXI-L2}k8}@x&yFpy^?p4nPlO5C>{g~#mSaFsJy-?Y(KxIRQ?yr| z8Dhs7X-<|MyT4wG=AIv&w{z)^pU-Arem?*IpY-JU747ryNxr{6@7*gEgXt<47!T|; ziHeQ3hB)hhDnkZiEW-`^e;@lFmGA!@`|;}fx~)6@{d(QqU-xD4%g+=0YnEK}-}8L( z{68rl56l1C@Z)v-|5*&_42M|lTw=dJ?_jZFuyAKvm7NB4=q?tfAAkS8uh;+g=efQ3 z`-wg@U?-JktcBycTA(y$iT@nCuGYSs&k2g3OMukU~aQi%}5KZET0pQqy| zo&H|?zB+#6B`XWw$by zKU!}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;as)4@as$dr%!dC0nb;< d57aY!oAplh{oy0C7#J8BJYD@<);T3K0RUockW2so literal 0 HcmV?d00001 diff --git a/akka-docs/intro/diagnostics-window.png b/akka-docs/images/diagnostics-window.png similarity index 100% rename from akka-docs/intro/diagnostics-window.png rename to akka-docs/images/diagnostics-window.png diff --git a/akka-docs/intro/example-code.png b/akka-docs/images/example-code.png similarity index 100% rename from akka-docs/intro/example-code.png rename to akka-docs/images/example-code.png diff --git a/akka-docs/intro/import-project.png b/akka-docs/images/import-project.png similarity index 100% rename from akka-docs/intro/import-project.png rename to akka-docs/images/import-project.png diff --git a/akka-docs/intro/install-beta2-updatesite.png b/akka-docs/images/install-beta2-updatesite.png similarity index 100% rename from akka-docs/intro/install-beta2-updatesite.png rename to akka-docs/images/install-beta2-updatesite.png diff --git a/akka-docs/intro/pi-formula.png b/akka-docs/images/pi-formula.png similarity index 100% rename from akka-docs/intro/pi-formula.png rename to akka-docs/images/pi-formula.png diff --git a/akka-docs/intro/quickfix.png b/akka-docs/images/quickfix.png similarity index 100% rename from akka-docs/intro/quickfix.png rename to akka-docs/images/quickfix.png diff --git a/akka-docs/intro/run-config.png b/akka-docs/images/run-config.png similarity index 100% rename from akka-docs/intro/run-config.png rename to akka-docs/images/run-config.png diff --git a/akka-docs/intro/getting-started-first-java.rst b/akka-docs/intro/getting-started-first-java.rst index 99db6f8c07..b907118f15 100644 --- a/akka-docs/intro/getting-started-first-java.rst +++ b/akka-docs/intro/getting-started-first-java.rst @@ -19,14 +19,17 @@ We will be using an algorithm that is called "embarrassingly parallel" which jus Here is the formula for the algorithm we will use: -.. image:: pi-formula.png +.. image:: ../images/pi-formula.png In this particular algorithm the master splits the series into chunks which are sent out to each worker actor to be processed. When each worker has processed its chunk it sends a result back to the master which aggregates the total result. Tutorial source code -------------------- -If you want don't want to type in the code and/or set up a Maven project then you can check out the full tutorial from the Akka GitHub repository. It is in the ``akka-tutorials/akka-tutorial-first`` module. You can also browse it online `here `_, with the actual source code `here `_. +If you want don't want to type in the code and/or set up a Maven project then you can check out the full tutorial from the Akka GitHub repository. It is in the ``akka-tutorials/akka-tutorial-first`` module. You can also browse it online `here`__, with the actual source code `here`__. + +__ https://github.com/jboner/akka/tree/master/akka-tutorials/akka-tutorial-first +__ https://github.com/jboner/akka/blob/master/akka-tutorials/akka-tutorial-first/src/main/java/akka/tutorial/first/java/Pi.java Prerequisites ------------- diff --git a/akka-docs/intro/getting-started-first-scala-eclipse.rst b/akka-docs/intro/getting-started-first-scala-eclipse.rst index 5c3987866a..5aaee1439d 100644 --- a/akka-docs/intro/getting-started-first-scala-eclipse.rst +++ b/akka-docs/intro/getting-started-first-scala-eclipse.rst @@ -12,14 +12,17 @@ We will be using an algorithm that is called "embarrassingly parallel" which jus Here is the formula for the algorithm we will use: -.. image:: pi-formula.png +.. image:: ../images/pi-formula.png In this particular algorithm the master splits the series into chunks which are sent out to each worker actor to be processed. When each worker has processed its chunk it sends a result back to the master which aggregates the total result. Tutorial source code -------------------- -If you want don't want to type in the code and/or set up an SBT project then you can check out the full tutorial from the Akka GitHub repository. It is in the ``akka-tutorials/akka-tutorial-first`` module. You can also browse it online `here `_, with the actual source code `here `_. +If you want don't want to type in the code and/or set up an SBT project then you can check out the full tutorial from the Akka GitHub repository. It is in the ``akka-tutorials/akka-tutorial-first`` module. You can also browse it online `here`__, with the actual source code `here`__. + +__ https://github.com/jboner/akka/tree/master/akka-tutorials/akka-tutorial-first +__ https://github.com/jboner/akka/blob/master/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala Prerequisites ------------- @@ -99,19 +102,19 @@ If you want to use Eclipse for coding your Akka tutorial, you need to install th You can install this plugin using the regular update mechanism. First choose a version of the IDE from `http://download.scala-ide.org `_. We recommend you choose 2.0.x, which comes with Scala 2.9. Copy the corresponding URL and then choose ``Help/Install New Software`` and paste the URL you just copied. You should see something similar to the following image. -.. image:: install-beta2-updatesite.png +.. image:: ../images/install-beta2-updatesite.png Make sure you select both the ``JDT Weaving for Scala`` and the ``Scala IDE for Eclipse`` plugins. The other plugin is optional, and contains the source code of the plugin itself. Once the installation is finished, you need to restart Eclipse. The first time the plugin starts it will open a diagnostics window and offer to fix several settings, such as the delay for content assist (code-completion) or the shown completion proposal types. -.. image:: diagnostics-window.png +.. image:: ../images/diagnostics-window.png Accept the recommended settings, and follow the instructions if you need to increase the heap size of Eclipse. Check that the installation succeeded by creating a new Scala project (``File/New>Scala Project``), and typing some code. You should have content-assist, hyperlinking to definitions, instant error reporting, and so on. -.. image:: example-code.png +.. image:: ../images/example-code.png You are ready to code now! @@ -140,7 +143,7 @@ Creating an Akka project in Eclipse If you have not already done so, now is the time to create an Eclipse project for our tutorial. Use the ``New Scala Project`` wizard and accept the default settings. Once the project is open, we need to add the akka libraries to the *build path*. Right click on the project and choose ``Properties``, then click on ``Java Build Path``. Go to ``Libraries`` and click on ``Add External Jars..``, then navigate to the location where you installed akka and choose ``akka-actor.jar``. You should see something similar to this: -.. image:: build-path.png +.. image:: ../images/build-path.png Using SBT in Eclipse ^^^^^^^^^^^^^^^^^^^^ @@ -186,7 +189,7 @@ Then run the ``eclipse`` target to generate the Eclipse project:: Next you need to import this project in Eclipse, by choosing ``Eclipse/Import.. Existing Projects into Workspace``. Navigate to the directory where you defined your SBT project and choose import: -.. image:: import-project.png +.. image:: ../images/import-project.png Now we have the basis for an Akka Eclipse application, so we can.. @@ -234,7 +237,7 @@ Now we can create the worker actor. Create a new class called ``Worker`` as bef The ``Actor`` trait is defined in ``akka.actor`` and you can either import it explicitly, or let Eclipse do it for you when it cannot resolve the ``Actor`` trait. The quick fix option (``Ctrl-F1``) will offer two options: -.. image:: quickfix.png +.. image:: ../images/quickfix.png Choose the Akka Actor and move on. @@ -403,7 +406,7 @@ If you have not defined an the ``AKKA_HOME`` environment variable then Akka can' You can also define a new Run configuration, by going to ``Run/Run Configurations``. Create a new ``Scala application`` and choose the tutorial project and the main class to be ``akkatutorial.Pi``. You can pass additional command line arguments to the JVM on the ``Arguments`` page, for instance to define where ``akka.conf`` is: -.. image:: run-config.png +.. image:: ../images/run-config.png Once you finished your run configuration, click ``Run``. You should see the same output in the ``Console`` window. You can use the same configuration for debugging the application, by choosing ``Run/Debug History`` or just ``Debug As``. diff --git a/akka-docs/intro/getting-started-first-scala.rst b/akka-docs/intro/getting-started-first-scala.rst index 364c0d276b..59d8fd5a82 100644 --- a/akka-docs/intro/getting-started-first-scala.rst +++ b/akka-docs/intro/getting-started-first-scala.rst @@ -19,14 +19,17 @@ We will be using an algorithm that is called "embarrassingly parallel" which jus Here is the formula for the algorithm we will use: -.. image:: pi-formula.png +.. image:: ../images/pi-formula.png In this particular algorithm the master splits the series into chunks which are sent out to each worker actor to be processed. When each worker has processed its chunk it sends a result back to the master which aggregates the total result. Tutorial source code -------------------- -If you want don't want to type in the code and/or set up an SBT project then you can check out the full tutorial from the Akka GitHub repository. It is in the ``akka-tutorials/akka-tutorial-first`` module. You can also browse it online `here `_, with the actual source code `here `_. +If you want don't want to type in the code and/or set up an SBT project then you can check out the full tutorial from the Akka GitHub repository. It is in the ``akka-tutorials/akka-tutorial-first`` module. You can also browse it online `here`__, with the actual source code `here`__. + +__ https://github.com/jboner/akka/tree/master/akka-tutorials/akka-tutorial-first +__ https://github.com/jboner/akka/blob/master/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala Prerequisites ------------- diff --git a/akka-docs/java/stm.rst b/akka-docs/java/stm.rst index 221c706183..dbc0da5d4a 100644 --- a/akka-docs/java/stm.rst +++ b/akka-docs/java/stm.rst @@ -524,7 +524,7 @@ They are immutable and each update creates a completely new version but they are This illustration is taken from Rich Hickey's presentation. Copyright Rich Hickey 2009. -.. image:: http://eclipsesource.com/blogs/wp-content/uploads/2009/12/clojure-trees.png +.. image:: ../images/clojure-trees.png JTA integration diff --git a/akka-docs/scala/stm.rst b/akka-docs/scala/stm.rst index 4917a7cd96..21b8d7b522 100644 --- a/akka-docs/scala/stm.rst +++ b/akka-docs/scala/stm.rst @@ -524,7 +524,7 @@ They are immutable and each update creates a completely new version but they are This illustration is taken from Rich Hickey's presentation. Copyright Rich Hickey 2009. -.. image:: http://eclipsesource.com/blogs/wp-content/uploads/2009/12/clojure-trees.png +.. image:: ../images/clojure-trees.png JTA integration diff --git a/akka-docs/scala/typed-actors.rst b/akka-docs/scala/typed-actors.rst index 7e5a327113..74c7f22f1f 100644 --- a/akka-docs/scala/typed-actors.rst +++ b/akka-docs/scala/typed-actors.rst @@ -70,6 +70,7 @@ Configuration factory class Using a configuration object: .. code-block:: scala + import akka.actor.TypedActorConfiguration import akka.util.Duration import akka.util.duration._ From fd46de15a642e0d02b0e60420d0ed8838e713a75 Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Wed, 27 Apr 2011 15:50:57 +1200 Subject: [PATCH 041/112] Remove akka modules build info --- akka-docs/general/building-akka.rst | 64 +---------------------------- 1 file changed, 1 insertion(+), 63 deletions(-) diff --git a/akka-docs/general/building-akka.rst b/akka-docs/general/building-akka.rst index 02765172d3..3ed3b151bc 100644 --- a/akka-docs/general/building-akka.rst +++ b/akka-docs/general/building-akka.rst @@ -151,69 +151,7 @@ testing, and publishing Akka to the local Ivy repository can be done with:: Building Akka Modules ===================== -To build Akka Modules first build and publish Akka to your local Ivy repository -as described above. Or using:: - - cd akka - sbt update publish-local - -Then you can build Akka Modules using the same steps as building Akka. First -update to get all dependencies (including the Akka core modules), then compile, -test, or publish-local as needed. For example:: - - cd akka-modules - sbt update publish-local - - -Microkernel distribution ------------------------- - -To build the Akka Modules microkernel (the same as the Akka Modules distribution -download) use the ``dist`` command:: - - sbt dist - -The distribution zip can be found in the dist directory and is called -``akka-modules-{version}.zip``. - -To run the microkernel, unzip the zip file, change into the unzipped directory, -set the ``AKKA_HOME`` environment variable, and run the main jar file. For -example:: - - unzip dist/akka-modules-1.1-SNAPSHOT.zip - cd akka-modules-1.1-SNAPSHOT - export AKKA_HOME=`pwd` - java -jar akka-modules-1.1-SNAPSHOT.jar - -The microkernel will boot up and install the sample applications that reside in -the distribution's ``deploy`` directory. You can deploy your own applications -into the ``deploy`` directory as well. - - -Scripts -======= - -Linux/Unix init script ----------------------- - -Here is a Linux/Unix init script that can be very useful: - -http://github.com/jboner/akka/blob/master/scripts/akka-init-script.sh - -Copy and modify as needed. - - -Simple startup shell script ---------------------------- - -This little script might help a bit. Just make sure you have the Akka -distribution in the '$AKKA_HOME/dist' directory and then invoke this script to -start up the kernel. The distribution is created in the './dist' dir for you if -you invoke 'sbt dist'. - -http://github.com/jboner/akka/blob/master/scripts/run_akka.sh - -Copy and modify as needed. +See the Akka Modules documentation. Dependencies From 7a33e9003d60d5612ddb07492de71b6399b89aad Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Wed, 27 Apr 2011 17:06:37 +1200 Subject: [PATCH 042/112] Remove microkernel dist stuff --- project/build/AkkaProject.scala | 131 +++++--------------------------- 1 file changed, 19 insertions(+), 112 deletions(-) diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index b3cb6dba6b..5a25f943d1 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -27,42 +27,6 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { override def compileOptions = super.compileOptions ++ scalaCompileSettings.map(CompileOption) override def javaCompileOptions = super.javaCompileOptions ++ javaCompileSettings.map(JavaCompileOption) - // ------------------------------------------------------------------------------------------------------------------- - // Deploy/dist settings - // ------------------------------------------------------------------------------------------------------------------- - val distName = "%s-%s".format(name, version) - val distArchiveName = distName + ".zip" - val deployPath = info.projectPath / "deploy" - val distPath = info.projectPath / "dist" - val distArchive = (distPath ##) / distArchiveName - - lazy override val `package` = task { None } - - //The distribution task, packages Akka into a zipfile and places it into the projectPath/dist directory - lazy val dist = task { - - def transferFile(from: Path, to: Path) = - if ( from.asFile.renameTo(to.asFile) ) None - else Some("Couldn't transfer %s to %s".format(from,to)) - - //Creates a temporary directory where we can assemble the distribution - val genDistDir = Path.fromFile({ - val d = File.createTempFile("akka","dist") - d.delete //delete the file - d.mkdir //Recreate it as a dir - d - }).## //## is needed to make sure that the zipped archive has the correct root folder - - //Temporary directory to hold the dist currently being generated - val currentDist = genDistDir / distName - - FileUtilities.copy(allArtifacts.get, currentDist, log).left.toOption orElse //Copy all needed artifacts into the root archive - FileUtilities.zip(List(currentDist), distArchiveName, true, log) orElse //Compress the root archive into a zipfile - transferFile(info.projectPath / distArchiveName, distArchive) orElse //Move the archive into the dist folder - FileUtilities.clean(genDistDir,log) //Cleanup the generated jars - - } dependsOn (`package`) describedAs("Zips up the distribution.") - // ------------------------------------------------------------------------------------------------------------------- // All repositories *must* go here! See ModuleConigurations below. // ------------------------------------------------------------------------------------------------------------------- @@ -197,14 +161,6 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { override def disableCrossPaths = true - override def packageOptions = - manifestClassPath.map(cp => ManifestAttributes( - (Attributes.Name.CLASS_PATH, cp), - (IMPLEMENTATION_TITLE, "Akka"), - (IMPLEMENTATION_URL, "http://akka.io"), - (IMPLEMENTATION_VENDOR, "Scalable Solutions AB") - )).toList - //Exclude slf4j1.5.11 from the classpath, it's conflicting... override def fullClasspath(config: Configuration): PathFinder = { super.fullClasspath(config) --- @@ -250,7 +206,7 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { override def deliverProjectDependencies = super.deliverProjectDependencies.toList - akka_samples.projectID - akka_tutorials.projectID - // ------------------------------------------------------------ + // ------------------------------------------------------------ // Build release // ------------------------------------------------------------ @@ -265,15 +221,13 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { publishTask(publishIvyModule, releaseConfiguration) dependsOn (deliver, publishLocal, makePom) } - lazy val buildRelease = task { - FileUtilities.copy(Seq(distArchive), localReleaseDownloads, log).left.toOption - } dependsOn (publishRelease, dist) + lazy val buildRelease = task { None } dependsOn publishRelease // ------------------------------------------------------------------------------------------------------------------- // akka-actor subproject // ------------------------------------------------------------------------------------------------------------------- - class AkkaActorProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with OsgiProject { + class AkkaActorProject(info: ProjectInfo) extends AkkaDefaultProject(info) with OsgiProject { override def bndExportPackage = super.bndExportPackage ++ Seq("com.eaio.*;version=3.2") } @@ -281,7 +235,7 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { // akka-stm subproject // ------------------------------------------------------------------------------------------------------------------- - class AkkaStmProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + class AkkaStmProject(info: ProjectInfo) extends AkkaDefaultProject(info) { val multiverse = Dependencies.multiverse // testing @@ -293,7 +247,7 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { // akka-typed-actor subproject // ------------------------------------------------------------------------------------------------------------------- - class AkkaTypedActorProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + class AkkaTypedActorProject(info: ProjectInfo) extends AkkaDefaultProject(info) { val aopalliance = Dependencies.aopalliance val aspectwerkz = Dependencies.aspectwerkz val guicey = Dependencies.guicey @@ -310,7 +264,7 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { // akka-remote subproject // ------------------------------------------------------------------------------------------------------------------- - class AkkaRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + class AkkaRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info) { val commons_codec = Dependencies.commons_codec val commons_io = Dependencies.commons_io val guicey = Dependencies.guicey @@ -337,7 +291,7 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { // akka-http subproject // ------------------------------------------------------------------------------------------------------------------- - class AkkaHttpProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + class AkkaHttpProject(info: ProjectInfo) extends AkkaDefaultProject(info) { val jsr250 = Dependencies.jsr250 val javax_servlet30 = Dependencies.javax_servlet_30 val jetty = Dependencies.jetty @@ -371,13 +325,13 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { } } - class AkkaSampleRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) + class AkkaSampleRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info) - class AkkaSampleChatProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) + class AkkaSampleChatProject(info: ProjectInfo) extends AkkaDefaultProject(info) - class AkkaSampleFSMProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) + class AkkaSampleFSMProject(info: ProjectInfo) extends AkkaDefaultProject(info) - class AkkaSampleOsgiProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) with BNDPlugin { + class AkkaSampleOsgiProject(info: ProjectInfo) extends AkkaDefaultProject(info) with BNDPlugin { val osgiCore = Dependencies.osgi_core override protected def bndPrivatePackage = List("sample.osgi.*") override protected def bndBundleActivator = Some("sample.osgi.Activator") @@ -407,9 +361,9 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { // Tutorials // ------------------------------------------------------------------------------------------------------------------- - class AkkaTutorialFirstProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) + class AkkaTutorialFirstProject(info: ProjectInfo) extends AkkaDefaultProject(info) - class AkkaTutorialSecondProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) + class AkkaTutorialSecondProject(info: ProjectInfo) extends AkkaDefaultProject(info) class AkkaTutorialsParentProject(info: ProjectInfo) extends ParentProject(info) { override def disableCrossPaths = true @@ -430,7 +384,7 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { // akka-testkit subproject // ------------------------------------------------------------------------------------------------------------------- - class AkkaTestkitProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + class AkkaTestkitProject(info: ProjectInfo) extends AkkaDefaultProject(info) { val scalatest = Dependencies.scalatest } @@ -438,52 +392,26 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { // akka-actor-tests subproject // ------------------------------------------------------------------------------------------------------------------- - class AkkaActorTestsProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + class AkkaActorTestsProject(info: ProjectInfo) extends AkkaDefaultProject(info) { // testing val junit = Dependencies.junit val scalatest = Dependencies.scalatest val multiverse_test = Dependencies.multiverse_test // StandardLatch } - + // ------------------------------------------------------------------------------------------------------------------- // akka-slf4j subproject // ------------------------------------------------------------------------------------------------------------------- - class AkkaSlf4jProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + class AkkaSlf4jProject(info: ProjectInfo) extends AkkaDefaultProject(info) { val slf4j = Dependencies.slf4j } // ------------------------------------------------------------------------------------------------------------------- - // Helpers + // Default project // ------------------------------------------------------------------------------------------------------------------- - def removeDupEntries(paths: PathFinder) = Path.lazyPathFinder { - val mapped = paths.get map { p => (p.relativePath, p) } - (Map() ++ mapped).values.toList - } - - def allArtifacts = { - Path.fromFile(buildScalaInstance.libraryJar) +++ - (removeDupEntries(runClasspath filter ClasspathUtilities.isArchive) +++ - ((outputPath ##) / defaultJarName) +++ - mainResources +++ - mainDependencies.scalaJars +++ - descendents(info.projectPath / "scripts", "run_akka.sh") +++ - descendents(info.projectPath / "scripts", "akka-init-script.sh") +++ - descendents(info.projectPath / "dist", "*.jar") +++ - descendents(info.projectPath / "deploy", "*.jar") +++ - descendents(path("lib") ##, "*.jar") +++ - descendents(configurationPath(Configurations.Compile) ##, "*.jar")) - .filter(jar => // remove redundant libs - !jar.toString.endsWith("stax-api-1.0.1.jar") || - !jar.toString.endsWith("scala-library-2.7.7.jar") - ) - } - - def akkaArtifacts = descendents(info.projectPath / "dist", "*-" + version + ".jar") - - // ------------------------------------------------------------ - class AkkaDefaultProject(info: ProjectInfo, val deployPath: Path) extends DefaultProject(info) with DeployProject with McPom { + class AkkaDefaultProject(info: ProjectInfo) extends DefaultProject(info) with McPom { override def disableCrossPaths = true @@ -515,27 +443,6 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { } } -trait DeployProject { self: BasicScalaProject => - // defines where the deployTask copies jars to - def deployPath: Path - - lazy val dist = deployTask(jarPath, packageDocsJar, packageSrcJar, deployPath, true, true, true) dependsOn( - `package`, packageDocs, packageSrc) describedAs("Deploying") - - def deployTask(jar: Path, docs: Path, src: Path, toDir: Path, - genJar: Boolean, genDocs: Boolean, genSource: Boolean) = task { - def gen(jar: Path, toDir: Path, flag: Boolean, msg: String): Option[String] = - if (flag) { - log.info(msg + " " + jar) - FileUtilities.copyFile(jar, toDir / jar.name, log) - } else None - - gen(jar, toDir, genJar, "Deploying bits") orElse - gen(docs, toDir, genDocs, "Deploying docs") orElse - gen(src, toDir, genSource, "Deploying sources") - } -} - trait OsgiProject extends BNDPlugin { self: DefaultProject => override def bndExportPackage = Seq("akka.*;version=%s".format(projectVersion.value)) } From 5068f0d48a3575d0f921d9d9ea46573a3c30a46b Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Wed, 27 Apr 2011 12:21:19 +0200 Subject: [PATCH 043/112] Removing blocking dequeues from MailboxConfig due to high risk and no gain --- .../akka/dispatch/MailboxConfigSpec.scala | 42 ++++++------------- .../dispatch/PriorityDispatcherSpec.scala | 4 +- .../ExecutorBasedEventDrivenDispatcher.scala | 26 +++++------- .../scala/akka/dispatch/MailboxHandling.scala | 38 ++++++----------- .../scala/akka/dispatch/MessageHandling.scala | 3 +- .../akka/dispatch/ThreadBasedDispatcher.scala | 6 +-- 6 files changed, 41 insertions(+), 78 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala index 9ddbfdc332..15d123867e 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala @@ -24,7 +24,7 @@ abstract class MailboxSpec extends name should { "create a !blockDequeue && unbounded mailbox" in { - val config = UnboundedMailbox(false) + val config = UnboundedMailbox() val q = factory(config) ensureInitialMailboxState(config, q) @@ -37,8 +37,8 @@ abstract class MailboxSpec extends f.await.resultOrException must be === Some(null) } - "create a !blockDequeue and bounded mailbox with 10 capacity and with push timeout" in { - val config = BoundedMailbox(false, 10, Duration(10,TimeUnit.MILLISECONDS)) + "create a bounded mailbox with 10 capacity and with push timeout" in { + val config = BoundedMailbox(10, Duration(10,TimeUnit.MILLISECONDS)) val q = factory(config) ensureInitialMailboxState(config, q) @@ -59,30 +59,16 @@ abstract class MailboxSpec extends } "dequeue what was enqueued properly for unbounded mailboxes" in { - testEnqueueDequeue(UnboundedMailbox(false)) + testEnqueueDequeue(UnboundedMailbox()) } "dequeue what was enqueued properly for bounded mailboxes" in { - testEnqueueDequeue(BoundedMailbox(false, 10000, Duration(-1, TimeUnit.MILLISECONDS))) + testEnqueueDequeue(BoundedMailbox(10000, Duration(-1, TimeUnit.MILLISECONDS))) } "dequeue what was enqueued properly for bounded mailboxes with pushTimeout" in { - testEnqueueDequeue(BoundedMailbox(false, 10000, Duration(100, TimeUnit.MILLISECONDS))) + testEnqueueDequeue(BoundedMailbox(10000, Duration(100, TimeUnit.MILLISECONDS))) } - - /** FIXME Adapt test so it works with the last dequeue - - "dequeue what was enqueued properly for unbounded mailboxes with blockDeque" in { - testEnqueueDequeue(UnboundedMailbox(true)) - } - - "dequeue what was enqueued properly for bounded mailboxes with blockDeque" in { - testEnqueueDequeue(BoundedMailbox(true, 1000, Duration(-1, TimeUnit.MILLISECONDS))) - } - - "dequeue what was enqueued properly for bounded mailboxes with blockDeque and pushTimeout" in { - testEnqueueDequeue(BoundedMailbox(true, 1000, Duration(100, TimeUnit.MILLISECONDS))) - }*/ } //CANDIDATE FOR TESTKIT @@ -111,8 +97,8 @@ abstract class MailboxSpec extends q match { case aQueue: BlockingQueue[_] => config match { - case BoundedMailbox(_,capacity,_) => aQueue.remainingCapacity must be === capacity - case UnboundedMailbox(_) => aQueue.remainingCapacity must be === Int.MaxValue + case BoundedMailbox(capacity,_) => aQueue.remainingCapacity must be === capacity + case UnboundedMailbox() => aQueue.remainingCapacity must be === Int.MaxValue } case _ => } @@ -165,10 +151,8 @@ abstract class MailboxSpec extends class DefaultMailboxSpec extends MailboxSpec { lazy val name = "The default mailbox implementation" def factory = { - case UnboundedMailbox(blockDequeue) => - new DefaultUnboundedMessageQueue(blockDequeue) - case BoundedMailbox(blocking, capacity, pushTimeOut) => - new DefaultBoundedMessageQueue(capacity, pushTimeOut, blocking) + case UnboundedMailbox() => new DefaultUnboundedMessageQueue() + case BoundedMailbox(capacity, pushTimeOut) => new DefaultBoundedMessageQueue(capacity, pushTimeOut) } } @@ -176,9 +160,7 @@ class PriorityMailboxSpec extends MailboxSpec { val comparator = PriorityGenerator(_.##) lazy val name = "The priority mailbox implementation" def factory = { - case UnboundedMailbox(blockDequeue) => - new UnboundedPriorityMessageQueue(blockDequeue, comparator) - case BoundedMailbox(blocking, capacity, pushTimeOut) => - new BoundedPriorityMessageQueue(capacity, pushTimeOut, blocking, comparator) + case UnboundedMailbox() => new UnboundedPriorityMessageQueue(comparator) + case BoundedMailbox(capacity, pushTimeOut) => new BoundedPriorityMessageQueue(capacity, pushTimeOut, comparator) } } \ No newline at end of file diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/PriorityDispatcherSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/PriorityDispatcherSpec.scala index f256715b8c..002267a6c7 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/PriorityDispatcherSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/PriorityDispatcherSpec.scala @@ -10,11 +10,11 @@ class PriorityDispatcherSpec extends WordSpec with MustMatchers { "A PriorityExecutorBasedEventDrivenDispatcher" must { "Order it's messages according to the specified comparator using an unbounded mailbox" in { - testOrdering(UnboundedMailbox(false)) + testOrdering(UnboundedMailbox()) } "Order it's messages according to the specified comparator using a bounded mailbox" in { - testOrdering(BoundedMailbox(false,1000)) + testOrdering(BoundedMailbox(1000)) } } diff --git a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala index 105028f693..494fa85f28 100644 --- a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala @@ -117,20 +117,14 @@ class ExecutorBasedEventDrivenDispatcher( def createMailbox(actorRef: ActorRef): AnyRef = mailboxType match { case b: UnboundedMailbox => - if (b.blocking) { - new DefaultUnboundedMessageQueue(true) with ExecutableMailbox { - final def dispatcher = ExecutorBasedEventDrivenDispatcher.this - } - } else { //If we have an unbounded, non-blocking mailbox, we can go lockless - new ConcurrentLinkedQueue[MessageInvocation] with MessageQueue with ExecutableMailbox { - final def dispatcher = ExecutorBasedEventDrivenDispatcher.this - final def enqueue(m: MessageInvocation) = this.add(m) - final def dequeue(): MessageInvocation = this.poll() - } + new ConcurrentLinkedQueue[MessageInvocation] with MessageQueue with ExecutableMailbox { + @inline final def dispatcher = ExecutorBasedEventDrivenDispatcher.this + @inline final def enqueue(m: MessageInvocation) = this.add(m) + @inline final def dequeue(): MessageInvocation = this.poll() } case b: BoundedMailbox => - new DefaultBoundedMessageQueue(b.capacity, b.pushTimeOut, b.blocking) with ExecutableMailbox { - final def dispatcher = ExecutorBasedEventDrivenDispatcher.this + new DefaultBoundedMessageQueue(b.capacity, b.pushTimeOut) with ExecutableMailbox { + @inline final def dispatcher = ExecutorBasedEventDrivenDispatcher.this } } @@ -294,13 +288,13 @@ trait PriorityMailbox { self: ExecutorBasedEventDrivenDispatcher => override def createMailbox(actorRef: ActorRef): AnyRef = self.mailboxType match { case b: UnboundedMailbox => - new UnboundedPriorityMessageQueue(b.blocking, comparator) with ExecutableMailbox { - final def dispatcher = self + new UnboundedPriorityMessageQueue(comparator) with ExecutableMailbox { + @inline final def dispatcher = self } case b: BoundedMailbox => - new BoundedPriorityMessageQueue(b.capacity, b.pushTimeOut, b.blocking, comparator) with ExecutableMailbox { - final def dispatcher = self + new BoundedPriorityMessageQueue(b.capacity, b.pushTimeOut, comparator) with ExecutableMailbox { + @inline final def dispatcher = self } } } diff --git a/akka-actor/src/main/scala/akka/dispatch/MailboxHandling.scala b/akka-actor/src/main/scala/akka/dispatch/MailboxHandling.scala index e0586a40a7..cacdefe95c 100644 --- a/akka-actor/src/main/scala/akka/dispatch/MailboxHandling.scala +++ b/akka-actor/src/main/scala/akka/dispatch/MailboxHandling.scala @@ -30,9 +30,8 @@ trait MessageQueue { */ sealed trait MailboxType -case class UnboundedMailbox(val blocking: Boolean = false) extends MailboxType +case class UnboundedMailbox() extends MailboxType case class BoundedMailbox( - val blocking: Boolean = false, val capacity: Int = { if (Dispatchers.MAILBOX_CAPACITY < 0) Int.MaxValue else Dispatchers.MAILBOX_CAPACITY }, val pushTimeOut: Duration = Dispatchers.MAILBOX_PUSH_TIME_OUT) extends MailboxType { if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedMailbox can not be negative") @@ -40,46 +39,35 @@ case class BoundedMailbox( } trait UnboundedMessageQueueSemantics extends MessageQueue { self: BlockingQueue[MessageInvocation] => - def blockDequeue: Boolean - - final def enqueue(handle: MessageInvocation) { - this add handle - } - - final def dequeue(): MessageInvocation = { - if (blockDequeue) this.take() - else this.poll() - } + @inline final def enqueue(handle: MessageInvocation): Unit = this add handle + @inline final def dequeue(): MessageInvocation = this.poll() } trait BoundedMessageQueueSemantics extends MessageQueue { self: BlockingQueue[MessageInvocation] => - def blockDequeue: Boolean def pushTimeOut: Duration final def enqueue(handle: MessageInvocation) { - if (pushTimeOut.length > 0 && pushTimeOut.toMillis > 0) { - if (!this.offer(handle, pushTimeOut.length, pushTimeOut.unit)) - throw new MessageQueueAppendFailedException("Couldn't enqueue message " + handle + " to " + toString) + if (pushTimeOut.length > 0) { + this.offer(handle, pushTimeOut.length, pushTimeOut.unit) || { + throw new MessageQueueAppendFailedException("Couldn't enqueue message " + handle + " to " + toString) } } else this put handle } - final def dequeue(): MessageInvocation = - if (blockDequeue) this.take() - else this.poll() + @inline final def dequeue(): MessageInvocation = this.poll() } -class DefaultUnboundedMessageQueue(val blockDequeue: Boolean) extends +class DefaultUnboundedMessageQueue extends LinkedBlockingQueue[MessageInvocation] with UnboundedMessageQueueSemantics -class DefaultBoundedMessageQueue(capacity: Int, val pushTimeOut: Duration, val blockDequeue: Boolean) extends +class DefaultBoundedMessageQueue(capacity: Int, val pushTimeOut: Duration) extends LinkedBlockingQueue[MessageInvocation](capacity) with BoundedMessageQueueSemantics -class UnboundedPriorityMessageQueue(val blockDequeue: Boolean, cmp: Comparator[MessageInvocation]) extends +class UnboundedPriorityMessageQueue(cmp: Comparator[MessageInvocation]) extends PriorityBlockingQueue[MessageInvocation](11, cmp) with UnboundedMessageQueueSemantics -class BoundedPriorityMessageQueue(capacity: Int, val pushTimeOut: Duration, val blockDequeue: Boolean, cmp: Comparator[MessageInvocation]) extends - BoundedBlockingQueue[MessageInvocation](capacity, new PriorityQueue[MessageInvocation](11, cmp)) with - BoundedMessageQueueSemantics +class BoundedPriorityMessageQueue(capacity: Int, val pushTimeOut: Duration, cmp: Comparator[MessageInvocation]) extends + BoundedBlockingQueue[MessageInvocation](capacity, new PriorityQueue[MessageInvocation](11, cmp)) with + BoundedMessageQueueSemantics diff --git a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala index 14348e9f85..9e53bb09ca 100644 --- a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala +++ b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala @@ -221,9 +221,8 @@ abstract class MessageDispatcherConfigurator { def mailboxType(config: Configuration): MailboxType = { val capacity = config.getInt("mailbox-capacity", Dispatchers.MAILBOX_CAPACITY) - // FIXME how do we read in isBlocking for mailbox? Now set to 'false'. if (capacity < 1) UnboundedMailbox() - else BoundedMailbox(false, capacity, Duration(config.getInt("mailbox-push-timeout-time", Dispatchers.MAILBOX_PUSH_TIME_OUT.toMillis.toInt), TIME_UNIT)) + else BoundedMailbox(capacity, Duration(config.getInt("mailbox-push-timeout-time", Dispatchers.MAILBOX_PUSH_TIME_OUT.toMillis.toInt), TIME_UNIT)) } def configureThreadPool(config: Configuration, createDispatcher: => (ThreadPoolConfig) => MessageDispatcher): ThreadPoolConfigDispatcherBuilder = { diff --git a/akka-actor/src/main/scala/akka/dispatch/ThreadBasedDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/ThreadBasedDispatcher.scala index a8dfcf5860..9ed0ce8ef1 100644 --- a/akka-actor/src/main/scala/akka/dispatch/ThreadBasedDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/ThreadBasedDispatcher.scala @@ -25,13 +25,13 @@ class ThreadBasedDispatcher(_actor: ActorRef, _mailboxType: MailboxType) private[akka] val owner = new AtomicReference[ActorRef](_actor) def this(actor: ActorRef) = - this(actor, UnboundedMailbox(true)) // For Java API + this(actor, UnboundedMailbox()) // For Java API def this(actor: ActorRef, capacity: Int) = - this(actor, BoundedMailbox(true, capacity)) //For Java API + this(actor, BoundedMailbox(capacity)) //For Java API def this(actor: ActorRef, capacity: Int, pushTimeOut: Duration) = //For Java API - this(actor, BoundedMailbox(true, capacity, pushTimeOut)) + this(actor, BoundedMailbox(capacity, pushTimeOut)) override def register(actorRef: ActorRef) = { val actor = owner.get() From 71a7a922738fa4691dd5ab0e30da2fbefbf233f7 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Wed, 27 Apr 2011 13:49:50 +0200 Subject: [PATCH 044/112] Removing the Client Managed Remote Actor sample from the docs and akka-sample-remote, fixing #804 --- akka-samples/akka-sample-remote/README | 34 +----------------- .../ClientManagedRemoteActorSample.scala | 35 ------------------- 2 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala diff --git a/akka-samples/akka-sample-remote/README b/akka-samples/akka-sample-remote/README index b20d1c7f4e..f19386e1e3 100644 --- a/akka-samples/akka-sample-remote/README +++ b/akka-samples/akka-sample-remote/README @@ -1,10 +1,5 @@ --------------------------------------------------------- == Akka Remote Sample Application == - -This sample has two different samples: - - Server Managed Remote Actors Sample - - Client Managed Remote Actors Sample - --------------------------------------------------------- = Server Managed Remote Actors Sample = @@ -29,31 +24,4 @@ To run the sample: Now you could test client reconnect by killing the console running the ServerManagedRemoteActorClient and start it up again. See the client reconnect take place in the REPL shell. -That’s it. Have fun. - ---------------------------------------------------------- -= Client Managed Remote Actors Sample = - -To run the sample: - -1. Fire up two shells. For each of them: - - Step down into to the root of the Akka distribution. - - Set 'export AKKA_HOME=. - - Run 'sbt' - - Run 'update' followed by 'compile' if you have not done that before. - - Run 'project akka-sample-remote' - - Run 'console' to start up a REPL (interpreter). -2. In the first REPL you get execute: - - scala> import sample.remote._ - - scala> ClientManagedRemoteActorServer.run - This starts up the RemoteNode and registers the remote actor -3. In the second REPL you get execute: - - scala> import sample.remote._ - - scala> ClientManagedRemoteActorClient.run -4. See the actor conversation. -5. Run it again to see full speed after first initialization. - -Now you could test client reconnect by killing the console running the ClientManagedRemoteActorClient and start it up again. See the client reconnect take place in the REPL shell. - -That’s it. Have fun. - +That’s it. Have fun. \ No newline at end of file diff --git a/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala b/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala deleted file mode 100644 index 42450b0b39..0000000000 --- a/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package sample.remote - -import akka.actor.Actor._ -import akka.actor. {ActorRegistry, Actor} -import Actor.remote - -class RemoteHelloWorldActor extends Actor { - def receive = { - case "Hello" => - self.reply("World") - } -} - -object ClientManagedRemoteActorServer { - def run = { - remote.start("localhost", 2552) - } - - def main(args: Array[String]) = run -} - -object ClientManagedRemoteActorClient { - - def run = { - val actor = remote.actorOf[RemoteHelloWorldActor]("localhost",2552).start() - val result = actor !! "Hello" - } - - def main(args: Array[String]) = run -} - From 82a11110d3416f13b8c59c648934063eb1e346fb Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Wed, 27 Apr 2011 15:34:42 +0200 Subject: [PATCH 045/112] Removing awaitValue and valueWithin, and adding await(atMost: Duration) --- .../test/scala/akka/dispatch/FutureSpec.scala | 20 ------ .../src/main/scala/akka/dispatch/Future.scala | 66 ++++++------------- 2 files changed, 21 insertions(+), 65 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index e12294a70d..bc60f7762f 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -277,26 +277,6 @@ class FutureSpec extends JUnitSuite { Futures.reduce(List[Future[Int]]())(_ + _).await.resultOrException } - @Test def resultWithinShouldNotThrowExceptions { - val latch = new StandardLatch - - val actors = (1 to 10).toList map { _ => - actorOf(new Actor { - def receive = { case (add: Int, wait: Boolean, latch: StandardLatch) => if (wait) latch.await; self reply_? add } - }).start() - } - - def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx >= 5, latch)) } - val result = for(f <- futures) yield f.valueWithin(2, TimeUnit.SECONDS) - latch.open - val done = result collect { case Some(Right(x)) => x } - val undone = result collect { case None => None } - val errors = result collect { case Some(Left(t)) => t } - assert(done.size === 5) - assert(undone.size === 5) - assert(errors.size === 0) - } - @Test def receiveShouldExecuteOnComplete { val latch = new StandardLatch val actor = actorOf[TestActor].start() diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 863d9c1283..a2d5a63697 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -7,13 +7,13 @@ package akka.dispatch import akka.AkkaException import akka.event.EventHandler import akka.actor.{Actor, Channel} -import akka.routing.Dispatcher +import akka.util.Duration import akka.japi.{ Procedure, Function => JFunc } import java.util.concurrent.locks.ReentrantLock import java.util.concurrent. {ConcurrentLinkedQueue, TimeUnit, Callable} import java.util.concurrent.TimeUnit.{NANOSECONDS => NANOS, MILLISECONDS => MILLIS} -import java.util.concurrent.atomic. {AtomicBoolean, AtomicInteger} +import java.util.concurrent.atomic. {AtomicBoolean} import java.lang.{Iterable => JIterable} import java.util.{LinkedList => JLinkedList} import annotation.tailrec @@ -298,11 +298,20 @@ sealed trait Future[+T] { */ def await : Future[T] + /** + * Blocks the current thread until the Future has been completed or the + * timeout has expired. The timeout will be the least value of 'atMost' and the timeout + * supplied at the constructuion of this Future. + * In the case of the timeout expiring a FutureTimeoutException will be thrown. + */ + def await(atMost: Duration) : Future[T] + /** * Blocks the current thread until the Future has been completed. Use * caution with this method as it ignores the timeout and will block * indefinitely if the Future is never completed. */ + @deprecated("Will be removed after 1.1, it's dangerous and can cause deadlocks, agony and insanity.") def awaitBlocking : Future[T] /** @@ -340,24 +349,6 @@ sealed trait Future[+T] { else None } - /** - * Waits for the completion of this Future, then returns the completed value. - * If the Future's timeout expires while waiting a FutureTimeoutException - * will be thrown. - * - * Equivalent to calling future.await.value. - */ - def awaitValue: Option[Either[Throwable, T]] - - /** - * Returns the result of the Future if one is available within the specified - * time, if the time left on the future is less than the specified time, the - * time left on the future will be used instead of the specified time. - * returns None if no result, Some(Right(t)) if a result, or - * Some(Left(error)) if there was an exception - */ - def valueWithin(time: Long, unit: TimeUnit): Option[Either[Throwable, T]] - /** * Returns the contained exception of this Future if it exists. */ @@ -620,39 +611,25 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com * Must be called inside _lock.lock<->_lock.unlock */ @tailrec - private def awaitUnsafe(wait: Long): Boolean = { - if (_value.isEmpty && wait > 0) { + private def awaitUnsafe(waitTimeNanos: Long): Boolean = { + if (_value.isEmpty && waitTimeNanos > 0) { val start = currentTimeInNanos - val remaining = try { - _signal.awaitNanos(wait) + val remainingNanos = try { + _signal.awaitNanos(waitTimeNanos) } catch { case e: InterruptedException => - wait - (currentTimeInNanos - start) + waitTimeNanos - (currentTimeInNanos - start) } - awaitUnsafe(remaining) + awaitUnsafe(remainingNanos) } else { _value.isDefined } } - def awaitValue: Option[Either[Throwable, T]] = { + def await(atMost: Duration) = { _lock.lock - try { - awaitUnsafe(timeLeft()) - _value - } finally { - _lock.unlock - } - } - - def valueWithin(time: Long, unit: TimeUnit): Option[Either[Throwable, T]] = { - _lock.lock - try { - awaitUnsafe(unit toNanos time min timeLeft()) - _value - } finally { - _lock.unlock - } + if (try { awaitUnsafe(atMost.toNanos min timeLeft()) } finally { _lock.unlock }) this + else throw new FutureTimeoutException("Futures timed out after [" + NANOS.toMillis(timeoutInNanos) + "] milliseconds") } def await = { @@ -741,8 +718,7 @@ sealed class AlreadyCompletedFuture[T](suppliedValue: Either[Throwable, T]) exte def complete(value: Either[Throwable, T]): CompletableFuture[T] = this def onComplete(func: Future[T] => Unit): Future[T] = { func(this); this } - def awaitValue: Option[Either[Throwable, T]] = value - def valueWithin(time: Long, unit: TimeUnit): Option[Either[Throwable, T]] = value + def await(atMost: Duration): Future[T] = this def await : Future[T] = this def awaitBlocking : Future[T] = this def isExpired: Boolean = true From 2da27123ac417a730f0042232ec99fd442e19a1b Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Wed, 27 Apr 2011 16:46:06 +0200 Subject: [PATCH 046/112] Renaming a test --- .../src/test/scala/akka/dispatch/MailboxConfigSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala index 15d123867e..0da861350d 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/MailboxConfigSpec.scala @@ -23,7 +23,7 @@ abstract class MailboxSpec extends def factory: MailboxType => MessageQueue name should { - "create a !blockDequeue && unbounded mailbox" in { + "create an unbounded mailbox" in { val config = UnboundedMailbox() val q = factory(config) ensureInitialMailboxState(config, q) From 800840719f54e67ce25e59ff7fc691ff6055e478 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Wed, 27 Apr 2011 16:52:19 +0200 Subject: [PATCH 047/112] Making it impossible to complete a future after it`s expired, and not run onComplete callbacks if it hasn`t been completed before expiry, fixing ticket #811 --- .../src/test/scala/akka/dispatch/FutureSpec.scala | 14 ++++++++++++++ .../src/main/scala/akka/dispatch/Future.scala | 8 +++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index bc60f7762f..7ec397025e 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -343,6 +343,20 @@ class FutureSpec extends JUnitSuite { } } + @Test def shouldNotAddOrRunCallbacksAfterFailureToBeCompletedBeforeExpiry { + val latch = new StandardLatch + val f = new DefaultCompletableFuture[Int](0) + Thread.sleep(25) + f.onComplete( _ => latch.open ) //Shouldn't throw any exception here + + assert(f.isExpired) //Should be expired + + f.complete(Right(1)) //Shouldn't complete the Future since it is expired + + assert(f.value.isEmpty) //Shouldn't be completed + assert(!latch.isOpen) //Shouldn't run the listener + } + @Test def lesslessIsMore { import akka.actor.Actor.spawn val dataflowVar, dataflowVar2 = new DefaultCompletableFuture[Int](Long.MaxValue) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index a2d5a63697..1f2c8d63e4 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -664,7 +664,7 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com def complete(value: Either[Throwable, T]): DefaultCompletableFuture[T] = { _lock.lock val notifyTheseListeners = try { - if (_value.isEmpty) { + if (_value.isEmpty && !isExpired) { //Only complete if we aren't expired _value = Some(value) val existingListeners = _listeners _listeners = Nil @@ -685,8 +685,10 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com _lock.lock val notifyNow = try { if (_value.isEmpty) { - _listeners ::= func - false + if(!isExpired) { //Only add the listener if the future isn't expired + _listeners ::= func + false + } else false //Will never run the callback since the future is expired } else true } finally { _lock.unlock From 7224abd532ea6179dc509175052bbde0659c307f Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Wed, 27 Apr 2011 17:35:50 +0200 Subject: [PATCH 048/112] Fixing the docs for the Actor Pool with regards to the factory vs instance question and closing ticket #744 --- akka-docs/pending/routing-scala.rst | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/akka-docs/pending/routing-scala.rst b/akka-docs/pending/routing-scala.rst index 4cb825219e..3885290ccb 100644 --- a/akka-docs/pending/routing-scala.rst +++ b/akka-docs/pending/routing-scala.rst @@ -219,18 +219,16 @@ Examples with SmallestMailboxSelector with BasicNoBackoffFilter { - def factory = actorOf(new Actor {def receive = {case n:Int => - Thread.sleep(n) - counter.incrementAndGet - latch.countDown()}}) - + def receive = _route def lowerBound = 2 def upperBound = 4 def rampupRate = 0.1 def partialFill = true def selectionCount = 1 - def instance = factory - def receive = _route + def instance = actorOf(new Actor {def receive = {case n:Int => + Thread.sleep(n) + counter.incrementAndGet + latch.countDown()}}) } .. code-block:: scala @@ -243,11 +241,7 @@ Examples with RunningMeanBackoff with BasicRampup { - - def factory = actorOf(new Actor {def receive = {case n:Int => - Thread.sleep(n) - latch.countDown()}}) - + def receive = _route def lowerBound = 1 def upperBound = 5 def pressureThreshold = 1 @@ -256,8 +250,9 @@ Examples def rampupRate = 0.1 def backoffRate = 0.50 def backoffThreshold = 0.50 - def instance = factory - def receive = _route + def instance = actorOf(new Actor {def receive = {case n:Int => + Thread.sleep(n) + latch.countDown()}}) } Taken from the unit test `spec `_. From 9fadbc4980398dedfa83991823c697568dda69c1 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Wed, 27 Apr 2011 20:12:23 +0200 Subject: [PATCH 049/112] Moved transactors from pending --- akka-docs/java/index.rst | 1 + akka-docs/{pending/transactors-java.rst => java/transactors.rst} | 0 akka-docs/scala/index.rst | 1 + .../{pending/transactors-scala.rst => scala/transactors.rst} | 0 4 files changed, 2 insertions(+) rename akka-docs/{pending/transactors-java.rst => java/transactors.rst} (100%) rename akka-docs/{pending/transactors-scala.rst => scala/transactors.rst} (100%) diff --git a/akka-docs/java/index.rst b/akka-docs/java/index.rst index d4fed805d4..aeef671960 100644 --- a/akka-docs/java/index.rst +++ b/akka-docs/java/index.rst @@ -8,4 +8,5 @@ Java API typed-actors actor-registry stm + transactors dispatchers diff --git a/akka-docs/pending/transactors-java.rst b/akka-docs/java/transactors.rst similarity index 100% rename from akka-docs/pending/transactors-java.rst rename to akka-docs/java/transactors.rst diff --git a/akka-docs/scala/index.rst b/akka-docs/scala/index.rst index 8897cfc17b..71c399709d 100644 --- a/akka-docs/scala/index.rst +++ b/akka-docs/scala/index.rst @@ -9,6 +9,7 @@ Scala API actor-registry agents stm + transactors dispatchers fsm testing diff --git a/akka-docs/pending/transactors-scala.rst b/akka-docs/scala/transactors.rst similarity index 100% rename from akka-docs/pending/transactors-scala.rst rename to akka-docs/scala/transactors.rst From 43ebe61ab2f13a7a476890fd0e94cb9159d1b89a Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Wed, 27 Apr 2011 21:30:35 +0200 Subject: [PATCH 050/112] Reviewed and improved transactors doc --- akka-docs/java/transactors.rst | 76 +++++++++++++++++---------------- akka-docs/scala/transactors.rst | 64 ++++++++++++++------------- 2 files changed, 74 insertions(+), 66 deletions(-) diff --git a/akka-docs/java/transactors.rst b/akka-docs/java/transactors.rst index 9cc4d522f4..2d17bd2fa6 100644 --- a/akka-docs/java/transactors.rst +++ b/akka-docs/java/transactors.rst @@ -1,10 +1,14 @@ -**Transactors (Java)** -============================================================ +Transactors (Java) +================== + +.. sidebar:: Contents + + .. contents:: :local: Module stability: **SOLID** Why Transactors? -================ +---------------- Actors are excellent for solving problems where you have many independent processes that can work in isolation and only interact with other Actors through message passing. This model fits many problems. But the actor model is unfortunately a terrible model for implementing truly shared state. E.g. when you need to have consensus and a stable view of state across many components. The classic example is the bank account where clients can deposit and withdraw, in which each operation needs to be atomic. For detailed discussion on the topic see `this JavaOne presentation `_. @@ -15,21 +19,21 @@ Akka's Transactors combine Actors and STM to provide the best of the Actor model If you need Durability then you should not use one of the in-memory data structures but one of the persistent ones. Generally, the STM is not needed very often when working with Akka. Some use-cases (that we can think of) are: -# When you really need composable message flows across many actors updating their **internal local** state but need them to do that atomically in one big transaction. Might not often, but when you do need this then you are screwed without it. -# When you want to share a datastructure across actors. -# When you need to use the persistence modules. + +- When you really need composable message flows across many actors updating their **internal local** state but need them to do that atomically in one big transaction. Might not often, but when you do need this then you are screwed without it. +- When you want to share a datastructure across actors. +- When you need to use the persistence modules. Actors and STM --------------- +^^^^^^^^^^^^^^ You can combine Actors and STM in several ways. An Actor may use STM internally so that particular changes are guaranteed to be atomic. Actors may also share transactional datastructures as the STM provides safe shared state across threads. It's also possible to coordinate transactions across Actors or threads so that either the transactions in a set all commit successfully or they all fail. This is the focus of Transactors and the explicit support for coordinated transactions in this section. ----- Coordinated transactions -======================== +------------------------ Akka provides an explicit mechanism for coordinating transactions across actors. Under the hood it uses a ``CountDownCommitBarrier``, similar to a CountDownLatch. @@ -40,9 +44,11 @@ Here is an example of coordinating two simple counter UntypedActors so that they import akka.actor.ActorRef; public class Increment { - private ActorRef friend = null; + private final ActorRef friend; - public Increment() {} + public Increment() { + this.friend = null; + } public Increment(ActorRef friend) { this.friend = friend; @@ -59,9 +65,7 @@ Here is an example of coordinating two simple counter UntypedActors so that they .. code-block:: java - import akka.actor.ActorRef; import akka.actor.UntypedActor; - import static akka.actor.Actors.*; import akka.stm.Ref; import akka.transactor.Atomically; import akka.transactor.Coordinated; @@ -88,11 +92,8 @@ Here is an example of coordinating two simple counter UntypedActors so that they } }); } - } else if (incoming instanceof String) { - String message = (String) incoming; - if (message.equals("GetCount")) { - getContext().replyUnsafe(count.get()); - } + } else if (incoming.equals("GetCount")) { + getContext().replyUnsafe(count.get()); } } } @@ -104,7 +105,7 @@ Here is an example of coordinating two simple counter UntypedActors so that they counter1.sendOneWay(new Coordinated(new Increment(counter2))); -To start a new coordinated transaction set that you will also participate in, just create a ``Coordinated`` object: +To start a new coordinated transaction that you will also participate in, just create a ``Coordinated`` object: .. code-block:: java @@ -116,7 +117,7 @@ To start a coordinated transaction that you won't participate in yourself you ca actor.sendOneWay(new Coordinated(new Message())); -To include another actor in the same coordinated transaction set that you've created or received, use the ``coordinate`` method on that object. This will increment the number of parties involved by one and create a new ``Coordinated`` object to be sent. +To include another actor in the same coordinated transaction that you've created or received, use the ``coordinate`` method on that object. This will increment the number of parties involved by one and create a new ``Coordinated`` object to be sent. .. code-block:: java @@ -134,10 +135,9 @@ To enter the coordinated transaction use the atomic method of the coordinated ob The coordinated transaction will wait for the other transactions before committing. If any of the coordinated transactions fail then they all fail. ----- UntypedTransactor -================= +----------------- UntypedTransactors are untyped actors that provide a general pattern for coordinating transactions, using the explicit coordination described above. @@ -146,10 +146,12 @@ Here's an example of a simple untyped transactor that will join a coordinated tr .. code-block:: java import akka.transactor.UntypedTransactor; + import akka.stm.Ref; public class Counter extends UntypedTransactor { Ref count = new Ref(0); + @Override public void atomically(Object message) { if (message instanceof Increment) { count.set(count.get() + 1); @@ -174,7 +176,8 @@ Example of coordinating an increment, similar to the explicitly coordinated exam public class Counter extends UntypedTransactor { Ref count = new Ref(0); - @Override public Set coordinate(Object message) { + @Override + public Set coordinate(Object message) { if (message instanceof Increment) { Increment increment = (Increment) message; if (increment.hasFriend()) @@ -183,6 +186,7 @@ Example of coordinating an increment, similar to the explicitly coordinated exam return nobody(); } + @Override public void atomically(Object message) { if (message instanceof Increment) { count.set(count.get() + 1); @@ -190,14 +194,13 @@ Example of coordinating an increment, similar to the explicitly coordinated exam } } -To execute directly before or after the coordinated transaction, override the ``before`` and ``after`` methods. These methods also expect partial functions like the receive method. They do not execute within the transaction. +To execute directly before or after the coordinated transaction, override the ``before`` and ``after`` methods. They do not execute within the transaction. To completely bypass coordinated transactions override the ``normally`` method. Any message matched by ``normally`` will not be matched by the other methods, and will not be involved in coordinated transactions. In this method you can implement normal actor behavior, or use the normal STM atomic for local transactions. ----- Coordinating Typed Actors -========================= +------------------------- It's also possible to use coordinated transactions with typed actors. You can explicitly pass around ``Coordinated`` objects, or use built-in support with the ``@Coordinated`` annotation and the ``Coordination.coordinate`` method. @@ -249,17 +252,18 @@ Here's an example of using ``@Coordinated`` with a TypedActor to coordinate incr } } -``_ -Counter counter1 = (Counter) TypedActor.newInstance(Counter.class, CounterImpl.class); -Counter counter2 = (Counter) TypedActor.newInstance(Counter.class, CounterImpl.class); +.. code-block:: java -Coordination.coordinate(true, new Atomically() { + Counter counter1 = (Counter) TypedActor.newInstance(Counter.class, CounterImpl.class); + Counter counter2 = (Counter) TypedActor.newInstance(Counter.class, CounterImpl.class); + + Coordination.coordinate(true, new Atomically() { public void atomically() { - counter1.increment(); - counter2.increment(); + counter1.increment(); + counter2.increment(); } -}); + }); + + TypedActor.stop(counter1); + TypedActor.stop(counter2); -TypedActor.stop(counter1); -TypedActor.stop(counter2); -``_ diff --git a/akka-docs/scala/transactors.rst b/akka-docs/scala/transactors.rst index 6ee4126f0a..da26b4b527 100644 --- a/akka-docs/scala/transactors.rst +++ b/akka-docs/scala/transactors.rst @@ -1,10 +1,14 @@ -**Transactors (Scala)** -============================================================= +Transactors (Scala) +=================== + +.. sidebar:: Contents + + .. contents:: :local: Module stability: **SOLID** Why Transactors? -================ +---------------- Actors are excellent for solving problems where you have many independent processes that can work in isolation and only interact with other Actors through message passing. This model fits many problems. But the actor model is unfortunately a terrible model for implementing truly shared state. E.g. when you need to have consensus and a stable view of state across many components. The classic example is the bank account where clients can deposit and withdraw, in which each operation needs to be atomic. For detailed discussion on the topic see `this JavaOne presentation `_. @@ -15,21 +19,21 @@ Akka's Transactors combine Actors and STM to provide the best of the Actor model If you need Durability then you should not use one of the in-memory data structures but one of the persistent ones. Generally, the STM is not needed very often when working with Akka. Some use-cases (that we can think of) are: -# When you really need composable message flows across many actors updating their **internal local** state but need them to do that atomically in one big transaction. Might not often, but when you do need this then you are screwed without it. -# When you want to share a datastructure across actors. -# When you need to use the persistence modules. + +- When you really need composable message flows across many actors updating their **internal local** state but need them to do that atomically in one big transaction. Might not often, but when you do need this then you are screwed without it. +- When you want to share a datastructure across actors. +- When you need to use the persistence modules. Actors and STM --------------- +^^^^^^^^^^^^^^ You can combine Actors and STM in several ways. An Actor may use STM internally so that particular changes are guaranteed to be atomic. Actors may also share transactional datastructures as the STM provides safe shared state across threads. It's also possible to coordinate transactions across Actors or threads so that either the transactions in a set all commit successfully or they all fail. This is the focus of Transactors and the explicit support for coordinated transactions in this section. ----- Coordinated transactions -======================== +------------------------ Akka provides an explicit mechanism for coordinating transactions across Actors. Under the hood it uses a ``CountDownCommitBarrier``, similar to a CountDownLatch. @@ -70,7 +74,7 @@ Here is an example of coordinating two simple counter Actors so that they both i counter1.stop() counter2.stop() -To start a new coordinated transaction set that you will also participate in, just create a ``Coordinated`` object: +To start a new coordinated transaction that you will also participate in, just create a ``Coordinated`` object: .. code-block:: scala @@ -90,7 +94,7 @@ To receive a coordinated message in an actor simply match it in a case statement case coordinated @ Coordinated(Message) => ... } -To include another actor in the same coordinated transaction set that you've created or received, use the apply method on that object. This will increment the number of parties involved by one and create a new ``Coordinated`` object to be sent. +To include another actor in the same coordinated transaction that you've created or received, use the apply method on that object. This will increment the number of parties involved by one and create a new ``Coordinated`` object to be sent. .. code-block:: scala @@ -106,10 +110,9 @@ To enter the coordinated transaction use the atomic method of the coordinated ob The coordinated transaction will wait for the other transactions before committing. If any of the coordinated transactions fail then they all fail. ----- Transactor -========== +---------- Transactors are actors that provide a general pattern for coordinating transactions, using the explicit coordination described above. @@ -125,7 +128,7 @@ Here's an example of a simple transactor that will join a coordinated transactio class Counter extends Transactor { val count = Ref(0) - def atomically = { + override def atomically = { case Increment => count alter (_ + 1) } } @@ -140,6 +143,7 @@ Example of coordinating an increment: import akka.transactor.Transactor import akka.stm.Ref + import akka.actor.ActorRef case object Increment @@ -150,7 +154,7 @@ Example of coordinating an increment: case Increment => include(friend) } - def atomically = { + override def atomically = { case Increment => count alter (_ + 1) } } @@ -176,10 +180,9 @@ To execute directly before or after the coordinated transaction, override the `` To completely bypass coordinated transactions override the ``normally`` method. Any message matched by ``normally`` will not be matched by the other methods, and will not be involved in coordinated transactions. In this method you can implement normal actor behavior, or use the normal STM atomic for local transactions. ----- Coordinating Typed Actors -========================= +------------------------- It's also possible to use coordinated transactions with typed actors. You can explicitly pass around ``Coordinated`` objects, or use built-in support with the ``@Coordinated`` annotation and the ``Coordination.coordinate`` method. @@ -188,7 +191,7 @@ To specify a method should use coordinated transactions add the ``@Coordinated`` .. code-block:: scala trait Counter { - @Coordinated def increment: Unit + @Coordinated def increment() def get: Int } @@ -197,8 +200,8 @@ To coordinate transactions use a ``coordinate`` block: .. code-block:: scala coordinate { - counter1.increment - counter2.increment + counter1.increment() + counter2.increment() } Here's an example of using ``@Coordinated`` with a TypedActor to coordinate increments. @@ -211,13 +214,13 @@ Here's an example of using ``@Coordinated`` with a TypedActor to coordinate incr import akka.transactor.Coordination._ trait Counter { - @Coordinated def increment: Unit + @Coordinated def increment() def get: Int } class CounterImpl extends TypedActor with Counter { val ref = Ref(0) - def increment = ref alter (_ + 1) + def increment() { ref alter (_ + 1) } def get = ref.get } @@ -227,8 +230,8 @@ Here's an example of using ``@Coordinated`` with a TypedActor to coordinate incr val counter2 = TypedActor.newInstance(classOf[Counter], classOf[CounterImpl]) coordinate { - counter1.increment - counter2.increment + counter1.increment() + counter2.increment() } TypedActor.stop(counter1) @@ -236,9 +239,10 @@ Here's an example of using ``@Coordinated`` with a TypedActor to coordinate incr The ``coordinate`` block will wait for the transactions to complete. If you do not want to wait then you can specify this explicitly: -``_ -coordinate(wait = false) { - counter1.increment - counter2.increment -} -``_ +.. code-block:: scala + + coordinate(wait = false) { + counter1.increment() + counter2.increment() + } + From 43fc3bf463a23ef7d942de9b57c1658d49e07db2 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Wed, 27 Apr 2011 19:39:15 -0600 Subject: [PATCH 051/112] Add failing test for Ticket #812 --- .../src/test/scala/akka/dispatch/FutureSpec.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 7ec397025e..d848eede53 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -375,4 +375,14 @@ class FutureSpec extends JUnitSuite { assert(dataflowVar2() === 5) assert(dataflowVar.get === 5) } + + @Test def ticket812FutureDispatchCleanup { + val dispatcher = implicitly[MessageDispatcher] + assert(dispatcher.futureQueueSize === 0) + val future = Future({Thread.sleep(100);"Done"}, 10) + intercept[FutureTimeoutException] { future.await } + assert(dispatcher.futureQueueSize === 1) + Thread.sleep(200) + assert(dispatcher.futureQueueSize === 0) + } } From 485013a353d952ddeb4fb294a6929a2ab53c33f0 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Wed, 27 Apr 2011 20:45:39 -0600 Subject: [PATCH 052/112] Dispatcher executed Future will be cleaned up even after expiring --- .../test/scala/akka/dispatch/FutureSpec.scala | 14 ++-- .../ExecutorBasedEventDrivenDispatcher.scala | 2 +- .../src/main/scala/akka/dispatch/Future.scala | 7 +- .../scala/akka/dispatch/MessageHandling.scala | 71 ++++++++++--------- .../testkit/CallingThreadDispatcher.scala | 2 +- 5 files changed, 49 insertions(+), 47 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index d848eede53..1f7dae9270 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -324,7 +324,7 @@ class FutureSpec extends JUnitSuite { assert(f3.resultOrException === Some("SUCCESS")) // make sure all futures are completed in dispatcher - assert(Dispatchers.defaultGlobalDispatcher.futureQueueSize === 0) + assert(Dispatchers.defaultGlobalDispatcher.pendingFutures === 0) } @Test def shouldBlockUntilResult { @@ -341,6 +341,10 @@ class FutureSpec extends JUnitSuite { intercept[FutureTimeoutException] { f3() } + Thread.sleep(100) + + // make sure all futures are completed in dispatcher + assert(Dispatchers.defaultGlobalDispatcher.pendingFutures === 0) } @Test def shouldNotAddOrRunCallbacksAfterFailureToBeCompletedBeforeExpiry { @@ -378,11 +382,11 @@ class FutureSpec extends JUnitSuite { @Test def ticket812FutureDispatchCleanup { val dispatcher = implicitly[MessageDispatcher] - assert(dispatcher.futureQueueSize === 0) + assert(dispatcher.pendingFutures === 0) val future = Future({Thread.sleep(100);"Done"}, 10) intercept[FutureTimeoutException] { future.await } - assert(dispatcher.futureQueueSize === 1) - Thread.sleep(200) - assert(dispatcher.futureQueueSize === 0) + assert(dispatcher.pendingFutures === 1) + Thread.sleep(100) + assert(dispatcher.pendingFutures === 0) } } diff --git a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala index 494fa85f28..dca2f2f822 100644 --- a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala @@ -99,7 +99,7 @@ class ExecutorBasedEventDrivenDispatcher( registerForExecution(mbox) } - private[akka] def executeFuture(invocation: FutureInvocation): Unit = if (active.isOn) { + private[akka] def executeFuture(invocation: FutureInvocation[_]): Unit = if (active.isOn) { try executorService.get() execute invocation catch { case e: RejectedExecutionException => diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 1f2c8d63e4..72cab081a2 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -232,11 +232,8 @@ object Future { * This method constructs and returns a Future that will eventually hold the result of the execution of the supplied body * The execution is performed by the specified Dispatcher. */ - def apply[T](body: => T, timeout: Long = Actor.TIMEOUT)(implicit dispatcher: MessageDispatcher): Future[T] = { - val f = new DefaultCompletableFuture[T](timeout) - dispatcher.dispatchFuture(FutureInvocation(f.asInstanceOf[CompletableFuture[Any]], () => body)) - f - } + def apply[T](body: => T, timeout: Long = Actor.TIMEOUT)(implicit dispatcher: MessageDispatcher): Future[T] = + dispatcher.dispatchFuture(() => body, timeout) /** * Construct a completable channel diff --git a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala index 9e53bb09ca..8261a0f485 100644 --- a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala +++ b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala @@ -5,6 +5,7 @@ package akka.dispatch import java.util.concurrent._ +import java.util.concurrent.atomic.AtomicLong import akka.event.EventHandler import akka.config.Configuration import akka.config.Config.TIME_UNIT @@ -29,16 +30,18 @@ final case class MessageInvocation(val receiver: ActorRef, } } -final case class FutureInvocation(future: CompletableFuture[Any], function: () => Any) extends Runnable { - val uuid = akka.actor.newUuid - - def run = future complete (try { - Right(function.apply) - } catch { - case e => - EventHandler.error(e, this, e.getMessage) - Left(e) - }) +final case class FutureInvocation[T](future: CompletableFuture[T], function: () => T, cleanup: () => Unit) extends Runnable { + def run = { + future complete (try { + Right(function()) + } catch { + case e => + EventHandler.error(e, this, e.getMessage) + Left(e) + } finally { + cleanup() + }) + } } object MessageDispatcher { @@ -56,7 +59,7 @@ trait MessageDispatcher { import MessageDispatcher._ protected val uuids = new ConcurrentSkipListSet[Uuid] - protected val futures = new ConcurrentSkipListSet[Uuid] + protected val futures = new AtomicLong(0L) protected val guard = new ReentrantGuard protected val active = new Switch(false) @@ -83,27 +86,25 @@ trait MessageDispatcher { private[akka] final def dispatchMessage(invocation: MessageInvocation): Unit = dispatch(invocation) - private[akka] final def dispatchFuture(invocation: FutureInvocation): Unit = { - guard withGuard { - futures add invocation.uuid - if (active.isOff) { active.switchOn { start } } - } - invocation.future.onComplete { f => - guard withGuard { - futures remove invocation.uuid - if (futures.isEmpty && uuids.isEmpty) { - shutdownSchedule match { - case UNSCHEDULED => - shutdownSchedule = SCHEDULED - Scheduler.scheduleOnce(shutdownAction, timeoutMs, TimeUnit.MILLISECONDS) - case SCHEDULED => - shutdownSchedule = RESCHEDULED - case RESCHEDULED => //Already marked for reschedule - } - } + private[akka] final def dispatchFuture[T](block: () => T, timeout: Long): Future[T] = { + futures.getAndIncrement() + val future = new DefaultCompletableFuture[T](timeout) + if (active.isOff) { active.switchOn { start } } + executeFuture(FutureInvocation[T](future, block, futureCleanup)) + future + } + + private val futureCleanup: () => Unit = { () => + if (futures.decrementAndGet() == 0 && uuids.isEmpty) { + shutdownSchedule match { + case UNSCHEDULED => + shutdownSchedule = SCHEDULED + Scheduler.scheduleOnce(shutdownAction, timeoutMs, TimeUnit.MILLISECONDS) + case SCHEDULED => + shutdownSchedule = RESCHEDULED + case RESCHEDULED => //Already marked for reschedule } } - executeFuture(invocation) } private[akka] def register(actorRef: ActorRef) { @@ -121,7 +122,7 @@ trait MessageDispatcher { private[akka] def unregister(actorRef: ActorRef) = { if (uuids remove actorRef.uuid) { actorRef.mailbox = null - if (uuids.isEmpty && futures.isEmpty){ + if (uuids.isEmpty && futures.get == 0){ shutdownSchedule match { case UNSCHEDULED => shutdownSchedule = SCHEDULED @@ -155,7 +156,7 @@ trait MessageDispatcher { shutdownSchedule = SCHEDULED Scheduler.scheduleOnce(this, timeoutMs, TimeUnit.MILLISECONDS) case SCHEDULED => - if (uuids.isEmpty() && futures.isEmpty) { + if (uuids.isEmpty() && futures.get == 0) { active switchOff { shutdown // shut down in the dispatcher's references is zero } @@ -187,7 +188,7 @@ trait MessageDispatcher { */ private[akka] def dispatch(invocation: MessageInvocation): Unit - private[akka] def executeFuture(invocation: FutureInvocation): Unit + private[akka] def executeFuture(invocation: FutureInvocation[_]): Unit /** * Called one time every time an actor is attached to this dispatcher and this dispatcher was previously shutdown @@ -205,9 +206,9 @@ trait MessageDispatcher { def mailboxSize(actorRef: ActorRef): Int /** - * Returns the size of the Future queue + * Returns the amount of futures queued for execution */ - def futureQueueSize: Int = futures.size + def pendingFutures: Long = futures.get } /** diff --git a/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala b/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala index 971ee2e89f..dcf20158d8 100644 --- a/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala +++ b/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala @@ -156,7 +156,7 @@ class CallingThreadDispatcher(val warnings: Boolean = true) extends MessageDispa if (execute) runQueue(mbox, queue) } - private[akka] override def executeFuture(invocation: FutureInvocation) { invocation.run } + private[akka] override def executeFuture(invocation: FutureInvocation[_]) { invocation.run } /* * This method must be called with this thread's queue, which must already From 65e553a4dfa67a7f5f508423e74d5c698fd17579 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Thu, 28 Apr 2011 08:19:04 +0200 Subject: [PATCH 053/112] Added sample to Transactional Agents --- akka-docs/scala/agents.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/akka-docs/scala/agents.rst b/akka-docs/scala/agents.rst index 1e9ea128a3..dc62000995 100644 --- a/akka-docs/scala/agents.rst +++ b/akka-docs/scala/agents.rst @@ -92,6 +92,29 @@ Transactional Agents If an Agent is used within an enclosing transaction, then it will participate in that transaction. If you send to an Agent within a transaction then the dispatch to the Agent will be held until that transaction commits, and discarded if the transaction is aborted. +.. code-block:: scala + + import akka.agent.Agent + import akka.stm._ + + def transfer(from: Agent[Int], to: Agent[Int], amount: Int): Boolean = { + atomic { + if (from.get < amount) false + else { + from send (_ - amount) + to send (_ + amount) + true + } + } + } + + val from = Agent(100) + val to = Agent(20) + val ok = transfer(from, to, 50) + + from() // -> 50 + to() // -> 70 + Monadic usage ------------- From c61f1a42dc8b2113d4be76014ea37cff104cf029 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Thu, 28 Apr 2011 07:47:51 -0600 Subject: [PATCH 054/112] make sure lock is aquired when accessing shutdownSchedule --- akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala index 8261a0f485..e63a72f366 100644 --- a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala +++ b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala @@ -95,7 +95,7 @@ trait MessageDispatcher { } private val futureCleanup: () => Unit = { () => - if (futures.decrementAndGet() == 0 && uuids.isEmpty) { + if (futures.decrementAndGet() == 0) guard withGuard { if (uuids.isEmpty) { shutdownSchedule match { case UNSCHEDULED => shutdownSchedule = SCHEDULED @@ -104,7 +104,7 @@ trait MessageDispatcher { shutdownSchedule = RESCHEDULED case RESCHEDULED => //Already marked for reschedule } - } + }} } private[akka] def register(actorRef: ActorRef) { From 4bedb4813d9950ebcedf098b2417213c804c0bbb Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Thu, 28 Apr 2011 16:01:11 +0200 Subject: [PATCH 055/112] Fixing tickets #816, #814, #817 and Dereks fixes on #812 --- .../scala/akka/dispatch/ActorModelSpec.scala | 16 +++++++ .../scala/akka/dispatch/MessageHandling.scala | 42 ++++++++++++------- .../main/scala/akka/security/Security.scala | 2 +- .../src/test/scala/config/ConfigSpec.scala | 2 +- config/akka-reference.conf | 4 +- 5 files changed, 47 insertions(+), 19 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/ActorModelSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/ActorModelSpec.scala index 4e60ffcc96..2ee4d8a2f7 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/ActorModelSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/ActorModelSpec.scala @@ -14,6 +14,7 @@ import java.util.concurrent.atomic.AtomicLong import java.util.concurrent. {ConcurrentHashMap, CountDownLatch, TimeUnit} import akka.actor.dispatch.ActorModelSpec.MessageDispatcherInterceptor import akka.util.{Duration, Switch} +import org.multiverse.api.latches.StandardLatch object ActorModelSpec { @@ -216,6 +217,21 @@ abstract class ActorModelSpec extends JUnitSuite { msgsProcessed = 0, restarts = 0 ) + + val futures = for(i <- 1 to 10) yield Future { i } + await(dispatcher.stops.get == 2)(withinMs = dispatcher.timeoutMs * 5) + assertDispatcher(dispatcher)(starts = 2, stops = 2) + + val a2 = newTestActor + a2.start + val futures2 = for(i <- 1 to 10) yield Future { i } + + await(dispatcher.starts.get == 3)(withinMs = dispatcher.timeoutMs * 5) + assertDispatcher(dispatcher)(starts = 3, stops = 2) + + a2.stop + await(dispatcher.stops.get == 3)(withinMs = dispatcher.timeoutMs * 5) + assertDispatcher(dispatcher)(starts = 3, stops = 3) } @Test def dispatcherShouldProcessMessagesOneAtATime { diff --git a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala index e63a72f366..d9017edc29 100644 --- a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala +++ b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala @@ -88,24 +88,36 @@ trait MessageDispatcher { private[akka] final def dispatchFuture[T](block: () => T, timeout: Long): Future[T] = { futures.getAndIncrement() - val future = new DefaultCompletableFuture[T](timeout) - if (active.isOff) { active.switchOn { start } } - executeFuture(FutureInvocation[T](future, block, futureCleanup)) - future + try { + val future = new DefaultCompletableFuture[T](timeout) + + if (active.isOff) + guard withGuard { if (active.isOff) active.switchOn { start } } + + executeFuture(FutureInvocation[T](future, block, futureCleanup)) + future + } catch { + case e => + futures.decrementAndGet + throw e + } } - private val futureCleanup: () => Unit = { () => - if (futures.decrementAndGet() == 0) guard withGuard { if (uuids.isEmpty) { - shutdownSchedule match { - case UNSCHEDULED => - shutdownSchedule = SCHEDULED - Scheduler.scheduleOnce(shutdownAction, timeoutMs, TimeUnit.MILLISECONDS) - case SCHEDULED => - shutdownSchedule = RESCHEDULED - case RESCHEDULED => //Already marked for reschedule + private val futureCleanup: () => Unit = + () => if (futures.decrementAndGet() == 0) { + guard withGuard { + if (futures.get == 0 && uuids.isEmpty) { + shutdownSchedule match { + case UNSCHEDULED => + shutdownSchedule = SCHEDULED + Scheduler.scheduleOnce(shutdownAction, timeoutMs, TimeUnit.MILLISECONDS) + case SCHEDULED => + shutdownSchedule = RESCHEDULED + case RESCHEDULED => //Already marked for reschedule + } + } } - }} - } + } private[akka] def register(actorRef: ActorRef) { if (actorRef.mailbox eq null) diff --git a/akka-http/src/main/scala/akka/security/Security.scala b/akka-http/src/main/scala/akka/security/Security.scala index dce249de46..7789164fd3 100644 --- a/akka-http/src/main/scala/akka/security/Security.scala +++ b/akka-http/src/main/scala/akka/security/Security.scala @@ -182,7 +182,7 @@ trait AuthenticationActor[C <: Credentials] extends Actor { * Responsible for the execution flow of authentication * * Credentials are extracted and verified from the request, - * and a se3curity context is created for the ContainerRequest + * and a security context is created for the ContainerRequest * this should ensure good integration with current Jersey security */ protected val authenticate: Receive = { diff --git a/akka-http/src/test/scala/config/ConfigSpec.scala b/akka-http/src/test/scala/config/ConfigSpec.scala index 3adea2fc43..2b21f3cc34 100644 --- a/akka-http/src/test/scala/config/ConfigSpec.scala +++ b/akka-http/src/test/scala/config/ConfigSpec.scala @@ -19,7 +19,7 @@ class ConfigSpec extends WordSpec with MustMatchers { getString("akka.http.authenticator") must equal(Some("N/A")) getBool("akka.http.connection-close") must equal(Some(true)) getString("akka.http.expired-header-name") must equal(Some("Async-Timeout")) - getList("akka.http.filters") must equal(List("se.scalablesolutions.akka.security.AkkaSecurityFilterFactory")) + getList("akka.http.filters") must equal(List("akka.security.AkkaSecurityFilterFactory")) getList("akka.http.resource-packages") must equal(Nil) getString("akka.http.hostname") must equal(Some("localhost")) getString("akka.http.expired-header-value") must equal(Some("expired")) diff --git a/config/akka-reference.conf b/config/akka-reference.conf index df2c2c3e0d..9a647c6ad5 100644 --- a/config/akka-reference.conf +++ b/config/akka-reference.conf @@ -85,7 +85,7 @@ akka { port = 9998 #If you are using akka.http.AkkaRestServlet - filters = ["se.scalablesolutions.akka.security.AkkaSecurityFilterFactory"] # List with all jersey filters to use + filters = ["akka.security.AkkaSecurityFilterFactory"] # List with all jersey filters to use # resource-packages = ["sample.rest.scala", # "sample.rest.java", # "sample.security"] # List with all resource packages for your Jersey services @@ -123,7 +123,7 @@ akka { remote { - # secure-cookie = "050E0A0D0D06010A00000900040D060F0C09060B" # generate your own with '$AKKA_HOME/scripts/generate_secure_cookie.sh' or using 'Crypt.generateSecureCookie' + # secure-cookie = "050E0A0D0D06010A00000900040D060F0C09060B" # generate your own with '$AKKA_HOME/scripts/generate_config_with_secure_cookie.sh' or using 'Crypt.generateSecureCookie' secure-cookie = "" compression-scheme = "zlib" # Options: "zlib" (lzf to come), leave out for no compression From baa12988f9174c79126c5990f099a9ff6dd8047b Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Thu, 28 Apr 2011 16:03:21 +0200 Subject: [PATCH 056/112] Fixing ticket #813 --- .../META-INF/services/javax.ws.rs.ext.MessageBodyWriter_FIXME | 1 - 1 file changed, 1 deletion(-) delete mode 100644 akka-http/src/main/resources/META-INF/services/javax.ws.rs.ext.MessageBodyWriter_FIXME diff --git a/akka-http/src/main/resources/META-INF/services/javax.ws.rs.ext.MessageBodyWriter_FIXME b/akka-http/src/main/resources/META-INF/services/javax.ws.rs.ext.MessageBodyWriter_FIXME deleted file mode 100644 index 51bc8cccd2..0000000000 --- a/akka-http/src/main/resources/META-INF/services/javax.ws.rs.ext.MessageBodyWriter_FIXME +++ /dev/null @@ -1 +0,0 @@ -se.scalablesolutions.akka.rest.ListWriter From 7d5bc131635fdbf8a761aabed010ebeff8e200ff Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Thu, 28 Apr 2011 16:23:03 +0200 Subject: [PATCH 057/112] Removing uses of awaitBlocking in the FutureSpec --- .../test/scala/akka/dispatch/FutureSpec.scala | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 1f7dae9270..2e5381b334 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -215,8 +215,9 @@ class FutureSpec extends JUnitSuite { def receive = { case (add: Int, wait: Int) => Thread.sleep(wait); self reply_? add } }).start() } - def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 )) } - assert(Futures.fold(0)(futures)(_ + _).awaitBlocking.result.get === 45) + val timeout = 10000 + def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 ), timeout) } + assert(Futures.fold(0, timeout)(futures)(_ + _).await.result.get === 45) } @Test def shouldFoldResultsByComposing { @@ -225,8 +226,8 @@ class FutureSpec extends JUnitSuite { def receive = { case (add: Int, wait: Int) => Thread.sleep(wait); self reply_? add } }).start() } - def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 )) } - assert(futures.foldLeft(Future(0))((fr, fa) => for (r <- fr; a <- fa) yield (r + a)).awaitBlocking.result.get === 45) + def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 ), 10000) } + assert(futures.foldLeft(Future(0))((fr, fa) => for (r <- fr; a <- fa) yield (r + a)).get === 45) } @Test def shouldFoldResultsWithException { @@ -240,12 +241,13 @@ class FutureSpec extends JUnitSuite { } }).start() } - def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 100 )) } - assert(Futures.fold(0)(futures)(_ + _).awaitBlocking.exception.get.getMessage === "shouldFoldResultsWithException: expected") + val timeout = 10000 + def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 100 ), timeout) } + assert(Futures.fold(0, timeout)(futures)(_ + _).await.exception.get.getMessage === "shouldFoldResultsWithException: expected") } @Test def shouldFoldReturnZeroOnEmptyInput { - assert(Futures.fold(0)(List[Future[Int]]())(_ + _).awaitBlocking.result.get === 0) + assert(Futures.fold(0)(List[Future[Int]]())(_ + _).get === 0) } @Test def shouldReduceResults { @@ -254,8 +256,9 @@ class FutureSpec extends JUnitSuite { def receive = { case (add: Int, wait: Int) => Thread.sleep(wait); self reply_? add } }).start() } - def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 )) } - assert(Futures.reduce(futures)(_ + _).awaitBlocking.result.get === 45) + val timeout = 10000 + def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 200 ), timeout) } + assert(Futures.reduce(futures, timeout)(_ + _).get === 45) } @Test def shouldReduceResultsWithException { @@ -269,8 +272,9 @@ class FutureSpec extends JUnitSuite { } }).start() } - def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 100 )) } - assert(Futures.reduce(futures)(_ + _).awaitBlocking.exception.get.getMessage === "shouldFoldResultsWithException: expected") + val timeout = 10000 + def futures = actors.zipWithIndex map { case (actor: ActorRef, idx: Int) => actor.!!![Int]((idx, idx * 100 ), timeout) } + assert(Futures.reduce(futures, timeout)(_ + _).await.exception.get.getMessage === "shouldFoldResultsWithException: expected") } @Test(expected = classOf[UnsupportedOperationException]) def shouldReduceThrowIAEOnEmptyInput { From 9a582b7c49e675340998adc10d0b76d67de97131 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Thu, 28 Apr 2011 18:05:28 +0200 Subject: [PATCH 058/112] Removing redundant isOff call --- akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala index d9017edc29..cfe69e33f3 100644 --- a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala +++ b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala @@ -92,7 +92,7 @@ trait MessageDispatcher { val future = new DefaultCompletableFuture[T](timeout) if (active.isOff) - guard withGuard { if (active.isOff) active.switchOn { start } } + guard withGuard { active.switchOn { start } } executeFuture(FutureInvocation[T](future, block, futureCleanup)) future From 241a21aaa0368f8f64638dd272bebe89c8e5a775 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Thu, 28 Apr 2011 22:42:17 +0200 Subject: [PATCH 059/112] Cross linking --- akka-docs/intro/getting-started-first-scala-eclipse.rst | 2 ++ akka-docs/java/stm.rst | 2 +- akka-docs/java/transactors.rst | 2 ++ akka-docs/scala/stm.rst | 2 +- akka-docs/scala/transactors.rst | 2 ++ 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/akka-docs/intro/getting-started-first-scala-eclipse.rst b/akka-docs/intro/getting-started-first-scala-eclipse.rst index 5aaee1439d..b4380490ef 100644 --- a/akka-docs/intro/getting-started-first-scala-eclipse.rst +++ b/akka-docs/intro/getting-started-first-scala-eclipse.rst @@ -1,3 +1,5 @@ +.. _getting-started-first-scala-eclipse: + Getting Started Tutorial (Scala with Eclipse): First Chapter ============================================================ diff --git a/akka-docs/java/stm.rst b/akka-docs/java/stm.rst index dbc0da5d4a..ed44218804 100644 --- a/akka-docs/java/stm.rst +++ b/akka-docs/java/stm.rst @@ -141,7 +141,7 @@ It can happen for the first few executions that you get a few failures of execut Coordinated transactions and Transactors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -If you need coordinated transactions across actors or threads then see `Transactors `_. +If you need coordinated transactions across actors or threads then see :ref:`transactors-java`. Configuring transactions ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/akka-docs/java/transactors.rst b/akka-docs/java/transactors.rst index 2d17bd2fa6..b724ef89b6 100644 --- a/akka-docs/java/transactors.rst +++ b/akka-docs/java/transactors.rst @@ -1,3 +1,5 @@ +.. _transactors-java: + Transactors (Java) ================== diff --git a/akka-docs/scala/stm.rst b/akka-docs/scala/stm.rst index 21b8d7b522..42cd67ce2c 100644 --- a/akka-docs/scala/stm.rst +++ b/akka-docs/scala/stm.rst @@ -206,7 +206,7 @@ It can happen for the first few executions that you get a few failures of execut Coordinated transactions and Transactors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -If you need coordinated transactions across actors or threads then see `Transactors `_. +If you need coordinated transactions across actors or threads then see :ref:`transactors-scala`. Configuring transactions ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/akka-docs/scala/transactors.rst b/akka-docs/scala/transactors.rst index da26b4b527..e4ee824cd3 100644 --- a/akka-docs/scala/transactors.rst +++ b/akka-docs/scala/transactors.rst @@ -1,3 +1,5 @@ +.. _transactors-scala: + Transactors (Scala) =================== From 390176b64dd56d002c4feb4cb910bae37fbfd8a1 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Thu, 28 Apr 2011 22:43:11 +0200 Subject: [PATCH 060/112] Added sbt reload before initial update --- akka-docs/intro/getting-started-first-scala.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/akka-docs/intro/getting-started-first-scala.rst b/akka-docs/intro/getting-started-first-scala.rst index 59d8fd5a82..867b6fe3f4 100644 --- a/akka-docs/intro/getting-started-first-scala.rst +++ b/akka-docs/intro/getting-started-first-scala.rst @@ -176,8 +176,11 @@ Not needed in this tutorial, but if you would like to use additional Akka module So, now we are all set. Just one final thing to do; make SBT download the dependencies it needs. That is done by invoking:: + > reload > update +The first reload command is needed because we have changed the project definition since the sbt session started. + SBT itself needs a whole bunch of dependencies but our project will only need one; ``akka-actor-1.1.jar``. SBT downloads that as well. Start writing the code From 2451d4a8d3b76896e92033fd205dcbfb5194b69e Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Thu, 28 Apr 2011 22:43:56 +0200 Subject: [PATCH 061/112] Added instructions for SBT project and IDE --- akka-docs/scala/tutorial-chat-server.rst | 47 ++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/akka-docs/scala/tutorial-chat-server.rst b/akka-docs/scala/tutorial-chat-server.rst index 4a10af9a45..73f66cc394 100644 --- a/akka-docs/scala/tutorial-chat-server.rst +++ b/akka-docs/scala/tutorial-chat-server.rst @@ -1,4 +1,4 @@ -Tutorial: write a scalable, fault-tolerant, persistent network chat server and client (Scala) +Tutorial: write a scalable, fault-tolerant, network chat server and client (Scala) ============================================================================================= .. sidebar:: Contents @@ -87,12 +87,53 @@ We will try to write a simple chat/IM system. It is client-server based and uses We will use many of the features of Akka along the way. In particular; Actors, fault-tolerance using Actor supervision, remote Actors, Software Transactional Memory (STM) and persistence. -But let's start by defining the messages that will flow in our system. +Creating an Akka SBT project +---------------------------- + +First we need to create an SBT project for our tutorial. You do that by stepping into the directory you want to create your project in and invoking the ``sbt`` command answering the questions for setting up your project:: + + $ sbt + Project does not exist, create new project? (y/N/s) y + Name: Chat + Organization: Hakkers Inc + Version [1.0]: + Scala version [2.9.0.RC1]: + sbt version [0.7.6.RC0]: + +Add the Akka SBT plugin definition to your SBT project by creating a ``Plugins.scala`` file in the ``project/plugins`` directory containing:: + + import sbt._ + + class Plugins(info: ProjectInfo) extends PluginDefinition(info) { + val akkaRepo = "Akka Repo" at "http://akka.io/repository" + val akkaPlugin = "se.scalablesolutions.akka" % "akka-sbt-plugin" % "1.1-M1" + } + +Create a project definition ``project/build/Project.scala`` file containing:: + + import sbt._ + + class ChatProject(info: ProjectInfo) extends DefaultProject(info) with AkkaProject { + val akkaRepo = "Akka Repo" at "http://akka.io/repository" + val akkaSTM = akkaModule("stm") + val akkaRemote = akkaModule("remote") + } + + +Make SBT download the dependencies it needs. That is done by invoking:: + + > reload + > update + +From the SBT project you can generate files for your IDE: + +- `SbtEclipsify `_ to generate the Eclipse project. Detailed instructions are available in :ref:`getting-started-first-scala-eclipse`. +- `sbt-idea `_ to generate the Eclipse project Creating messages ----------------- -It is very important that all messages that will be sent around in the system are immutable. The Actor model relies on the simple fact that no state is shared between Actors and the only way to guarantee that is to make sure we don't pass mutable state around as part of the messages. +Let's start by defining the messages that will flow in our system. It is very important that all messages that will be sent around in the system are immutable. The Actor model relies on the simple fact that no state is shared between Actors and the only way to guarantee that is to make sure we don't pass mutable state around as part of the messages. In Scala we have something called `case classes `_. These make excellent messages since they are both immutable and great to pattern match on. From f6e142a58351b820406c806769225db128819c65 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Thu, 28 Apr 2011 20:53:45 -0600 Subject: [PATCH 062/112] prevent chain of callbacks from overflowing the stack --- .../src/main/scala/akka/dispatch/Future.scala | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 72cab081a2..c6d270324a 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -16,6 +16,7 @@ import java.util.concurrent.TimeUnit.{NANOSECONDS => NANOS, MILLISECONDS => MILL import java.util.concurrent.atomic. {AtomicBoolean} import java.lang.{Iterable => JIterable} import java.util.{LinkedList => JLinkedList} +import scala.collection.mutable.Stack import annotation.tailrec class FutureTimeoutException(message: String) extends AkkaException(message) @@ -271,6 +272,10 @@ object Future { val fb = fn(a.asInstanceOf[A]) for (r <- fr; b <-fb) yield (r += b) }.map(_.result) + + private[akka] val callbacks = new ThreadLocal[Option[Stack[() => Unit]]]() { + override def initialValue = None + } } sealed trait Future[+T] { @@ -672,8 +677,30 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com _lock.unlock } - if (notifyTheseListeners.nonEmpty) - notifyTheseListeners.reverse foreach notify + @tailrec + def addToCallbacks(rest: List[Future[T] => Unit], callbacks: Stack[() => Unit]) { + if (rest.nonEmpty) { + callbacks.push(() => notify(rest.head)) + addToCallbacks(rest.tail, callbacks) + } + } + + if (notifyTheseListeners.nonEmpty) { + val optCallbacks = Future.callbacks.get + if (optCallbacks.isDefined) addToCallbacks(notifyTheseListeners, optCallbacks.get) + else { + try { + val callbacks = Stack[() => Unit]() + Future.callbacks.set(Some(callbacks)) + addToCallbacks(notifyTheseListeners, callbacks) + while (callbacks.nonEmpty) { + callbacks.pop().apply + } + } finally { + Future.callbacks.set(None) + } + } + } this } From ae481fc39a14423bd7a74138e0f150761c2fff61 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Thu, 28 Apr 2011 21:14:18 -0600 Subject: [PATCH 063/112] Avoid unneeded allocations --- .../src/main/scala/akka/dispatch/Future.scala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index c6d270324a..a925978b24 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -685,6 +685,14 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com } } + def runCallbacks(rest: List[Future[T] => Unit], callbacks: Stack[() => Unit]) { + if (rest.nonEmpty) { + notify(rest.head) + while (callbacks.nonEmpty) { callbacks.pop().apply } + runCallbacks(rest.tail, callbacks) + } + } + if (notifyTheseListeners.nonEmpty) { val optCallbacks = Future.callbacks.get if (optCallbacks.isDefined) addToCallbacks(notifyTheseListeners, optCallbacks.get) @@ -692,10 +700,7 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com try { val callbacks = Stack[() => Unit]() Future.callbacks.set(Some(callbacks)) - addToCallbacks(notifyTheseListeners, callbacks) - while (callbacks.nonEmpty) { - callbacks.pop().apply - } + runCallbacks(notifyTheseListeners, callbacks) } finally { Future.callbacks.set(None) } From 2bfa5e5fc2c800b28d19b786bead5015af7d8948 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Thu, 28 Apr 2011 21:24:58 -0600 Subject: [PATCH 064/112] Add @tailrec check --- akka-actor/src/main/scala/akka/dispatch/Future.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index a925978b24..d745f8ec4a 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -685,6 +685,7 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com } } + @tailrec def runCallbacks(rest: List[Future[T] => Unit], callbacks: Stack[() => Unit]) { if (rest.nonEmpty) { notify(rest.head) From c2f810ecdb87b50c4aecd4ba4d21b69803cc94f4 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Apr 2011 07:59:54 +0200 Subject: [PATCH 065/112] Fixed typo --- akka-docs/scala/tutorial-chat-server.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/akka-docs/scala/tutorial-chat-server.rst b/akka-docs/scala/tutorial-chat-server.rst index 73f66cc394..daa28d2ca3 100644 --- a/akka-docs/scala/tutorial-chat-server.rst +++ b/akka-docs/scala/tutorial-chat-server.rst @@ -127,8 +127,8 @@ Make SBT download the dependencies it needs. That is done by invoking:: From the SBT project you can generate files for your IDE: -- `SbtEclipsify `_ to generate the Eclipse project. Detailed instructions are available in :ref:`getting-started-first-scala-eclipse`. -- `sbt-idea `_ to generate the Eclipse project +- `SbtEclipsify `_ to generate Eclipse project. Detailed instructions are available in :ref:`getting-started-first-scala-eclipse`. +- `sbt-idea `_ to generate IntelliJ IDEA project. Creating messages ----------------- From 2cec337c97d1ae0b238dded451f642ba42b7527e Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Apr 2011 08:57:26 +0200 Subject: [PATCH 066/112] Moved remote-actors from pending --- akka-docs/java/index.rst | 1 + .../{pending/remote-actors-java.rst => java/remote-actors.rst} | 0 akka-docs/scala/index.rst | 1 + .../{pending/remote-actors-scala.rst => scala/remote-actors.rst} | 0 4 files changed, 2 insertions(+) rename akka-docs/{pending/remote-actors-java.rst => java/remote-actors.rst} (100%) rename akka-docs/{pending/remote-actors-scala.rst => scala/remote-actors.rst} (100%) diff --git a/akka-docs/java/index.rst b/akka-docs/java/index.rst index aeef671960..f0cb45d08f 100644 --- a/akka-docs/java/index.rst +++ b/akka-docs/java/index.rst @@ -9,4 +9,5 @@ Java API actor-registry stm transactors + remote-actors dispatchers diff --git a/akka-docs/pending/remote-actors-java.rst b/akka-docs/java/remote-actors.rst similarity index 100% rename from akka-docs/pending/remote-actors-java.rst rename to akka-docs/java/remote-actors.rst diff --git a/akka-docs/scala/index.rst b/akka-docs/scala/index.rst index 71c399709d..35a5c0a79b 100644 --- a/akka-docs/scala/index.rst +++ b/akka-docs/scala/index.rst @@ -10,6 +10,7 @@ Scala API agents stm transactors + remote-actors dispatchers fsm testing diff --git a/akka-docs/pending/remote-actors-scala.rst b/akka-docs/scala/remote-actors.rst similarity index 100% rename from akka-docs/pending/remote-actors-scala.rst rename to akka-docs/scala/remote-actors.rst From 52e7d078a9b0aaad5f5c08eaae12fbcdb2353f9a Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Apr 2011 09:36:17 +0200 Subject: [PATCH 067/112] Cleanup --- akka-docs/java/remote-actors.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/akka-docs/java/remote-actors.rst b/akka-docs/java/remote-actors.rst index 47f27d6cef..15786c7a6a 100644 --- a/akka-docs/java/remote-actors.rst +++ b/akka-docs/java/remote-actors.rst @@ -3,9 +3,9 @@ Remote Actors (Java) Module stability: **SOLID** -Akka supports starting UntypedActors and TypedActors on remote nodes using a very efficient and scalable NIO implementation built upon `JBoss Netty `_ and `Google Protocol Buffers `_ . +Akka supports starting interacting with UntypedActors and TypedActors on remote nodes using a very efficient and scalable NIO implementation built upon `JBoss Netty `_ and `Google Protocol Buffers `_ . -The usage is completely transparent both in regards to sending messages and error handling and propagation as well as supervision, linking and restarts. You can send references to other Actors as part of the message. +The usage is completely transparent with local actors, both in regards to sending messages and error handling and propagation as well as supervision, linking and restarts. You can send references to other Actors as part of the message. **WARNING**: For security reasons, do not run an Akka node with a Remote Actor port reachable by untrusted connections unless you have supplied a classloader that restricts access to the JVM. From cdf9da112bc4f76b33f0cda276368c87fc7a7fd8 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Apr 2011 09:36:27 +0200 Subject: [PATCH 068/112] Cleanup --- akka-docs/scala/remote-actors.rst | 45 ++++++++++++++++--------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/akka-docs/scala/remote-actors.rst b/akka-docs/scala/remote-actors.rst index 9389a5d284..d06e34c2de 100644 --- a/akka-docs/scala/remote-actors.rst +++ b/akka-docs/scala/remote-actors.rst @@ -3,11 +3,11 @@ Remote Actors (Scala) Module stability: **SOLID** -Akka supports starting Actors and Typed Actors on remote nodes using a very efficient and scalable NIO implementation built upon `JBoss Netty `_ and `Google Protocol Buffers `_ . +Akka supports starting and interacting with Actors and Typed Actors on remote nodes using a very efficient and scalable NIO implementation built upon `JBoss Netty `_ and `Google Protocol Buffers `_ . -The usage is completely transparent both in regards to sending messages and error handling and propagation as well as supervision, linking and restarts. You can send references to other Actors as part of the message. +The usage is completely transparent with local actors, both in regards to sending messages and error handling and propagation as well as supervision, linking and restarts. You can send references to other Actors as part of the message. -You can find a runnable sample `here `_. +You can find a runnable sample `here `__. Starting up the remote service ------------------------------ @@ -332,7 +332,7 @@ Session bound server side setup Session bound server managed remote actors work by creating and starting a new actor for every client that connects. Actors are stopped automatically when the client disconnects. The client side is the same as regular server managed remote actors. Use the function registerPerSession instead of register. Session bound actors are useful if you need to keep state per session, e.g. username. -They are also useful if you need to perform some cleanup when a client disconnects by overriding the postStop method as described `here `_ +They are also useful if you need to perform some cleanup when a client disconnects by overriding the postStop method as described `here `__ .. code-block:: scala @@ -697,26 +697,27 @@ Using the generated message builder to send the message to a remote actor: SBinary ^^^^^^^ -``_ -case class User(firstNameLastName: Tuple2[String, String], email: String, age: Int) extends Serializable.SBinary[User] { - import sbinary.DefaultProtocol._ +.. code-block:: scala - def this() = this(null, null, 0) + case class User(firstNameLastName: Tuple2[String, String], email: String, age: Int) extends Serializable.SBinary[User] { + import sbinary.DefaultProtocol._ - implicit object UserFormat extends Format[User] { - def reads(in : Input) = User( - read[Tuple2[String, String]](in), - read[String](in), - read[Int](in)) - def writes(out: Output, value: User) = { - write[Tuple2[String, String]](out, value. firstNameLastName) - write[String](out, value.email) - write[Int](out, value.age) + def this() = this(null, null, 0) + + implicit object UserFormat extends Format[User] { + def reads(in : Input) = User( + read[Tuple2[String, String]](in), + read[String](in), + read[Int](in)) + def writes(out: Output, value: User) = { + write[Tuple2[String, String]](out, value. firstNameLastName) + write[String](out, value.email) + write[Int](out, value.age) + } } + + def fromBytes(bytes: Array[Byte]) = fromByteArray[User](bytes) + + def toBytes: Array[Byte] = toByteArray(this) } - def fromBytes(bytes: Array[Byte]) = fromByteArray[User](bytes) - - def toBytes: Array[Byte] = toByteArray(this) -} -``_ From cf494781836917daaf58f6c5c4f4fb45ad45a627 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Apr 2011 10:19:09 +0200 Subject: [PATCH 069/112] Scala style fixes, added parens for side effecting shutdown methods --- akka-docs/scala/remote-actors.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-docs/scala/remote-actors.rst b/akka-docs/scala/remote-actors.rst index d06e34c2de..8f01882956 100644 --- a/akka-docs/scala/remote-actors.rst +++ b/akka-docs/scala/remote-actors.rst @@ -64,7 +64,7 @@ If you invoke 'shutdown' on the server then the connection will be closed. import akka.actor.Actor._ - remote.shutdown + remote.shutdown() Connecting and shutting down a client explicitly ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From 6576cd51e9f888e89d43dca24a19cfd1f713141d Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Apr 2011 10:20:16 +0200 Subject: [PATCH 070/112] Scala style fixes, added parens for side effecting shutdown methods --- .../actor/supervisor/SupervisorSpec.scala | 2 +- .../akka/actor/supervisor/Ticket669Spec.scala | 2 +- .../scala/akka/dataflow/DataFlowSpec.scala | 6 ++-- .../scala/akka/dispatch/ActorModelSpec.scala | 8 +++--- .../src/main/scala/akka/actor/Scheduler.scala | 14 ++++++---- .../main/scala/akka/dataflow/DataFlow.scala | 2 +- .../scala/akka/dispatch/MessageHandling.scala | 6 ++-- .../akka/dispatch/ThreadPoolBuilder.scala | 4 +-- .../main/scala/akka/event/EventHandler.scala | 6 ++-- .../remoteinterface/RemoteInterface.scala | 6 ++-- .../src/main/scala/akka/util/AkkaLoader.scala | 18 ++++++------ .../src/main/scala/akka/util/Bootable.scala | 4 +-- .../remote/BootableRemoteActorService.scala | 14 +++++----- .../remote/netty/NettyRemoteSupport.scala | 28 +++++++++---------- .../test/scala/remote/AkkaRemoteTest.scala | 8 +++--- ...erverInitiatedRemoteSessionActorSpec.scala | 4 +-- ...InitiatedRemoteTypedSessionActorSpec.scala | 10 +++---- .../src/main/scala/ChatServer.scala | 25 +++++++++-------- .../testkit/CallingThreadDispatcher.scala | 4 +-- .../config/TypedActorGuiceConfigurator.scala | 2 +- 20 files changed, 91 insertions(+), 82 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/actor/supervisor/SupervisorSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/supervisor/SupervisorSpec.scala index 253570f576..668a2709cc 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/supervisor/SupervisorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/supervisor/SupervisorSpec.scala @@ -381,7 +381,7 @@ class SupervisorSpec extends WordSpec with MustMatchers with BeforeAndAfterEach inits.get must be (3) - supervisor.shutdown + supervisor.shutdown() } } } diff --git a/akka-actor-tests/src/test/scala/akka/actor/supervisor/Ticket669Spec.scala b/akka-actor-tests/src/test/scala/akka/actor/supervisor/Ticket669Spec.scala index 33f7a72434..b61bd1a937 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/supervisor/Ticket669Spec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/supervisor/Ticket669Spec.scala @@ -14,7 +14,7 @@ import org.scalatest.matchers.MustMatchers class Ticket669Spec extends WordSpec with MustMatchers with BeforeAndAfterAll { import Ticket669Spec._ - override def afterAll = Actor.registry.shutdownAll() + override def afterAll() { Actor.registry.shutdownAll() } "A supervised actor with lifecycle PERMANENT" should { "be able to reply on failure during preRestart" in { diff --git a/akka-actor-tests/src/test/scala/akka/dataflow/DataFlowSpec.scala b/akka-actor-tests/src/test/scala/akka/dataflow/DataFlowSpec.scala index e0e0a09e6b..412605c02b 100644 --- a/akka-actor-tests/src/test/scala/akka/dataflow/DataFlowSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dataflow/DataFlowSpec.scala @@ -36,7 +36,7 @@ class DataFlowTest extends Spec with ShouldMatchers with BeforeAndAfterAll { latch.await(10,TimeUnit.SECONDS) should equal (true) result.get should equal (42) - List(x,y,z).foreach(_.shutdown) + List(x,y,z).foreach(_.shutdown()) } it("should be able to sum a sequence of ints") { @@ -67,7 +67,7 @@ class DataFlowTest extends Spec with ShouldMatchers with BeforeAndAfterAll { latch.await(10,TimeUnit.SECONDS) should equal (true) result.get should equal (sum(0,ints(0,1000))) - List(x,y,z).foreach(_.shutdown) + List(x,y,z).foreach(_.shutdown()) } /* it("should be able to join streams") { @@ -158,7 +158,7 @@ class DataFlowTest extends Spec with ShouldMatchers with BeforeAndAfterAll { val setV = thread { v << y } - List(x,y,z,v) foreach (_.shutdown) + List(x,y,z,v) foreach (_.shutdown()) latch.await(2,TimeUnit.SECONDS) should equal (true) }*/ } diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/ActorModelSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/ActorModelSpec.scala index 2ee4d8a2f7..d5cea19bf5 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/ActorModelSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/ActorModelSpec.scala @@ -111,13 +111,13 @@ object ActorModelSpec { super.dispatch(invocation) } - private[akka] abstract override def start { - super.start + private[akka] abstract override def start() { + super.start() starts.incrementAndGet() } - private[akka] abstract override def shutdown { - super.shutdown + private[akka] abstract override def shutdown() { + super.shutdown() stops.incrementAndGet() } } diff --git a/akka-actor/src/main/scala/akka/actor/Scheduler.scala b/akka-actor/src/main/scala/akka/actor/Scheduler.scala index cbda9d0af9..1c1da8e7a2 100644 --- a/akka-actor/src/main/scala/akka/actor/Scheduler.scala +++ b/akka-actor/src/main/scala/akka/actor/Scheduler.scala @@ -105,13 +105,17 @@ object Scheduler { } } - def shutdown: Unit = synchronized { - service.shutdown + def shutdown() { + synchronized { + service.shutdown() + } } - def restart: Unit = synchronized { - shutdown - service = Executors.newSingleThreadScheduledExecutor(SchedulerThreadFactory) + def restart() { + synchronized { + shutdown() + service = Executors.newSingleThreadScheduledExecutor(SchedulerThreadFactory) + } } } diff --git a/akka-actor/src/main/scala/akka/dataflow/DataFlow.scala b/akka-actor/src/main/scala/akka/dataflow/DataFlow.scala index 7ac900333d..446bc9652b 100644 --- a/akka-actor/src/main/scala/akka/dataflow/DataFlow.scala +++ b/akka-actor/src/main/scala/akka/dataflow/DataFlow.scala @@ -160,6 +160,6 @@ object DataFlow { } } - def shutdown = in ! Exit + def shutdown() { in ! Exit } } } diff --git a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala index cfe69e33f3..415ed053dc 100644 --- a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala +++ b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala @@ -168,7 +168,7 @@ trait MessageDispatcher { shutdownSchedule = SCHEDULED Scheduler.scheduleOnce(this, timeoutMs, TimeUnit.MILLISECONDS) case SCHEDULED => - if (uuids.isEmpty() && futures.get == 0) { + if (uuids.isEmpty && futures.get == 0) { active switchOff { shutdown // shut down in the dispatcher's references is zero } @@ -205,12 +205,12 @@ trait MessageDispatcher { /** * Called one time every time an actor is attached to this dispatcher and this dispatcher was previously shutdown */ - private[akka] def start: Unit + private[akka] def start(): Unit /** * Called one time every time an actor is detached from this dispatcher and this dispatcher has no actors left attached */ - private[akka] def shutdown: Unit + private[akka] def shutdown(): Unit /** * Returns the size of the mailbox for the specified actor diff --git a/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala b/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala index 83c30f23e0..0bcc0662e0 100644 --- a/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala +++ b/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala @@ -221,9 +221,9 @@ trait ExecutorServiceDelegate extends ExecutorService { def execute(command: Runnable) = executor.execute(command) - def shutdown = executor.shutdown + def shutdown() { executor.shutdown() } - def shutdownNow = executor.shutdownNow + def shutdownNow() = executor.shutdownNow() def isShutdown = executor.isShutdown diff --git a/akka-actor/src/main/scala/akka/event/EventHandler.scala b/akka-actor/src/main/scala/akka/event/EventHandler.scala index b29eb0ca72..1d7d81c1b6 100644 --- a/akka-actor/src/main/scala/akka/event/EventHandler.scala +++ b/akka-actor/src/main/scala/akka/event/EventHandler.scala @@ -102,9 +102,9 @@ object EventHandler extends ListenerManagement { /** * Shuts down all event handler listeners including the event handle dispatcher. */ - def shutdown() = { - foreachListener(_.stop) - EventHandlerDispatcher.shutdown + def shutdown() { + foreachListener(_.stop()) + EventHandlerDispatcher.shutdown() } def notify(event: Any) { diff --git a/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala b/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala index 081b622f39..7b61f224e8 100644 --- a/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala +++ b/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala @@ -143,11 +143,11 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule handler } - def shutdown { + def shutdown() { eventHandler.stop() removeListener(eventHandler) - this.shutdownClientModule - this.shutdownServerModule + this.shutdownClientModule() + this.shutdownServerModule() clear } diff --git a/akka-actor/src/main/scala/akka/util/AkkaLoader.scala b/akka-actor/src/main/scala/akka/util/AkkaLoader.scala index b7f113313d..2a2ee13db7 100644 --- a/akka-actor/src/main/scala/akka/util/AkkaLoader.scala +++ b/akka-actor/src/main/scala/akka/util/AkkaLoader.scala @@ -21,7 +21,7 @@ class AkkaLoader { * Boot initializes the specified bundles */ def boot(withBanner: Boolean, b : Bootable): Unit = hasBooted switchOn { - if (withBanner) printBanner + if (withBanner) printBanner() println("Starting Akka...") b.onLoad Thread.currentThread.setContextClassLoader(getClass.getClassLoader) @@ -32,15 +32,17 @@ class AkkaLoader { /* * Shutdown, well, shuts down the bundles used in boot */ - def shutdown: Unit = hasBooted switchOff { - println("Shutting down Akka...") - _bundles.foreach(_.onUnload) - _bundles = None - Actor.shutdownHook.run - println("Akka succesfully shut down") + def shutdown() { + hasBooted switchOff { + println("Shutting down Akka...") + _bundles.foreach(_.onUnload) + _bundles = None + Actor.shutdownHook.run + println("Akka succesfully shut down") + } } - private def printBanner = { + private def printBanner() { println("==================================================") println(" t") println(" t t t") diff --git a/akka-actor/src/main/scala/akka/util/Bootable.scala b/akka-actor/src/main/scala/akka/util/Bootable.scala index bea62e5ac7..d07643e1ac 100644 --- a/akka-actor/src/main/scala/akka/util/Bootable.scala +++ b/akka-actor/src/main/scala/akka/util/Bootable.scala @@ -5,6 +5,6 @@ package akka.util trait Bootable { - def onLoad {} - def onUnload {} + def onLoad() {} + def onUnload() {} } diff --git a/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala b/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala index 8139b35d0b..aa88be92c0 100644 --- a/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala +++ b/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala @@ -20,18 +20,18 @@ trait BootableRemoteActorService extends Bootable { def run = Actor.remote.start(self.applicationLoader.getOrElse(null)) //Use config host/port }, "Akka Remote Service") - def startRemoteService = remoteServerThread.start() + def startRemoteService() { remoteServerThread.start() } - abstract override def onLoad = { + abstract override def onLoad() { if (ReflectiveAccess.isRemotingEnabled && RemoteServerSettings.isRemotingEnabled) { - startRemoteService + startRemoteService() } - super.onLoad + super.onLoad() } - abstract override def onUnload = { - Actor.remote.shutdown + abstract override def onUnload() { + Actor.remote.shutdown() if (remoteServerThread.isAlive) remoteServerThread.join(1000) - super.onUnload + super.onUnload() } } diff --git a/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala b/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala index 3be65cdea3..7196231c2d 100644 --- a/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala +++ b/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala @@ -107,7 +107,7 @@ trait NettyRemoteClientModule extends RemoteClientModule { self: ListenerManagem def shutdownClientConnection(address: InetSocketAddress): Boolean = lock withWriteGuard { remoteClients.remove(Address(address)) match { - case s: Some[RemoteClient] => s.get.shutdown + case s: Some[RemoteClient] => s.get.shutdown() case None => false } } @@ -132,15 +132,15 @@ trait NettyRemoteClientModule extends RemoteClientModule { self: ListenerManagem /** * Clean-up all open connections. */ - def shutdownClientModule = { - shutdownRemoteClients + def shutdownClientModule() { + shutdownRemoteClients() //TODO: Should we empty our remoteActors too? //remoteActors.clear } - def shutdownRemoteClients = lock withWriteGuard { - remoteClients.foreach({ case (addr, client) => client.shutdown }) - remoteClients.clear + def shutdownRemoteClients() = lock withWriteGuard { + remoteClients.foreach({ case (addr, client) => client.shutdown() }) + remoteClients.clear() } def registerClientManagedActor(hostname: String, port: Int, uuid: Uuid) = { @@ -187,7 +187,7 @@ abstract class RemoteClient private[akka] ( def connect(reconnectIfAlreadyConnected: Boolean = false): Boolean - def shutdown: Boolean + def shutdown(): Boolean /** * Returns an array with the current pending messages not yet delivered. @@ -403,16 +403,16 @@ class ActiveRemoteClient private[akka] ( } //Please note that this method does _not_ remove the ARC from the NettyRemoteClientModule's map of clients - def shutdown = runSwitch switchOff { + def shutdown() = runSwitch switchOff { notifyListeners(RemoteClientShutdown(module, remoteAddress)) timer.stop() timer = null openChannels.close.awaitUninterruptibly openChannels = null - bootstrap.releaseExternalResources + bootstrap.releaseExternalResources() bootstrap = null connection = null - pendingRequests.clear + pendingRequests.clear() } private[akka] def isWithinReconnectionTimeWindow: Boolean = { @@ -629,7 +629,7 @@ class NettyRemoteServer(serverModule: NettyRemoteServerModule, val host: String, openChannels.add(bootstrap.bind(address)) serverModule.notifyListeners(RemoteServerStarted(serverModule)) - def shutdown { + def shutdown() { try { val shutdownSignal = { val b = RemoteControlProtocol.newBuilder @@ -641,7 +641,7 @@ class NettyRemoteServer(serverModule: NettyRemoteServerModule, val host: String, openChannels.write(RemoteEncoder.encode(shutdownSignal)).awaitUninterruptibly openChannels.disconnect openChannels.close.awaitUninterruptibly - bootstrap.releaseExternalResources + bootstrap.releaseExternalResources() serverModule.notifyListeners(RemoteServerShutdown(serverModule)) } catch { case e: Exception => @@ -684,11 +684,11 @@ trait NettyRemoteServerModule extends RemoteServerModule { self: RemoteModule => this } - def shutdownServerModule = guard withGuard { + def shutdownServerModule() = guard withGuard { _isRunning switchOff { currentServer.getAndSet(None) foreach { instance => - instance.shutdown + instance.shutdown() } } } diff --git a/akka-remote/src/test/scala/remote/AkkaRemoteTest.scala b/akka-remote/src/test/scala/remote/AkkaRemoteTest.scala index 9b2b299d25..22c3a6e949 100644 --- a/akka-remote/src/test/scala/remote/AkkaRemoteTest.scala +++ b/akka-remote/src/test/scala/remote/AkkaRemoteTest.scala @@ -40,20 +40,20 @@ class AkkaRemoteTest extends remote.asInstanceOf[NettyRemoteSupport].optimizeLocal.set(false) //Can't run the test if we're eliminating all remote calls } - override def afterAll { + override def afterAll() { if (!OptimizeLocal) remote.asInstanceOf[NettyRemoteSupport].optimizeLocal.set(optimizeLocal_?) //Reset optimizelocal after all tests } - override def beforeEach { + override def beforeEach() { remote.start(host,port) super.beforeEach } override def afterEach() { - remote.shutdown + remote.shutdown() Actor.registry.shutdownAll() - super.afterEach + super.afterEach() } /* Utilities */ diff --git a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala index 09a5f96bde..af29bb0bcb 100644 --- a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala +++ b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala @@ -48,7 +48,7 @@ class ServerInitiatedRemoteSessionActorSpec extends AkkaRemoteTest { val result1 = session1 !! GetUser() result1.as[String] must equal (Some("session[1]")) - remote.shutdownClientModule + remote.shutdownClientModule() val session2 = remote.actorFor("untyped-session-actor-service", 5000L, host, port) @@ -66,7 +66,7 @@ class ServerInitiatedRemoteSessionActorSpec extends AkkaRemoteTest { default1.as[String] must equal (Some("anonymous")) instantiatedSessionActors must have size (1) - remote.shutdownClientModule + remote.shutdownClientModule() Thread.sleep(1000) instantiatedSessionActors must have size (0) } diff --git a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala index e357127641..e0d1a32ac3 100644 --- a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala +++ b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala @@ -18,8 +18,8 @@ class ServerInitiatedRemoteTypedSessionActorSpec extends AkkaRemoteTest { } // make sure the servers shutdown cleanly after the test has finished - override def afterEach = { - super.afterEach + override def afterEach() { + super.afterEach() clearMessageLogs } @@ -32,7 +32,7 @@ class ServerInitiatedRemoteTypedSessionActorSpec extends AkkaRemoteTest { session1.login("session[1]") session1.getUser() must equal ("session[1]") - remote.shutdownClientModule + remote.shutdownClientModule() val session2 = remote.typedActorFor(classOf[RemoteTypedSessionActor], "typed-session-actor-service", 5000L, host, port) @@ -46,7 +46,7 @@ class ServerInitiatedRemoteTypedSessionActorSpec extends AkkaRemoteTest { session1.getUser() must equal ("anonymous") RemoteTypedSessionActorImpl.getInstances() must have size (1) - remote.shutdownClientModule + remote.shutdownClientModule() Thread.sleep(1000) RemoteTypedSessionActorImpl.getInstances() must have size (0) @@ -57,7 +57,7 @@ class ServerInitiatedRemoteTypedSessionActorSpec extends AkkaRemoteTest { session1.doSomethingFunny() - remote.shutdownClientModule + remote.shutdownClientModule() Thread.sleep(1000) RemoteTypedSessionActorImpl.getInstances() must have size (0) } diff --git a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala index 90f6f2701e..8b0358a4e1 100644 --- a/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala +++ b/akka-samples/akka-sample-chat/src/main/scala/ChatServer.scala @@ -6,7 +6,7 @@ import scala.collection.mutable.HashMap - import akka.actor.{SupervisorFactory, Actor, ActorRef} + import akka.actor.{Actor, ActorRef} import akka.stm._ import akka.config.Supervision.{OneForOneStrategy,Permanent} import Actor._ @@ -108,7 +108,9 @@ self.reply(ChatLog(messageList)) } - override def postRestart(reason: Throwable) = chatLog = TransactionalVector() + override def postRestart(reason: Throwable) { + chatLog = TransactionalVector() + } } /** @@ -135,8 +137,9 @@ sessions -= username } - protected def shutdownSessions = + protected def shutdownSessions() { sessions.foreach { case (_, session) => session.stop() } + } } /** @@ -184,11 +187,11 @@ // abstract methods to be defined somewhere else protected def chatManagement: Receive protected def sessionManagement: Receive - protected def shutdownSessions(): Unit + protected def shutdownSessions() - override def postStop() = { + override def postStop() { EventHandler.info(this, "Chat server is shutting down...") - shutdownSessions + shutdownSessions() self.unlink(storage) storage.stop() } @@ -206,7 +209,7 @@ SessionManagement with ChatManagement with MemoryChatStorageFactory { - override def preStart() = { + override def preStart() { remote.start("localhost", 2552); remote.register("chat:service", self) //Register the actor with the specified service id } @@ -217,9 +220,9 @@ */ object ServerRunner { - def main(args: Array[String]): Unit = ServerRunner.run + def main(args: Array[String]) { ServerRunner.run() } - def run = { + def run() { actorOf[ChatService].start() } } @@ -229,9 +232,9 @@ */ object ClientRunner { - def main(args: Array[String]): Unit = ClientRunner.run + def main(args: Array[String]) { ClientRunner.run() } - def run = { + def run() { val client1 = new ChatClient("jonas") client1.login diff --git a/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala b/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala index dcf20158d8..319b40b6f4 100644 --- a/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala +++ b/akka-testkit/src/main/scala/akka/testkit/CallingThreadDispatcher.scala @@ -108,9 +108,9 @@ class CallingThreadDispatcher(val warnings: Boolean = true) extends MessageDispa private def getMailbox(actor: ActorRef) = actor.mailbox.asInstanceOf[CallingThreadMailbox] - private[akka] override def start {} + private[akka] override def start() {} - private[akka] override def shutdown {} + private[akka] override def shutdown() {} private[akka] override def timeoutMs = 100L diff --git a/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala b/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala index ae19601351..98ce6d8b20 100644 --- a/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala +++ b/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala @@ -173,7 +173,7 @@ private[akka] class TypedActorGuiceConfigurator extends TypedActorConfiguratorBa } def stop = synchronized { - if (supervisor.isDefined) supervisor.get.shutdown + if (supervisor.isDefined) supervisor.get.shutdown() } } From 5e3f8d3e89b94459b3f42bafe3a41c54a49230ee Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Apr 2011 11:02:35 +0200 Subject: [PATCH 071/112] Failing test due to timeout, decreased number of messages --- .../src/test/scala/remote/ClientInitiatedRemoteActorSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-remote/src/test/scala/remote/ClientInitiatedRemoteActorSpec.scala b/akka-remote/src/test/scala/remote/ClientInitiatedRemoteActorSpec.scala index af5aaffcc3..55f0ac3e3e 100644 --- a/akka-remote/src/test/scala/remote/ClientInitiatedRemoteActorSpec.scala +++ b/akka-remote/src/test/scala/remote/ClientInitiatedRemoteActorSpec.scala @@ -101,7 +101,7 @@ class ClientInitiatedRemoteActorSpec extends AkkaRemoteTest { } "shouldSendBangBangMessageAndReceiveReplyConcurrently" in { - val actors = (1 to 10).map(num => { remote.actorOf[RemoteActorSpecActorBidirectional](host,port).start() }).toList + val actors = (1 to 5).map(num => { remote.actorOf[RemoteActorSpecActorBidirectional](host,port).start() }).toList actors.map(_ !!! ("Hello", 10000)) foreach { future => "World" must equal (future.await.result.asInstanceOf[Option[String]].get) } From c24063496dab7061a0973fa9f81ed797ea2e901c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Fri, 29 Apr 2011 03:39:25 -0700 Subject: [PATCH 072/112] Added instructions to checkout tutorial with git --- akka-docs/intro/getting-started-first-java.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/akka-docs/intro/getting-started-first-java.rst b/akka-docs/intro/getting-started-first-java.rst index b907118f15..aafe02446f 100644 --- a/akka-docs/intro/getting-started-first-java.rst +++ b/akka-docs/intro/getting-started-first-java.rst @@ -31,6 +31,14 @@ If you want don't want to type in the code and/or set up a Maven project then yo __ https://github.com/jboner/akka/tree/master/akka-tutorials/akka-tutorial-first __ https://github.com/jboner/akka/blob/master/akka-tutorials/akka-tutorial-first/src/main/java/akka/tutorial/first/java/Pi.java +To check out the code using Git invoke the following:: + + $ git clone git://github.com/jboner/akka.git + +Then you can navigate down to the tutorial:: + + $ cd akka/akka-tutorials/akka-tutorial-first + Prerequisites ------------- From 36535d50e266c080c0668eef9762698bd5027561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Fri, 29 Apr 2011 03:40:08 -0700 Subject: [PATCH 073/112] Added instructions on how to check out the tutorial code using git --- akka-docs/intro/getting-started-first-scala.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/akka-docs/intro/getting-started-first-scala.rst b/akka-docs/intro/getting-started-first-scala.rst index 867b6fe3f4..20e592c4ea 100644 --- a/akka-docs/intro/getting-started-first-scala.rst +++ b/akka-docs/intro/getting-started-first-scala.rst @@ -31,6 +31,14 @@ If you want don't want to type in the code and/or set up an SBT project then you __ https://github.com/jboner/akka/tree/master/akka-tutorials/akka-tutorial-first __ https://github.com/jboner/akka/blob/master/akka-tutorials/akka-tutorial-first/src/main/scala/Pi.scala +To check out the code using Git invoke the following:: + + $ git clone git://github.com/jboner/akka.git + +Then you can navigate down to the tutorial:: + + $ cd akka/akka-tutorials/akka-tutorial-first + Prerequisites ------------- From 1fb228c06d5fdb67c22d59455357821f5a2290fb Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Fri, 29 Apr 2011 13:22:39 +0200 Subject: [PATCH 074/112] Reducing object creation overhead --- .../src/main/scala/akka/dispatch/Future.scala | 56 ++++++++----------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index d745f8ec4a..0f326410c2 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -18,6 +18,7 @@ import java.lang.{Iterable => JIterable} import java.util.{LinkedList => JLinkedList} import scala.collection.mutable.Stack import annotation.tailrec +import util.DynamicVariable class FutureTimeoutException(message: String) extends AkkaException(message) @@ -273,9 +274,7 @@ object Future { for (r <- fr; b <-fb) yield (r += b) }.map(_.result) - private[akka] val callbacks = new ThreadLocal[Option[Stack[() => Unit]]]() { - override def initialValue = None - } + private[akka] val callbacksPendingExecution = new DynamicVariable[Option[Stack[() => Unit]]](None) } sealed trait Future[+T] { @@ -677,35 +676,28 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com _lock.unlock } - @tailrec - def addToCallbacks(rest: List[Future[T] => Unit], callbacks: Stack[() => Unit]) { - if (rest.nonEmpty) { - callbacks.push(() => notify(rest.head)) - addToCallbacks(rest.tail, callbacks) - } - } - - @tailrec - def runCallbacks(rest: List[Future[T] => Unit], callbacks: Stack[() => Unit]) { - if (rest.nonEmpty) { - notify(rest.head) - while (callbacks.nonEmpty) { callbacks.pop().apply } - runCallbacks(rest.tail, callbacks) - } - } - - if (notifyTheseListeners.nonEmpty) { - val optCallbacks = Future.callbacks.get - if (optCallbacks.isDefined) addToCallbacks(notifyTheseListeners, optCallbacks.get) - else { - try { - val callbacks = Stack[() => Unit]() - Future.callbacks.set(Some(callbacks)) - runCallbacks(notifyTheseListeners, callbacks) - } finally { - Future.callbacks.set(None) + if (notifyTheseListeners.nonEmpty) { // Steps to ensure we don't run into a stack-overflow situation + @tailrec def runCallbacks(rest: List[Future[T] => Unit], callbacks: Stack[() => Unit]) { + if (rest.nonEmpty) { + notifyCompleted(rest.head) + while (callbacks.nonEmpty) { callbacks.pop().apply() } + runCallbacks(rest.tail, callbacks) } } + + val pending = Future.callbacksPendingExecution.value + if (pending.isDefined) { //Instead of nesting the calls to the callbacks (leading to stack overflow) + pending.get.push(() => { // Linearize/aggregate callbacks at top level and then execute + val doNotify = notifyCompleted _ //Hoist closure to avoid garbage + notifyTheseListeners foreach doNotify + }) + } else { + try { + val callbacks = Stack[() => Unit]() // Allocate new aggregator for pending callbacks + Future.callbacksPendingExecution.value = Some(callbacks) // Specify the callback aggregator + runCallbacks(notifyTheseListeners, callbacks) // Execute callbacks, if they trigger new callbacks, they are aggregated + } finally { Future.callbacksPendingExecution.value = None } // Ensure cleanup + } } this @@ -724,12 +716,12 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com _lock.unlock } - if (notifyNow) notify(func) + if (notifyNow) notifyCompleted(func) this } - private def notify(func: Future[T] => Unit) { + private def notifyCompleted(func: Future[T] => Unit) { try { func(this) } catch { From e4e99ef56399e892206ce4a46b9a9107da6c7770 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Fri, 29 Apr 2011 14:43:01 +0200 Subject: [PATCH 075/112] Reenabling the on-send-redistribution of messages in WorkStealer --- ...sedEventDrivenWorkStealingDispatcher.scala | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala index f2f63a3ff4..d5f1307a84 100644 --- a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala @@ -10,6 +10,7 @@ import akka.util.{ReflectiveAccess, Switch} import java.util.Queue import java.util.concurrent.atomic.{AtomicReference, AtomicInteger} import java.util.concurrent.{ TimeUnit, ExecutorService, RejectedExecutionException, ConcurrentLinkedQueue, LinkedBlockingQueue} +import util.DynamicVariable /** * An executor based event driven dispatcher which will try to redistribute work from busy actors to idle actors. It is assumed @@ -55,6 +56,7 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher( @volatile private var actorType: Option[Class[_]] = None @volatile private var members = Vector[ActorRef]() + private val donationInProgress = new DynamicVariable(false) private[akka] override def register(actorRef: ActorRef) = { //Verify actor type conformity @@ -78,18 +80,22 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher( override private[akka] def dispatch(invocation: MessageInvocation) = { val mbox = getMailbox(invocation.receiver) - /*if (!mbox.isEmpty && attemptDonationOf(invocation, mbox)) { + if (donationInProgress.value == false && mbox.dispatcherLock.locked && attemptDonationOf(invocation, mbox)) { //We were busy and we got to donate the message to some other lucky guy, we're done here - } else {*/ + } else { mbox enqueue invocation registerForExecution(mbox) - //} + } } override private[akka] def reRegisterForExecution(mbox: MessageQueue with ExecutableMailbox): Unit = { - while(donateFrom(mbox)) {} //When we reregister, first donate messages to another actor + try { + donationInProgress.value = true + while(donateFrom(mbox)) {} //When we reregister, first donate messages to another actor + } finally { donationInProgress.value = false } + if (!mbox.isEmpty) //If we still have messages left to process, reschedule for execution - super.reRegisterForExecution(mbox) + super.reRegisterForExecution(mbox) } /** @@ -110,13 +116,14 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher( /** * Returns true if the donation succeeded or false otherwise */ - /*protected def attemptDonationOf(message: MessageInvocation, donorMbox: MessageQueue with ExecutableMailbox): Boolean = { + protected def attemptDonationOf(message: MessageInvocation, donorMbox: MessageQueue with ExecutableMailbox): Boolean = try { + donationInProgress.value = true val actors = members // copy to prevent concurrent modifications having any impact doFindDonorRecipient(donorMbox, actors, System.identityHashCode(message) % actors.size) match { case null => false case recipient => donate(message, recipient) } - }*/ + } finally { donationInProgress.value = false } /** * Rewrites the message and adds that message to the recipients mailbox From d69baf74ae610087d16a95a3bab473b77f438ae6 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Fri, 29 Apr 2011 15:50:25 +0200 Subject: [PATCH 076/112] Reverting to ThreadLocal --- akka-actor/src/main/scala/akka/dispatch/Future.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 0f326410c2..ff0b6fdc57 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -18,7 +18,6 @@ import java.lang.{Iterable => JIterable} import java.util.{LinkedList => JLinkedList} import scala.collection.mutable.Stack import annotation.tailrec -import util.DynamicVariable class FutureTimeoutException(message: String) extends AkkaException(message) @@ -274,7 +273,9 @@ object Future { for (r <- fr; b <-fb) yield (r += b) }.map(_.result) - private[akka] val callbacksPendingExecution = new DynamicVariable[Option[Stack[() => Unit]]](None) + private[akka] val callbacksPendingExecution = new ThreadLocal[Option[Stack[() => Unit]]]() { + override def initialValue = None + } } sealed trait Future[+T] { @@ -685,7 +686,7 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com } } - val pending = Future.callbacksPendingExecution.value + val pending = Future.callbacksPendingExecution.get if (pending.isDefined) { //Instead of nesting the calls to the callbacks (leading to stack overflow) pending.get.push(() => { // Linearize/aggregate callbacks at top level and then execute val doNotify = notifyCompleted _ //Hoist closure to avoid garbage @@ -694,9 +695,9 @@ class DefaultCompletableFuture[T](timeout: Long, timeunit: TimeUnit) extends Com } else { try { val callbacks = Stack[() => Unit]() // Allocate new aggregator for pending callbacks - Future.callbacksPendingExecution.value = Some(callbacks) // Specify the callback aggregator + Future.callbacksPendingExecution.set(Some(callbacks)) // Specify the callback aggregator runCallbacks(notifyTheseListeners, callbacks) // Execute callbacks, if they trigger new callbacks, they are aggregated - } finally { Future.callbacksPendingExecution.value = None } // Ensure cleanup + } finally { Future.callbacksPendingExecution.set(None) } // Ensure cleanup } } From d89c286fb2a89b4f3f40deeee6a1388e07a7c246 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Fri, 29 Apr 2011 15:58:13 +0200 Subject: [PATCH 077/112] Switching from DynamicVariable to ThreadLocal to avoid child threads inheriting the current value --- akka-actor/src/main/scala/akka/actor/Actor.scala | 8 +++++--- akka-actor/src/main/scala/akka/actor/ActorRef.scala | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/akka-actor/src/main/scala/akka/actor/Actor.scala b/akka-actor/src/main/scala/akka/actor/Actor.scala index ff3cf26d7b..cf4c1bf042 100644 --- a/akka-actor/src/main/scala/akka/actor/Actor.scala +++ b/akka-actor/src/main/scala/akka/actor/Actor.scala @@ -125,7 +125,9 @@ object Actor extends ListenerManagement { */ type Receive = PartialFunction[Any, Unit] - private[actor] val actorRefInCreation = new scala.util.DynamicVariable[Option[ActorRef]](None) + private[actor] val actorRefInCreation = new ThreadLocal[Option[ActorRef]]{ + override def initialValue = None + } /** * Creates an ActorRef out of the Actor with type T. @@ -290,7 +292,7 @@ trait Actor { * the 'forward' function. */ @transient implicit val someSelf: Some[ActorRef] = { - val optRef = Actor.actorRefInCreation.value + val optRef = Actor.actorRefInCreation.get if (optRef.isEmpty) throw new ActorInitializationException( "ActorRef for instance of actor [" + getClass.getName + "] is not in scope." + "\n\tYou can not create an instance of an actor explicitly using 'new MyActor'." + @@ -298,7 +300,7 @@ trait Actor { "\n\tEither use:" + "\n\t\t'val actor = Actor.actorOf[MyActor]', or" + "\n\t\t'val actor = Actor.actorOf(new MyActor(..))'") - Actor.actorRefInCreation.value = None + Actor.actorRefInCreation.set(None) optRef.asInstanceOf[Some[ActorRef]].get.id = getClass.getName //FIXME: Is this needed? optRef.asInstanceOf[Some[ActorRef]] } diff --git a/akka-actor/src/main/scala/akka/actor/ActorRef.scala b/akka-actor/src/main/scala/akka/actor/ActorRef.scala index 12e2b5949a..08e99206c2 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRef.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRef.scala @@ -1015,12 +1015,12 @@ class LocalActorRef private[akka] ( private[this] def newActor: Actor = { try { - Actor.actorRefInCreation.value = Some(this) + Actor.actorRefInCreation.set(Some(this)) val a = actorFactory() if (a eq null) throw new ActorInitializationException("Actor instance passed to ActorRef can not be 'null'") a } finally { - Actor.actorRefInCreation.value = None + Actor.actorRefInCreation.set(None) } } From b5873ff2c7428828deba99011d5311a57ca610df Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Fri, 29 Apr 2011 16:14:29 +0200 Subject: [PATCH 078/112] Improving throughput for WorkStealer even more --- .../ExecutorBasedEventDrivenWorkStealingDispatcher.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala index d5f1307a84..7829e47712 100644 --- a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala @@ -80,7 +80,7 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher( override private[akka] def dispatch(invocation: MessageInvocation) = { val mbox = getMailbox(invocation.receiver) - if (donationInProgress.value == false && mbox.dispatcherLock.locked && attemptDonationOf(invocation, mbox)) { + if (donationInProgress.value == false && (!mbox.isEmpty || mbox.dispatcherLock.locked) && attemptDonationOf(invocation, mbox)) { //We were busy and we got to donate the message to some other lucky guy, we're done here } else { mbox enqueue invocation From 3366dd507c4f34a6f8a6130c6374d6617f1c59bf Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Apr 2011 16:33:54 +0200 Subject: [PATCH 079/112] Moved serialization from pending --- akka-docs/java/index.rst | 1 + .../{pending/serialization-java.rst => java/serialization.rst} | 0 akka-docs/scala/index.rst | 1 + .../{pending/serialization-scala.rst => scala/serialization.rst} | 0 4 files changed, 2 insertions(+) rename akka-docs/{pending/serialization-java.rst => java/serialization.rst} (100%) rename akka-docs/{pending/serialization-scala.rst => scala/serialization.rst} (100%) diff --git a/akka-docs/java/index.rst b/akka-docs/java/index.rst index f0cb45d08f..553f75da45 100644 --- a/akka-docs/java/index.rst +++ b/akka-docs/java/index.rst @@ -10,4 +10,5 @@ Java API stm transactors remote-actors + serialization dispatchers diff --git a/akka-docs/pending/serialization-java.rst b/akka-docs/java/serialization.rst similarity index 100% rename from akka-docs/pending/serialization-java.rst rename to akka-docs/java/serialization.rst diff --git a/akka-docs/scala/index.rst b/akka-docs/scala/index.rst index 35a5c0a79b..d5269336aa 100644 --- a/akka-docs/scala/index.rst +++ b/akka-docs/scala/index.rst @@ -11,6 +11,7 @@ Scala API stm transactors remote-actors + serialization dispatchers fsm testing diff --git a/akka-docs/pending/serialization-scala.rst b/akka-docs/scala/serialization.rst similarity index 100% rename from akka-docs/pending/serialization-scala.rst rename to akka-docs/scala/serialization.rst From 888af3479e9abdbaf8aaff8c36a75e1c19de4c5d Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Apr 2011 17:07:52 +0200 Subject: [PATCH 080/112] Cleanup of serialization docs --- akka-docs/java/serialization.rst | 21 ++-- akka-docs/scala/serialization.rst | 153 ++++++++++++++++-------------- 2 files changed, 93 insertions(+), 81 deletions(-) diff --git a/akka-docs/java/serialization.rst b/akka-docs/java/serialization.rst index 1206211b8d..813db45a9a 100644 --- a/akka-docs/java/serialization.rst +++ b/akka-docs/java/serialization.rst @@ -1,10 +1,16 @@ +.. _serialization-java: + Serialization (Java) ==================== -Akka serialization module has been documented extensively under the Scala API section. In this section we will point out the different APIs that are available in Akka for Java based serialization of ActorRefs. The Scala APIs of ActorSerialization has implicit Format objects that set up the type class based serialization. In the Java API, the Format objects need to be specified explicitly. +.. sidebar:: Contents + + .. contents:: :local: + +Akka serialization module has been documented extensively under the :ref:`serialization-scala` section. In this section we will point out the different APIs that are available in Akka for Java based serialization of ActorRefs. The Scala APIs of ActorSerialization has implicit Format objects that set up the type class based serialization. In the Java API, the Format objects need to be specified explicitly. Serialization of ActorRef -========================= +------------------------- The following are the Java APIs for serialization of local ActorRefs: @@ -26,10 +32,9 @@ The following are the Java APIs for serialization of local ActorRefs: The following steps describe the procedure for serializing an Actor and ActorRef. Serialization of a Stateless Actor -================================== +---------------------------------- Step 1: Define the Actor ------------------------- .. code-block:: scala @@ -40,7 +45,6 @@ Step 1: Define the Actor } Step 2: Define the typeclass instance for the actor ---------------------------------------------------- Note how the generated Java classes are accessed using the $class based naming convention of the Scala compiler. @@ -58,7 +62,7 @@ Note how the generated Java classes are accessed using the $class based naming c } } -**Step 3: Serialize and de-serialize** +Step 3: Serialize and de-serialize The following JUnit snippet first creates an actor using the default constructor. The actor is, as we saw above a stateless one. Then it is serialized and de-serialized to get back the original actor. Being stateless, the de-serialized version behaves in the same way on a message as the original actor. @@ -91,12 +95,11 @@ The following JUnit snippet first creates an actor using the default constructor } Serialization of a Stateful Actor -================================= +--------------------------------- Let's now have a look at how to serialize an actor that carries a state with it. Here the expectation is that the serialization of the actor will also persist the state information. And after de-serialization we will get back the state with which it was serialized. Step 1: Define the Actor ------------------------- Here we consider an actor defined in Scala. We will however serialize using the Java APIs. @@ -119,7 +122,6 @@ Here we consider an actor defined in Scala. We will however serialize using the Note the actor has a state in the form of an Integer. And every message that the actor receives, it replies with an addition to the integer member. Step 2: Define the instance of the typeclass --------------------------------------------- .. code-block:: java @@ -141,7 +143,6 @@ Step 2: Define the instance of the typeclass Note the usage of Protocol Buffers to serialize the state of the actor. Step 3: Serialize and de-serialize ----------------------------------- .. code-block:: java diff --git a/akka-docs/scala/serialization.rst b/akka-docs/scala/serialization.rst index a0b0e312e6..39f9304bc8 100644 --- a/akka-docs/scala/serialization.rst +++ b/akka-docs/scala/serialization.rst @@ -1,10 +1,16 @@ +.. _serialization-scala: + Serialization (Scala) ===================== +.. sidebar:: Contents + + .. contents:: :local: + Module stability: **SOLID** Serialization of ActorRef -========================= +------------------------- An Actor can be serialized in two different ways: @@ -13,7 +19,7 @@ An Actor can be serialized in two different ways: Both of these can be sent as messages over the network and/or store them to disk, in a persistent storage backend etc. -Actor serialization in Akka is implemented through a type class 'Format[T <: Actor]' which publishes the 'fromBinary' and 'toBinary' methods for serialization. Here's the complete definition of the type class: +Actor serialization in Akka is implemented through a type class ``Format[T <: Actor]`` which publishes the ``fromBinary`` and ``toBinary`` methods for serialization. Here's the complete definition of the type class: .. code-block:: scala @@ -31,15 +37,14 @@ Actor serialization in Akka is implemented through a type class 'Format[T <: Act // client needs to implement Format[] for the respective actor trait Format[T <: Actor] extends FromBinary[T] with ToBinary[T] -**Deep serialization of an Actor and ActorRef** ------------------------------------------------ +Deep serialization of an Actor and ActorRef +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -You can serialize the whole actor deeply, e.g. both the 'ActorRef' and then instance of its 'Actor'. This can be useful if you want to move an actor from one node to another, or if you want to store away an actor, with its state, into a database. +You can serialize the whole actor deeply, e.g. both the ``ActorRef`` and then instance of its ``Actor``. This can be useful if you want to move an actor from one node to another, or if you want to store away an actor, with its state, into a database. Here is an example of how to serialize an Actor. Step 1: Define the actor -^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: scala @@ -54,7 +59,6 @@ Step 1: Define the actor } Step 2: Implement the type class for the actor -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: scala @@ -72,7 +76,6 @@ Step 2: Implement the type class for the actor } Step 3: Import the type class module definition and serialize / de-serialize -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: scala @@ -90,7 +93,8 @@ Step 3: Import the type class module definition and serialize / de-serialize (actor2 !! "hello").getOrElse("_") should equal("world 3") } -**Helper Type Class for Stateless Actors** +Helper Type Class for Stateless Actors +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If your actor is stateless, then you can use the helper trait that Akka provides to serialize / de-serialize. Here's the definition: @@ -138,9 +142,10 @@ and use it for serialization: (actor2 !! "hello").getOrElse("_") should equal("world") } -**Helper Type Class for actors with external serializer** +Helper Type Class for actors with external serializer +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Use the trait 'SerializerBasedActorFormat' for specifying serializers. +Use the trait ``SerializerBasedActorFormat`` for specifying serializers. .. code-block:: scala @@ -192,14 +197,14 @@ and serialize / de-serialize .. (actor2 !! "hello").getOrElse("_") should equal("world 3") } -**Serialization of a RemoteActorRef** -------------------------------------- +Serialization of a RemoteActorRef +--------------------------------- -You can serialize an 'ActorRef' to an immutable, network-aware Actor reference that can be freely shared across the network, a reference that "remembers" and stay mapped to its original Actor instance and host node, and will always work as expected. +You can serialize an ``ActorRef`` to an immutable, network-aware Actor reference that can be freely shared across the network, a reference that "remembers" and stay mapped to its original Actor instance and host node, and will always work as expected. -The 'RemoteActorRef' serialization is based upon Protobuf (Google Protocol Buffers) and you don't need to do anything to use it, it works on any 'ActorRef' (as long as the actor has **not** implemented one of the 'SerializableActor' traits, since then deep serialization will happen). +The ``RemoteActorRef`` serialization is based upon Protobuf (Google Protocol Buffers) and you don't need to do anything to use it, it works on any ``ActorRef`` (as long as the actor has **not** implemented one of the ``SerializableActor`` traits, since then deep serialization will happen). -Currently Akka will **not** autodetect an 'ActorRef' as part of your message and serialize it for you automatically, so you have to do that manually or as part of your custom serialization mechanisms. +Currently Akka will **not** autodetect an ``ActorRef`` as part of your message and serialize it for you automatically, so you have to do that manually or as part of your custom serialization mechanisms. Here is an example of how to serialize an Actor. @@ -209,14 +214,14 @@ Here is an example of how to serialize an Actor. val bytes = toBinary(actor1) -To deserialize the 'ActorRef' to a 'RemoteActorRef' you need to use the 'fromBinaryToRemoteActorRef(bytes: Array[Byte])' method on the 'ActorRef' companion object: +To deserialize the ``ActorRef`` to a ``RemoteActorRef`` you need to use the ``fromBinaryToRemoteActorRef(bytes: Array[Byte])`` method on the ``ActorRef`` companion object: .. code-block:: scala import RemoteActorSerialization._ val actor2 = fromBinaryToRemoteActorRef(bytes) -You can also pass in a class loader to load the 'ActorRef' class and dependencies from: +You can also pass in a class loader to load the ``ActorRef`` class and dependencies from: .. code-block:: scala @@ -226,14 +231,12 @@ You can also pass in a class loader to load the 'ActorRef' class and dependencie Deep serialization of a TypedActor ---------------------------------- -Serialization of typed actors works almost the same way as untyped actors. You can serialize the whole actor deeply, e.g. both the 'proxied ActorRef' and the instance of its 'TypedActor'. +Serialization of typed actors works almost the same way as untyped actors. You can serialize the whole actor deeply, e.g. both the 'proxied ActorRef' and the instance of its ``TypedActor``. Here is the example from above implemented as a TypedActor. -^ Step 1: Define the actor -^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: scala @@ -252,7 +255,6 @@ Step 1: Define the actor } Step 2: Implement the type class for the actor -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: scala @@ -266,7 +268,6 @@ Step 2: Implement the type class for the actor } Step 3: Import the type class module definition and serialize / de-serialize -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: scala @@ -278,12 +279,12 @@ Step 3: Import the type class module definition and serialize / de-serialize val typedActor2: MyTypedActor = fromBinaryJ(bytes, f) //type hint needed typedActor2.requestReply("hello") -- + Serialization of a remote typed ActorRef ---------------------------------------- -To deserialize the TypedActor to a 'RemoteTypedActorRef' (an aspectwerkz proxy to a RemoteActorRef) you need to use the 'fromBinaryToRemoteTypedActorRef(bytes: Array[Byte])' method on 'RemoteTypedActorSerialization' object: +To deserialize the TypedActor to a ``RemoteTypedActorRef`` (an aspectwerkz proxy to a RemoteActorRef) you need to use the ``fromBinaryToRemoteTypedActorRef(bytes: Array[Byte])`` method on ``RemoteTypedActorSerialization`` object: .. code-block:: scala @@ -294,7 +295,7 @@ To deserialize the TypedActor to a 'RemoteTypedActorRef' (an aspectwerkz proxy t val typedActor2 = fromBinaryToRemoteTypedActorRef(bytes, classLoader) Compression -=========== +----------- Akka has a helper class for doing compression of binary data. This can be useful for example when storing data in one of the backing storages. It currently supports LZF which is a very fast compression algorithm suited for runtime dynamic compression. @@ -309,24 +310,28 @@ Here is an example of how it can be used: val uncompressBytes = Compression.LZF.uncompress(compressBytes) Using the Serializable trait and Serializer class for custom serialization -========================================================================== +-------------------------------------------------------------------------- -If you are sending messages to a remote Actor and these messages implement one of the predefined interfaces/traits in the 'akka.serialization.Serializable.*' object, then Akka will transparently detect which serialization format it should use as wire protocol and will automatically serialize and deserialize the message according to this protocol. +If you are sending messages to a remote Actor and these messages implement one of the predefined interfaces/traits in the ``akka.serialization.Serializable.*`` object, then Akka will transparently detect which serialization format it should use as wire protocol and will automatically serialize and deserialize the message according to this protocol. Each serialization interface/trait in -* akka.serialization.Serializable.* -> has a matching serializer in -* akka.serialization.Serializer.* + +- akka.serialization.Serializable.* + +has a matching serializer in + +- akka.serialization.Serializer.* Note however that if you are using one of the Serializable interfaces then you don’t have to do anything else in regard to sending remote messages. The ones currently supported are (besides the default which is regular Java serialization): -* ScalaJSON (Scala only) -* JavaJSON (Java but some Scala structures) -* SBinary (Scala only) -* Protobuf (Scala and Java) -Apart from the above, Akka also supports Scala object serialization through `SJSON `_ that implements APIs similar to 'akka.serialization.Serializer.*'. See the section on SJSON below for details. +- ScalaJSON (Scala only) +- JavaJSON (Java but some Scala structures) +- SBinary (Scala only) +- Protobuf (Scala and Java) + +Apart from the above, Akka also supports Scala object serialization through `SJSON `_ that implements APIs similar to ``akka.serialization.Serializer.*``. See the section on SJSON below for details. Protobuf -------- @@ -481,8 +486,8 @@ You may also see this exception when trying to serialize a case class with out a @BeanInfo case class Empty() // cannot be serialized - SJSON: Scala -------------- +SJSON: Scala +------------ SJSON supports serialization of Scala objects into JSON. It implements support for built in Scala structures like List, Map or String as well as custom objects. SJSON is available as an Apache 2 licensed project on Github `here `_. @@ -535,7 +540,7 @@ What you get back from is a JsValue, an abstraction of the JSON object model. Fo Serialization of Embedded Objects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - SJSON supports serialization of Scala objects that have other embedded objects. Suppose you have the following Scala classes .. Here Contact has an embedded Address Map .. +SJSON supports serialization of Scala objects that have other embedded objects. Suppose you have the following Scala classes .. Here Contact has an embedded Address Map .. .. code-block:: scala @@ -593,7 +598,7 @@ With SJSON, I can do the following: "Market Street" should equal( (r ># { ('addresses ? obj) andThen ('residence ? obj) andThen ('street ? str) })) -^ + Changing property names during serialization ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -619,7 +624,7 @@ When this will be serialized out, the property name will be changed. JsString("ISBN") -> JsString("012-456372") ) -^ + Serialization with ignore properties ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -653,7 +658,7 @@ The annotation @JSONProperty can be used to selectively ignore fields. When I se Similarly, we can ignore properties of an object **only** if they are null and not ignore otherwise. Just specify the annotation @JSONProperty as @JSONProperty {val ignoreIfNull = true}. -^ + Serialization with Type Hints for Generic Data Members ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -892,7 +897,8 @@ and the serialization in action in the REPL: There are other nifty ways to implement case class serialization using sjson. For more details, have a look at the `wiki `_ for sjson. -**JSON: Java** +JSON: Java +---------- Use the akka.serialization.Serialization.JavaJSON base class with its toJSONmethod. Akka’s Java JSON is based upon the Jackson library. @@ -924,7 +930,6 @@ Use the akka.serialization.SerializerFactory.getJavaJSON to do generic JSON seri String json = factory.getJavaJSON().out(foo); Foo fooCopy = factory.getJavaJSON().in(json, Foo.class); -- SBinary: Scala -------------- @@ -942,37 +947,43 @@ Here is an example of using the akka.serialization.Serializer.SBinary serializer val usersCopy = Serializer.SBinary.in(bytes, Some(classOf[List[Tuple2[String,String]]])) If you need to serialize your own user-defined objects then you have to do three things: -# Define an empty constructor -# Mix in the Serializable.SBinary[T] trait, and implement its methods: -## fromBytes(bytes: Array[Byte])[T] -## toBytes: Array[Byte] -# Create an implicit sbinary.Format[T] object for your class. Which means that you have to define its two methods: -## reads(in: Input): T; in which you read in all the fields in your object, using read[FieldType](in)and recreate it. -## writes(out: Output, value: T): Unit; in which you write out all the fields in your object, using write[FieldType](out, value.field). + +- Define an empty constructor +- Mix in the Serializable.SBinary[T] trait, and implement its methods: + + - fromBytes(bytes: Array[Byte])[T] + - toBytes: Array[Byte] + +- Create an implicit sbinary.Format[T] object for your class. Which means that you have to define its two methods: + + - reads(in: Input): T; in which you read in all the fields in your object, using read[FieldType](in)and recreate it. + - writes(out: Output, value: T): Unit; in which you write out all the fields in your object, using write[FieldType](out, value.field). Here is an example: -``_ -case class User(val usernamePassword: Tuple2[String, String], val email: String, val age: Int) - extends Serializable.SBinary[User] { - import sbinary.DefaultProtocol._ - import sbinary.Operations._ - def this() = this(null, null, 0) +.. code-block:: scala - implicit object UserFormat extends Format[User] { - def reads(in : Input) = User( - read[Tuple2[String, String]](in), - read[String](in), - read[Int](in)) - def writes(out: Output, value: User) = { - write[Tuple2[String, String]](out, value.usernamePassword) - write[String](out, value.email) - write[Int](out, value.age) + case class User(val usernamePassword: Tuple2[String, String], val email: String, val age: Int) + extends Serializable.SBinary[User] { + import sbinary.DefaultProtocol._ + import sbinary.Operations._ + + def this() = this(null, null, 0) + + implicit object UserFormat extends Format[User] { + def reads(in : Input) = User( + read[Tuple2[String, String]](in), + read[String](in), + read[Int](in)) + def writes(out: Output, value: User) = { + write[Tuple2[String, String]](out, value.usernamePassword) + write[String](out, value.email) + write[Int](out, value.age) + } } + + def fromBytes(bytes: Array[Byte]) = fromByteArray[User](bytes) + + def toBytes: Array[Byte] = toByteArray(this) } - def fromBytes(bytes: Array[Byte]) = fromByteArray[User](bytes) - - def toBytes: Array[Byte] = toByteArray(this) -} -``_ From 1c29885f3da971abc185e00b71bce17a5f67f74c Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Fri, 29 Apr 2011 17:09:22 +0200 Subject: [PATCH 081/112] Reviewed and improved remote-actors doc --- .../remoteinterface/RemoteInterface.scala | 3 +- akka-docs/java/remote-actors.rst | 351 +++++++++--------- akka-docs/scala/remote-actors.rst | 135 +++---- .../ServerInitiatedRemoteActorSample.scala | 26 +- 4 files changed, 268 insertions(+), 247 deletions(-) diff --git a/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala b/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala index 7b61f224e8..906f8b8d18 100644 --- a/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala +++ b/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala @@ -354,7 +354,8 @@ trait RemoteServerModule extends RemoteModule { def registerByUuid(actorRef: ActorRef): Unit /** - * Register Remote Actor by a specific 'id' passed as argument. + * Register Remote Actor by a specific 'id' passed as argument. The actor is registered by UUID rather than ID + * when prefixing the handle with the “uuid:” protocol. *

    * NOTE: If you use this method to register your remote actor then you must unregister the actor by this ID yourself. */ diff --git a/akka-docs/java/remote-actors.rst b/akka-docs/java/remote-actors.rst index 15786c7a6a..3894f2dacc 100644 --- a/akka-docs/java/remote-actors.rst +++ b/akka-docs/java/remote-actors.rst @@ -1,6 +1,10 @@ Remote Actors (Java) ==================== +.. sidebar:: Contents + + .. contents:: :local: + Module stability: **SOLID** Akka supports starting interacting with UntypedActors and TypedActors on remote nodes using a very efficient and scalable NIO implementation built upon `JBoss Netty `_ and `Google Protocol Buffers `_ . @@ -142,12 +146,6 @@ The default behavior is that the remote client will maintain a transaction log o If you choose a capacity higher than 0, then a bounded queue will be used and if the limit of the queue is reached then a 'RemoteClientMessageBufferException' will be thrown. -You can also get an Array with all the messages that the remote client has failed to send. Since the remote client events passes you an instance of the RemoteClient you have an easy way to act upon failure and do something with these messages (while waiting for them to be retried). - -.. code-block:: java - - Object[] pending = Actors.remote().pendingMessages(); - Running Remote Server in untrusted mode --------------------------------------- @@ -253,21 +251,13 @@ You can also generate the secure cookie by using the 'Crypt' object and its 'gen The secure cookie is a cryptographically secure randomly generated byte array turned into a SHA-1 hash. -Remote Actors -------------- - -Akka has two types of remote actors: - -* Client-initiated and managed. Here it is the client that creates the remote actor and "moves it" to the server. -* Server-initiated and managed. Here it is the server that creates the remote actor and the client can ask for a handle to this actor. - -They are good for different use-cases. The client-initiated are great when you want to monitor an actor on another node since it allows you to link to it and supervise it using the regular supervision semantics. They also make RPC completely transparent. The server-initiated, on the other hand, are great when you have a service running on the server that you want clients to connect to, and you want full control over the actor on the server side for security reasons etc. - Client-managed Remote UntypedActor -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +---------------------------------- DEPRECATED AS OF 1.1 +The client creates the remote actor and "moves it" to the server. + When you define an actors as being remote it is instantiated as on the remote host and your local actor becomes a proxy, it works as a handle to the remote actor. The real execution is always happening on the remote node. Here is an example: @@ -291,26 +281,31 @@ An UntypedActor can also start remote child Actors through one of the “spawn/l .. code-block:: java ... - getContext().spawnRemote(MyActor.class, hostname, port); + getContext().spawnRemote(MyActor.class, hostname, port, timeoutInMsForFutures); getContext().spawnLinkRemote(MyActor.class, hostname, port, timeoutInMsForFutures); ... Server-managed Remote UntypedActor -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +---------------------------------- + +Here it is the server that creates the remote actor and the client can ask for a handle to this actor. Server side setup -***************** +^^^^^^^^^^^^^^^^^ The API for server managed remote actors is really simple. 2 methods only: .. code-block:: java + import akka.actor.Actors; + import akka.actor.UntypedActor; + class MyActor extends UntypedActor { public void onReceive(Object message) throws Exception { ... } } - Actors.remote().start("localhost", 2552).register("hello-service", Actors.actorOf(HelloWorldActor.class); + Actors.remote().start("localhost", 2552).register("hello-service", Actors.actorOf(HelloWorldActor.class)); Actors created like this are automatically started. @@ -322,88 +317,6 @@ You can also register an actor by its UUID rather than ID or handle. This is don server.unregister("uuid:" + actor.uuid); -Client side usage -***************** - -.. code-block:: java - - ActorRef actor = Actors.remote().actorFor("hello-service", "localhost", 2552); - actor.sendOneWay("Hello"); - -There are many variations on the 'remote()#actorFor' method. Here are some of them: - -.. code-block:: java - - ... = actorFor(className, hostname, port); - ... = actorFor(className, timeout, hostname, port); - ... = actorFor(uuid, className, hostname, port); - ... = actorFor(uuid, className, timeout, hostname, port); - ... // etc - -All of these also have variations where you can pass in an explicit 'ClassLoader' which can be used when deserializing messages sent from the remote actor. - -Client-managed Remote TypedActor -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -DEPRECATED AS OF 1.1 - -Remote Typed Actors are created through the 'TypedActor.newRemoteInstance' factory method. - -.. code-block:: java - - MyPOJO remoteActor = (MyPOJO)TypedActor.newRemoteInstance(MyPOJO.class, MyPOJOImpl.class, , "localhost", 2552); - -And if you want to specify the timeout: - -.. code-block:: java - - MyPOJO remoteActor = (MyPOJO)TypedActor.newRemoteInstance(MyPOJO.class, MyPOJOImpl.class, timeout, "localhost", 2552); - -You can also define the Typed Actor to be a client-managed-remote service by adding the ‘RemoteAddress’ configuration element in the declarative supervisor configuration: - -.. code-block:: java - - new Component( - Foo.class, - FooImpl.class, - new LifeCycle(new Permanent(), 1000), - 1000, - new RemoteAddress("localhost", 2552)) - -Server-managed Remote TypedActor -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -WARNING: Remote TypedActors do not work with overloaded methods on your TypedActor, refrain from using overloading. - -Server side setup -***************** - -The API for server managed remote typed actors is nearly the same as for untyped actor: - -.. code-block:: java - - import static akka.actor.Actors.*; - remote().start("localhost", 2552); - - RegistrationService typedActor = TypedActor.newInstance(RegistrationService.class, RegistrationServiceImpl.class, 2000); - remote().registerTypedActor("user-service", typedActor); - -Client side usage - -.. code-block:: java - - import static akka.actor.Actors.*; - RegistrationService actor = remote().typedActorFor(RegistrationService.class, "user-service", 5000L, "localhost", 2552); - actor.registerUser(...); - -There are variations on the 'remote()#typedActorFor' method. Here are some of them: - -.. code-block:: java - - ... = typedActorFor(interfaceClazz, serviceIdOrClassName, hostname, port); - ... = typedActorFor(interfaceClazz, serviceIdOrClassName, timeout, hostname, port); - ... = typedActorFor(interfaceClazz, serviceIdOrClassName, timeout, hostname, port, classLoader); - Session bound server side setup ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -414,17 +327,19 @@ Session bound actors are useful if you need to keep state per session, e.g. user .. code-block:: java import static akka.actor.Actors.*; + import akka.japi.Creator; + class HelloWorldActor extends Actor { ... } remote().start("localhost", 2552); - remote().registerPerSession("hello-service", new Creator[ActorRef]() { + remote().registerPerSession("hello-service", new Creator() { public ActorRef create() { return actorOf(HelloWorldActor.class); } - }) + }); Note that the second argument in registerPerSession is a Creator, it means that the create method will create a new ActorRef each invocation. It will be called to create an actor every time a session is established. @@ -443,19 +358,22 @@ There are many variations on the 'remote()#actorFor' method. Here are some of th .. code-block:: java - ... = actorFor(className, hostname, port); - ... = actorFor(className, timeout, hostname, port); - ... = actorFor(uuid, className, hostname, port); - ... = actorFor(uuid, className, timeout, hostname, port); + ... = remote().actorFor(className, hostname, port); + ... = remote().actorFor(className, timeout, hostname, port); + ... = remote().actorFor(uuid, className, hostname, port); + ... = remote().actorFor(uuid, className, timeout, hostname, port); ... // etc -Automatic remote 'sender' reference management -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +All of these also have variations where you can pass in an explicit 'ClassLoader' which can be used when deserializing messages sent from the remote actor. -Akka is automatically remote-enabling the sender Actor reference for you in order to allow the receiver to respond to the message using 'getContext().getSender().sendOneWay(msg);' or 'getContext().reply(msg);'. By default it is registering the sender reference in the remote server with the 'hostname' and 'port' from the akka.conf configuration file. The default is "localhost" and 2552 and if there is no remote server with this hostname and port then it creates and starts it. +Automatic remote 'sender' reference management +---------------------------------------------- + +The sender of a remote message will be reachable with a reply through the remote server on the node that the actor is residing, automatically. +Please note that firewalled clients won't work right now. [2011-01-05] Identifying remote actors -^^^^^^^^^^^^^^^^^^^^^^^^^ +------------------------- The 'id' field in the 'Actor' class is of importance since it is used as identifier for the remote actor. If you want to create a brand new actor every time you instantiate a remote actor then you have to set the 'id' field to a unique 'String' for each instance. If you want to reuse the same remote actor instance for each new remote actor (of the same class) you create then you don't have to do anything since the 'id' field by default is equal to the name of the actor class. @@ -463,18 +381,83 @@ Here is an example of overriding the 'id' field: .. code-block:: java - import akka.util.UUID; + import akka.actor.UntypedActor; + import com.eaio.uuid.UUID; class MyActor extends UntypedActor { public MyActor() { - getContext().setId(UUID.newUuid().toString()); + getContext().setId(new UUID().toString()); } public void onReceive(Object message) throws Exception { - ... + // ... } } +Client-managed Remote Typed Actors +---------------------------------- + +DEPRECATED AS OF 1.1 + +Remote Typed Actors are created through the 'TypedActor.newRemoteInstance' factory method. + +.. code-block:: java + + MyPOJO remoteActor = (MyPOJO) TypedActor.newRemoteInstance(MyPOJO.class, MyPOJOImpl.class, "localhost", 2552); + +And if you want to specify the timeout: + +.. code-block:: java + + MyPOJO remoteActor = (MyPOJO)TypedActor.newRemoteInstance(MyPOJO.class, MyPOJOImpl.class, timeout, "localhost", 2552); + +You can also define the Typed Actor to be a client-managed-remote service by adding the ‘RemoteAddress’ configuration element in the declarative supervisor configuration: + +.. code-block:: java + + new Component( + Foo.class, + FooImpl.class, + new LifeCycle(new Permanent(), 1000), + 1000, + new RemoteAddress("localhost", 2552)) + +Server-managed Remote Typed Actors +---------------------------------- + +WARNING: Remote TypedActors do not work with overloaded methods on your TypedActor, refrain from using overloading. + +Server side setup +^^^^^^^^^^^^^^^^^ + +The API for server managed remote typed actors is nearly the same as for untyped actor: + +.. code-block:: java + + import static akka.actor.Actors.*; + remote().start("localhost", 2552); + + RegistrationService typedActor = TypedActor.newInstance(RegistrationService.class, RegistrationServiceImpl.class, 2000); + remote().registerTypedActor("user-service", typedActor); + + +Client side usage +^^^^^^^^^^^^^^^^^ + +.. code-block:: java + + import static akka.actor.Actors.*; + RegistrationService actor = remote().typedActorFor(RegistrationService.class, "user-service", 5000L, "localhost", 2552); + actor.registerUser(...); + +There are variations on the 'remote()#typedActorFor' method. Here are some of them: + +.. code-block:: java + + ... = remote().typedActorFor(interfaceClazz, serviceIdOrClassName, hostname, port); + ... = remote().typedActorFor(interfaceClazz, serviceIdOrClassName, timeout, hostname, port); + ... = remote().typedActorFor(interfaceClazz, serviceIdOrClassName, timeout, hostname, port, classLoader); + Data Compression Configuration ------------------------------ @@ -493,44 +476,55 @@ You can configure it like this: } } +Code provisioning +----------------- + +Akka does currently not support automatic code provisioning but requires you to have the remote actor class files available on both the "client" the "server" nodes. +This is something that will be addressed soon. Until then, sorry for the inconvenience. + Subscribe to Remote Client events --------------------------------- Akka has a subscription API for remote client events. You can register an Actor as a listener and this actor will have to be able to process these events: -RemoteClientError { Throwable cause; RemoteClientModule client; InetSocketAddress remoteAddress; } -RemoteClientDisconnected { RemoteClientModule client; InetSocketAddress remoteAddress; } -RemoteClientConnected { RemoteClientModule client; InetSocketAddress remoteAddress; } -RemoteClientStarted { RemoteClientModule client; InetSocketAddress remoteAddress; } -RemoteClientShutdown { RemoteClientModule client; InetSocketAddress remoteAddress; } -RemoteClientWriteFailed { Object message; Throwable cause; RemoteClientModule client; InetSocketAddress remoteAddress; } +.. code-block:: java + + class RemoteClientError { Throwable cause; RemoteClientModule client; InetSocketAddress remoteAddress; } + class RemoteClientDisconnected { RemoteClientModule client; InetSocketAddress remoteAddress; } + class RemoteClientConnected { RemoteClientModule client; InetSocketAddress remoteAddress; } + class RemoteClientStarted { RemoteClientModule client; InetSocketAddress remoteAddress; } + class RemoteClientShutdown { RemoteClientModule client; InetSocketAddress remoteAddress; } + class RemoteClientWriteFailed { Object message; Throwable cause; RemoteClientModule client; InetSocketAddress remoteAddress; } So a simple listener actor can look like this: .. code-block:: java + import akka.actor.UntypedActor; + import akka.remoteinterface.*; + class Listener extends UntypedActor { public void onReceive(Object message) throws Exception { if (message instanceof RemoteClientError) { - RemoteClientError event = (RemoteClientError)message; - Exception cause = event.getCause(); - ... + RemoteClientError event = (RemoteClientError) message; + Throwable cause = event.getCause(); + // ... } else if (message instanceof RemoteClientConnected) { - RemoteClientConnected event = (RemoteClientConnected)message; - ... + RemoteClientConnected event = (RemoteClientConnected) message; + // ... } else if (message instanceof RemoteClientDisconnected) { - RemoteClientDisconnected event = (RemoteClientDisconnected)message; - ... + RemoteClientDisconnected event = (RemoteClientDisconnected) message; + // ... } else if (message instanceof RemoteClientStarted) { - RemoteClientStarted event = (RemoteClientStarted)message; - ... + RemoteClientStarted event = (RemoteClientStarted) message; + // ... } else if (message instanceof RemoteClientShutdown) { - RemoteClientShutdown event = (RemoteClientShutdown)message; - ... + RemoteClientShutdown event = (RemoteClientShutdown) message; + // ... } else if (message instanceof RemoteClientWriteFailed) { - RemoteClientWriteFailed event = (RemoteClientWriteFailed)message; - ... + RemoteClientWriteFailed event = (RemoteClientWriteFailed) message; + // ... } } } @@ -550,43 +544,45 @@ Subscribe to Remote Server events Akka has a subscription API for the server events. You can register an Actor as a listener and this actor will have to be able to process these events: -RemoteServerStarted { RemoteServerModule server; } -RemoteServerShutdown { RemoteServerModule server; } -RemoteServerError { Throwable cause; RemoteServerModule server; } -RemoteServerClientConnected { RemoteServerModule server; Option clientAddress; } -RemoteServerClientDisconnected { RemoteServerModule server; Option clientAddress; } -RemoteServerClientClosed { RemoteServerModule server; Option clientAddress; } -RemoteServerWriteFailed { Object request; Throwable cause; RemoteServerModule server; Option clientAddress; } +.. code-block:: java + + class RemoteServerStarted { RemoteServerModule server; } + class RemoteServerShutdown { RemoteServerModule server; } + class RemoteServerError { Throwable cause; RemoteServerModule server; } + class RemoteServerClientConnected { RemoteServerModule server; Option clientAddress; } + class RemoteServerClientDisconnected { RemoteServerModule server; Option clientAddress; } + class RemoteServerClientClosed { RemoteServerModule server; Option clientAddress; } + class RemoteServerWriteFailed { Object request; Throwable cause; RemoteServerModule server; Option clientAddress; } So a simple listener actor can look like this: .. code-block:: java + import akka.actor.UntypedActor; + import akka.remoteinterface.*; + class Listener extends UntypedActor { public void onReceive(Object message) throws Exception { - if (message instanceof RemoteServerError) { - RemoteServerError event = (RemoteServerError)message; - Exception cause = event.getCause(); - ... - } else if (message instanceof RemoteServerStarted) { - RemoteServerStarted event = (RemoteServerStarted)message; - ... - } else if (message instanceof RemoteServerShutdown) { - RemoteServerShutdown event = (RemoteServerShutdown)message; - ... - } else if (message instanceof RemoteServerClientConnected) { - RemoteServerClientConnected event = (RemoteServerClientConnected)message; - ... - } else if (message instanceof RemoteServerClientDisconnected) { - RemoteServerClientDisconnected event = (RemoteServerClientDisconnected)message; - ... - } else if (message instanceof RemoteServerClientClosed) { - RemoteServerClientClosed event = (RemoteServerClientClosed)message; - ... - } else if (message instanceof RemoteServerWriteFailed) { - RemoteServerWriteFailed event = (RemoteServerWriteFailed)message; - ... + if (message instanceof RemoteClientError) { + RemoteClientError event = (RemoteClientError) message; + Throwable cause = event.getCause(); + // ... + } else if (message instanceof RemoteClientConnected) { + RemoteClientConnected event = (RemoteClientConnected) message; + // ... + } else if (message instanceof RemoteClientDisconnected) { + RemoteClientDisconnected event = (RemoteClientDisconnected) message; + // ... + } else if (message instanceof RemoteClientStarted) { + RemoteClientStarted event = (RemoteClientStarted) message; + // ... + } else if (message instanceof RemoteClientShutdown) { + RemoteClientShutdown event = (RemoteClientShutdown) message; + // ... + } else if (message instanceof RemoteClientWriteFailed) { + RemoteClientWriteFailed event = (RemoteClientWriteFailed) message; + // ... } } } @@ -608,10 +604,27 @@ Message Serialization All messages that are sent to remote actors needs to be serialized to binary format to be able to travel over the wire to the remote node. This is done by letting your messages extend one of the traits in the 'akka.serialization.Serializable' object. If the messages don't implement any specific serialization trait then the runtime will try to use standard Java serialization. -Read more about that in the `Serialization section `_. +Here is one example, but full documentation can be found in the :ref:`serialization-java`. -Code provisioning ------------------ +Protobuf +^^^^^^^^ -Akka does currently not support automatic code provisioning but requires you to have the remote actor class files available on both the "client" the "server" nodes. -This is something that will be addressed soon. Until then, sorry for the inconvenience. +Protobuf message specification needs to be compiled with 'protoc' compiler. + +:: + + message ProtobufPOJO { + required uint64 id = 1; + required string name = 2; + required bool status = 3; + } + +Using the generated message builder to send the message to a remote actor: + +.. code-block:: java + + actor.sendOneWay(ProtobufPOJO.newBuilder() + .setId(11) + .setStatus(true) + .setName("Coltrane") + .build()); diff --git a/akka-docs/scala/remote-actors.rst b/akka-docs/scala/remote-actors.rst index 8f01882956..0f7e68d095 100644 --- a/akka-docs/scala/remote-actors.rst +++ b/akka-docs/scala/remote-actors.rst @@ -1,6 +1,10 @@ Remote Actors (Scala) ===================== +.. sidebar:: Contents + + .. contents:: :local: + Module stability: **SOLID** Akka supports starting and interacting with Actors and Typed Actors on remote nodes using a very efficient and scalable NIO implementation built upon `JBoss Netty `_ and `Google Protocol Buffers `_ . @@ -74,6 +78,7 @@ Normally you should not have to start and stop the client connection explicitly .. code-block:: scala import akka.actor.Actor._ + import java.net.InetSocketAddress remote.shutdownClientConnection(new InetSocketAddress("localhost", 6666)) //Returns true if successful, false otherwise remote.restartClientConnection(new InetSocketAddress("localhost", 6666)) //Returns true if successful, false otherwise @@ -143,12 +148,6 @@ The default behavior is that the remote client will maintain a transaction log o If you choose a capacity higher than 0, then a bounded queue will be used and if the limit of the queue is reached then a 'RemoteClientMessageBufferException' will be thrown. -You can also get an Array with all the messages that the remote client has failed to send. Since the remote client events passes you an instance of the RemoteClient you have an easy way to act upon failure and do something with these messages (while waiting for them to be retried). - -.. code-block:: scala - - val pending: Array[Any] = Actor.remote.pendingMessages - Running Remote Server in untrusted mode --------------------------------------- @@ -255,24 +254,16 @@ You can also generate the secure cookie by using the 'Crypt' object and its 'gen The secure cookie is a cryptographically secure randomly generated byte array turned into a SHA-1 hash. -Remote Actors -------------- - -Akka has two types of remote actors: - -* Client-initiated and managed. Here it is the client that creates the remote actor and "moves it" to the server. -* Server-initiated and managed. Here it is the server that creates the remote actor and the client can ask for a handle to this actor. - -They are good for different use-cases. The client-initiated are great when you want to monitor an actor on another node since it allows you to link to it and supervise it using the regular supervision semantics. They also make RPC completely transparent. The server-initiated, on the other hand, are great when you have a service running on the server that you want clients to connect to, and you want full control over the actor on the server side for security reasons etc. - Client-managed Remote Actors -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +---------------------------- DEPRECATED AS OF 1.1 -When you define an actors as being remote it is instantiated as on the remote host and your local actor becomes a proxy, it works as a handle to the remote actor. The real execution is always happening on the remote node. +The client creates the remote actor and "moves it" to the server. -Actors can be made remote by calling remote().actorOf[MyActor](host, port) +When you define an actor as being remote it is instantiated as on the remote host and your local actor becomes a proxy, it works as a handle to the remote actor. The real execution is always happening on the remote node. + +Actors can be made remote by calling remote.actorOf[MyActor](host, port) Here is an example: @@ -280,29 +271,30 @@ Here is an example: import akka.actor.Actor - class MyActor extends RemoteActor() { + class MyActor extends Actor { def receive = { case "hello" => self.reply("world") } } - val remote = Actor.remote().actorOf[MyActor]("192.68.23.769", 2552) + val remoteActor = Actor.remote.actorOf[MyActor]("192.68.23.769", 2552) An Actor can also start remote child Actors through one of the 'spawn/link' methods. These will start, link and make the Actor remote atomically. .. code-block:: scala ... - spawnRemote[MyActor](hostname, port) - spawnLinkRemote[MyActor](hostname, port) + self.spawnRemote[MyActor](hostname, port, timeout) + self.spawnLinkRemote[MyActor](hostname, port, timeout) ... Server-managed Remote Actors ---------------------------- +Here it is the server that creates the remote actor and the client can ask for a handle to this actor. + Server side setup ^^^^^^^^^^^^^^^^^ - The API for server managed remote actors is really simple. 2 methods only: .. code-block:: scala @@ -358,10 +350,10 @@ There are many variations on the 'remote#actorFor' method. Here are some of them .. code-block:: scala - ... = actorFor(className, hostname, port) - ... = actorFor(className, timeout, hostname, port) - ... = actorFor(uuid, className, hostname, port) - ... = actorFor(uuid, className, timeout, hostname, port) + ... = remote.actorFor(className, hostname, port) + ... = remote.actorFor(className, timeout, hostname, port) + ... = remote.actorFor(uuid, className, hostname, port) + ... = remote.actorFor(uuid, className, timeout, hostname, port) ... // etc All of these also have variations where you can pass in an explicit 'ClassLoader' which can be used when deserializing messages sent from the remote actor. @@ -371,11 +363,16 @@ Running sample Here is a complete running sample (also available `here `_): +Paste in the code below into two sbt concole shells. Then run: + +- ServerInitiatedRemoteActorServer.run() in one shell +- ServerInitiatedRemoteActorClient.run() in the other shell + .. code-block:: scala import akka.actor.Actor - import akka.util.Logging import Actor._ + import akka.event.EventHandler class HelloWorldActor extends Actor { def receive = { @@ -385,27 +382,27 @@ Here is a complete running sample (also available `here self.reply("world") } @@ -430,11 +427,9 @@ Here is an example of overriding the 'id' field: val actor = remote.actorOf[MyActor]("192.68.23.769", 2552) -Remote Typed Actors -------------------- -Client-managed Remote Actors -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Client-managed Remote Typed Actors +---------------------------------- DEPRECATED AS OF 1.1 @@ -458,13 +453,13 @@ You can also define an Typed Actor to be remote programmatically when creating i ... // use pojo as usual -Server-managed Remote Actors -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Server-managed Remote Typed Actors +---------------------------------- WARNING: Remote TypedActors do not work with overloaded methods on your TypedActor, refrain from using overloading. Server side setup -***************** +^^^^^^^^^^^^^^^^^ The API for server managed remote typed actors is nearly the same as for untyped actor @@ -507,20 +502,20 @@ They are also useful if you need to perform some cleanup when a client disconnec Note that the second argument in registerTypedPerSessionActor is an implicit function. It will be called to create an actor every time a session is established. Client side usage -***************** +^^^^^^^^^^^^^^^^^ .. code-block:: scala val actor = remote.typedActorFor(classOf[RegistrationService], "user-service", 5000L, "localhost", 2552) actor.registerUser(…) -There are variations on the 'RemoteClient#typedActorFor' method. Here are some of them: +There are variations on the 'remote#typedActorFor' method. Here are some of them: .. code-block:: scala - ... = typedActorFor(interfaceClazz, serviceIdOrClassName, hostname, port) - ... = typedActorFor(interfaceClazz, serviceIdOrClassName, timeout, hostname, port) - ... = typedActorFor(interfaceClazz, serviceIdOrClassName, timeout, hostname, port, classLoader) + ... = remote.typedActorFor(interfaceClazz, serviceIdOrClassName, hostname, port) + ... = remote.typedActorFor(interfaceClazz, serviceIdOrClassName, timeout, hostname, port) + ... = remote.typedActorFor(interfaceClazz, serviceIdOrClassName, timeout, hostname, port, classLoader) Data Compression Configuration ------------------------------ @@ -583,15 +578,19 @@ So a simple listener actor can look like this: .. code-block:: scala + import akka.actor.Actor + import akka.actor.Actor._ + import akka.remoteinterface._ + val listener = actorOf(new Actor { def receive = { - case RemoteClientError(cause, client, address) => ... // act upon error - case RemoteClientDisconnected(client, address) => ... // act upon disconnection - case RemoteClientConnected(client, address) => ... // act upon connection - case RemoteClientStarted(client, address) => ... // act upon client shutdown - case RemoteClientShutdown(client, address) => ... // act upon client shutdown - case RemoteClientWriteFailed(request, cause, client, address) => ... // act upon write failure - case _ => //ignore other + case RemoteClientError(cause, client, address) => //... act upon error + case RemoteClientDisconnected(client, address) => //... act upon disconnection + case RemoteClientConnected(client, address) => //... act upon connection + case RemoteClientStarted(client, address) => //... act upon client shutdown + case RemoteClientShutdown(client, address) => //... act upon client shutdown + case RemoteClientWriteFailed(request, cause, client, address) => //... act upon write failure + case _ => // ignore other } }).start() @@ -637,15 +636,19 @@ So a simple listener actor can look like this: .. code-block:: scala + import akka.actor.Actor + import akka.actor.Actor._ + import akka.remoteinterface._ + val listener = actorOf(new Actor { def receive = { - case RemoteServerStarted(server) => ... // act upon server start - case RemoteServerShutdown(server) => ... // act upon server shutdown - case RemoteServerError(cause, server) => ... // act upon server error - case RemoteServerClientConnected(server, clientAddress) => ... // act upon client connection - case RemoteServerClientDisconnected(server, clientAddress) => ... // act upon client disconnection - case RemoteServerClientClosed(server, clientAddress) => ... // act upon client connection close - case RemoteServerWriteFailed(request, cause, server, clientAddress) => ... // act upon server write failure + case RemoteServerStarted(server) => //... act upon server start + case RemoteServerShutdown(server) => //... act upon server shutdown + case RemoteServerError(cause, server) => //... act upon server error + case RemoteServerClientConnected(server, clientAddress) => //... act upon client connection + case RemoteServerClientDisconnected(server, clientAddress) => //... act upon client disconnection + case RemoteServerClientClosed(server, clientAddress) => //... act upon client connection close + case RemoteServerWriteFailed(request, cause, server, clientAddress) => //... act upon server write failure } }).start() @@ -662,7 +665,7 @@ Message Serialization All messages that are sent to remote actors needs to be serialized to binary format to be able to travel over the wire to the remote node. This is done by letting your messages extend one of the traits in the 'akka.serialization.Serializable' object. If the messages don't implement any specific serialization trait then the runtime will try to use standard Java serialization. -Here are some examples, but full documentation can be found in the `Serialization section `_. +Here are some examples, but full documentation can be found in the :ref:`serialization-scala`. Scala JSON ^^^^^^^^^^ @@ -676,7 +679,7 @@ Protobuf Protobuf message specification needs to be compiled with 'protoc' compiler. -.. code-block:: scala +:: message ProtobufPOJO { required uint64 id = 1; diff --git a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteActorSample.scala b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteActorSample.scala index cae866e6e2..0c5a9565a6 100644 --- a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteActorSample.scala +++ b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteActorSample.scala @@ -1,8 +1,8 @@ package akka.actor.remote -import akka.actor.{Actor, ActorRegistry} - +import akka.actor.Actor import Actor._ +import akka.event.EventHandler /************************************* Instructions how to run the sample: @@ -19,14 +19,12 @@ Instructions how to run the sample: * Then paste in the code below into both shells. Then run: -* ServerInitiatedRemoteActorServer.run in one shell -* ServerInitiatedRemoteActorClient.run in one shell +* ServerInitiatedRemoteActorServer.run() in one shell +* ServerInitiatedRemoteActorClient.run() in the other shell Have fun. *************************************/ class HelloWorldActor extends Actor { - self.start() - def receive = { case "Hello" => self.reply("World") } @@ -34,16 +32,22 @@ class HelloWorldActor extends Actor { object ServerInitiatedRemoteActorServer { - def main(args: Array[String]) = { - Actor.remote.start("localhost", 2552) - Actor.remote.register("hello-service", actorOf[HelloWorldActor]) + def run() { + remote.start("localhost", 2552) + remote.register("hello-service", actorOf[HelloWorldActor]) } + + def main(args: Array[String]) { run() } } object ServerInitiatedRemoteActorClient { - def main(args: Array[String]) = { - val actor = Actor.remote.actorFor("hello-service", "localhost", 2552) + + def run() { + val actor = remote.actorFor("hello-service", "localhost", 2552) val result = actor !! "Hello" + EventHandler.info("Result from Remote Actor: %s", result) } + + def main(args: Array[String]) { run() } } From c2486cd52ced11a133c54981b08e39a8601cc39b Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Fri, 29 Apr 2011 17:15:00 +0200 Subject: [PATCH 082/112] Fixing ticket 808 --- .../src/main/scala/akka/AkkaException.scala | 2 +- .../src/main/scala/akka/actor/Actor.scala | 21 +++--- .../main/scala/akka/actor/Supervisor.scala | 2 +- .../src/main/scala/akka/config/Config.scala | 4 +- .../main/scala/akka/dataflow/DataFlow.scala | 2 +- .../scala/akka/dispatch/Dispatchers.scala | 16 ++--- .../src/main/scala/akka/dispatch/Future.scala | 2 +- .../scala/akka/dispatch/MailboxHandling.scala | 2 +- .../main/scala/akka/event/EventHandler.scala | 7 +- .../remoteinterface/RemoteInterface.scala | 32 +++++---- .../scala/akka/util/ReflectiveAccess.scala | 72 ++++++++++--------- .../remote/netty/NettyRemoteSupport.scala | 2 +- .../scala/akka/testkit/TestActorRef.scala | 8 ++- .../scala/akka/transactor/Coordination.scala | 2 +- 14 files changed, 95 insertions(+), 79 deletions(-) diff --git a/akka-actor/src/main/scala/akka/AkkaException.scala b/akka-actor/src/main/scala/akka/AkkaException.scala index 748df1ced0..fe0bac916e 100644 --- a/akka-actor/src/main/scala/akka/AkkaException.scala +++ b/akka-actor/src/main/scala/akka/AkkaException.scala @@ -16,7 +16,7 @@ import java.net.{InetAddress, UnknownHostException} * * @author Jonas Bonér */ -class AkkaException(message: String = "") extends RuntimeException(message) with Serializable { +class AkkaException(message: String = "", cause: Throwable = null) extends RuntimeException(message, cause) with Serializable { val uuid = "%s_%s".format(AkkaException.hostname, newUuid) override lazy val toString = { diff --git a/akka-actor/src/main/scala/akka/actor/Actor.scala b/akka-actor/src/main/scala/akka/actor/Actor.scala index cf4c1bf042..104283d853 100644 --- a/akka-actor/src/main/scala/akka/actor/Actor.scala +++ b/akka-actor/src/main/scala/akka/actor/Actor.scala @@ -67,12 +67,12 @@ case class MaximumNumberOfRestartsWithinTimeRangeReached( @BeanProperty val lastExceptionCausingRestart: Throwable) extends LifeCycleMessage // Exceptions for Actors -class ActorStartException private[akka](message: String) extends AkkaException(message) -class IllegalActorStateException private[akka](message: String) extends AkkaException(message) -class ActorKilledException private[akka](message: String) extends AkkaException(message) -class ActorInitializationException private[akka](message: String) extends AkkaException(message) -class ActorTimeoutException private[akka](message: String) extends AkkaException(message) -class InvalidMessageException private[akka](message: String) extends AkkaException(message) +class ActorStartException private[akka](message: String, cause: Throwable = null) extends AkkaException(message, cause) +class IllegalActorStateException private[akka](message: String, cause: Throwable = null) extends AkkaException(message, cause) +class ActorKilledException private[akka](message: String, cause: Throwable = null) extends AkkaException(message, cause) +class ActorInitializationException private[akka](message: String, cause: Throwable = null) extends AkkaException(message, cause) +class ActorTimeoutException private[akka](message: String, cause: Throwable = null) extends AkkaException(message, cause) +class InvalidMessageException private[akka](message: String, cause: Throwable = null) extends AkkaException(message, cause) /** * This message is thrown by default when an Actors behavior doesn't match a message @@ -161,12 +161,15 @@ object Actor extends ListenerManagement { */ def actorOf(clazz: Class[_ <: Actor]): ActorRef = new LocalActorRef(() => { import ReflectiveAccess.{ createInstance, noParams, noArgs } - createInstance[Actor](clazz.asInstanceOf[Class[_]], noParams, noArgs).getOrElse( - throw new ActorInitializationException( + createInstance[Actor](clazz.asInstanceOf[Class[_]], noParams, noArgs) match { + case r: Right[Exception, Actor] => r.b + case l: Left[Exception, Actor] => throw new ActorInitializationException( "Could not instantiate Actor of " + clazz + "\nMake sure Actor is NOT defined inside a class/trait," + "\nif so put it outside the class/trait, f.e. in a companion object," + - "\nOR try to change: 'actorOf[MyActor]' to 'actorOf(new MyActor)'.")) + "\nOR try to change: 'actorOf[MyActor]' to 'actorOf(new MyActor)'.", l.a) + } + }, None) /** diff --git a/akka-actor/src/main/scala/akka/actor/Supervisor.scala b/akka-actor/src/main/scala/akka/actor/Supervisor.scala index e32b515ae5..50071524dc 100644 --- a/akka-actor/src/main/scala/akka/actor/Supervisor.scala +++ b/akka-actor/src/main/scala/akka/actor/Supervisor.scala @@ -13,7 +13,7 @@ import java.util.concurrent.{CopyOnWriteArrayList, ConcurrentHashMap} import java.net.InetSocketAddress import akka.config.Supervision._ -class SupervisorException private[akka](message: String) extends AkkaException(message) +class SupervisorException private[akka](message: String, cause: Throwable = null) extends AkkaException(message, cause) /** * Factory object for creating supervisors declarative. It creates instances of the 'Supervisor' class. diff --git a/akka-actor/src/main/scala/akka/config/Config.scala b/akka-actor/src/main/scala/akka/config/Config.scala index 7d50e59cd7..1b5d8f774e 100644 --- a/akka-actor/src/main/scala/akka/config/Config.scala +++ b/akka-actor/src/main/scala/akka/config/Config.scala @@ -6,8 +6,8 @@ package akka.config import akka.AkkaException -class ConfigurationException(message: String) extends AkkaException(message) -class ModuleNotAvailableException(message: String) extends AkkaException(message) +class ConfigurationException(message: String, cause: Throwable = null) extends AkkaException(message, cause) +class ModuleNotAvailableException(message: String, cause: Throwable = null) extends AkkaException(message, cause) /** * Loads up the configuration (from the akka.conf file). diff --git a/akka-actor/src/main/scala/akka/dataflow/DataFlow.scala b/akka-actor/src/main/scala/akka/dataflow/DataFlow.scala index 446bc9652b..258bc4fff0 100644 --- a/akka-actor/src/main/scala/akka/dataflow/DataFlow.scala +++ b/akka-actor/src/main/scala/akka/dataflow/DataFlow.scala @@ -23,7 +23,7 @@ object DataFlow { object Start object Exit - class DataFlowVariableException(msg: String) extends AkkaException(msg) + class DataFlowVariableException(message: String, cause: Throwable = null) extends AkkaException(message, cause) /** * Executes the supplied thunk in another thread. diff --git a/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala b/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala index 04ff6a9504..eee5d53c51 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala @@ -187,14 +187,14 @@ object Dispatchers { case "GlobalExecutorBasedEventDriven" => GlobalExecutorBasedEventDrivenDispatcherConfigurator case fqn => ReflectiveAccess.getClassFor[MessageDispatcherConfigurator](fqn) match { - case Some(clazz) => - val instance = ReflectiveAccess.createInstance[MessageDispatcherConfigurator](clazz, Array[Class[_]](), Array[AnyRef]()) - if (instance.isEmpty) - throw new IllegalArgumentException("Cannot instantiate MessageDispatcherConfigurator type [%s], make sure it has a default no-args constructor" format fqn) - else - instance.get - case None => - throw new IllegalArgumentException("Unknown MessageDispatcherConfigurator type [%s]" format fqn) + case r: Right[_, Class[MessageDispatcherConfigurator]] => + ReflectiveAccess.createInstance[MessageDispatcherConfigurator](r.b, Array[Class[_]](), Array[AnyRef]()) match { + case r: Right[Exception, MessageDispatcherConfigurator] => r.b + case l: Left[Exception, MessageDispatcherConfigurator] => + throw new IllegalArgumentException("Cannot instantiate MessageDispatcherConfigurator type [%s], make sure it has a default no-args constructor" format fqn, l.a) + } + case l: Left[Exception, _] => + throw new IllegalArgumentException("Unknown MessageDispatcherConfigurator type [%s]" format fqn, l.a) } } map { _ configure cfg diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index ff0b6fdc57..11c124e55c 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -19,7 +19,7 @@ import java.util.{LinkedList => JLinkedList} import scala.collection.mutable.Stack import annotation.tailrec -class FutureTimeoutException(message: String) extends AkkaException(message) +class FutureTimeoutException(message: String, cause: Throwable = null) extends AkkaException(message, cause) object Futures { diff --git a/akka-actor/src/main/scala/akka/dispatch/MailboxHandling.scala b/akka-actor/src/main/scala/akka/dispatch/MailboxHandling.scala index cacdefe95c..388d8f10b0 100644 --- a/akka-actor/src/main/scala/akka/dispatch/MailboxHandling.scala +++ b/akka-actor/src/main/scala/akka/dispatch/MailboxHandling.scala @@ -11,7 +11,7 @@ import java.util.{Queue, List, Comparator, PriorityQueue} import java.util.concurrent._ import akka.util._ -class MessageQueueAppendFailedException(message: String) extends AkkaException(message) +class MessageQueueAppendFailedException(message: String, cause: Throwable = null) extends AkkaException(message, cause) /** * @author Jonas Bonér diff --git a/akka-actor/src/main/scala/akka/event/EventHandler.scala b/akka-actor/src/main/scala/akka/event/EventHandler.scala index 1d7d81c1b6..15dd7eaa30 100644 --- a/akka-actor/src/main/scala/akka/event/EventHandler.scala +++ b/akka-actor/src/main/scala/akka/event/EventHandler.scala @@ -220,14 +220,15 @@ object EventHandler extends ListenerManagement { } defaultListeners foreach { listenerName => try { - ReflectiveAccess.getClassFor[Actor](listenerName) map { clazz => - addListener(Actor.actorOf(clazz).start()) + ReflectiveAccess.getClassFor[Actor](listenerName) match { + case r: Right[_, Class[Actor]] => addListener(Actor.actorOf(r.b).start()) + case l: Left[Exception,_] => throw l.a } } catch { case e: Exception => throw new ConfigurationException( "Event Handler specified in config can't be loaded [" + listenerName + - "] due to [" + e.toString + "]") + "] due to [" + e.toString + "]", e) } } } diff --git a/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala b/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala index 7b61f224e8..695885ad9a 100644 --- a/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala +++ b/akka-actor/src/main/scala/akka/remoteinterface/RemoteInterface.scala @@ -116,7 +116,7 @@ case class RemoteServerWriteFailed( class RemoteClientException private[akka] ( message: String, @BeanProperty val client: RemoteClientModule, - val remoteAddress: InetSocketAddress) extends AkkaException(message) + val remoteAddress: InetSocketAddress, cause: Throwable = null) extends AkkaException(message, cause) /** * Thrown when the remote server actor dispatching fails for some reason. @@ -189,13 +189,14 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule def actorOf(clazz: Class[_ <: Actor], host: String, port: Int): ActorRef = { import ReflectiveAccess.{ createInstance, noParams, noArgs } clientManagedActorOf(() => - createInstance[Actor](clazz.asInstanceOf[Class[_]], noParams, noArgs).getOrElse( - throw new ActorInitializationException( - "Could not instantiate Actor" + - "\nMake sure Actor is NOT defined inside a class/trait," + - "\nif so put it outside the class/trait, f.e. in a companion object," + - "\nOR try to change: 'actorOf[MyActor]' to 'actorOf(new MyActor)'.")), - host, port) + createInstance[Actor](clazz.asInstanceOf[Class[_]], noParams, noArgs) match { + case r: Right[_, Actor] => r.b + case l: Left[Exception, _] => throw new ActorInitializationException( + "Could not instantiate Actor" + + "\nMake sure Actor is NOT defined inside a class/trait," + + "\nif so put it outside the class/trait, f.e. in a companion object," + + "\nOR try to change: 'actorOf[MyActor]' to 'actorOf(new MyActor)'.", l.a) + }, host, port) } /** @@ -217,13 +218,14 @@ abstract class RemoteSupport extends ListenerManagement with RemoteServerModule def actorOf[T <: Actor : Manifest](host: String, port: Int): ActorRef = { import ReflectiveAccess.{ createInstance, noParams, noArgs } clientManagedActorOf(() => - createInstance[Actor](manifest[T].erasure.asInstanceOf[Class[_]], noParams, noArgs).getOrElse( - throw new ActorInitializationException( - "Could not instantiate Actor" + - "\nMake sure Actor is NOT defined inside a class/trait," + - "\nif so put it outside the class/trait, f.e. in a companion object," + - "\nOR try to change: 'actorOf[MyActor]' to 'actorOf(new MyActor)'.")), - host, port) + createInstance[Actor](manifest[T].erasure.asInstanceOf[Class[_]], noParams, noArgs) match { + case r: Right[_, Actor] => r.b + case l: Left[Exception, _] => throw new ActorInitializationException( + "Could not instantiate Actor" + + "\nMake sure Actor is NOT defined inside a class/trait," + + "\nif so put it outside the class/trait, f.e. in a companion object," + + "\nOR try to change: 'actorOf[MyActor]' to 'actorOf(new MyActor)'.", l.a) + }, host, port) } protected override def manageLifeCycleOfListeners = false diff --git a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala index cda46c1a95..6164be7bef 100644 --- a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala +++ b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala @@ -42,12 +42,16 @@ object ReflectiveAccess { lazy val isEnabled = remoteSupportClass.isDefined def ensureEnabled = if (!isEnabled) { - val e = new ModuleNotAvailableException( - "Can't load the remoting module, make sure that akka-remote.jar is on the classpath") + val e = new ModuleNotAvailableException("Can't load the remoting module, make sure that akka-remote.jar is on the classpath") EventHandler.debug(this, e.toString) throw e } - val remoteSupportClass: Option[Class[_ <: RemoteSupport]] = getClassFor(TRANSPORT) + val remoteSupportClass = getClassFor[RemoteSupport](TRANSPORT) match { + case r: Right[_, Class[RemoteSupport]] => Some(r.b) + case l: Left[Exception,_] => + EventHandler.debug(this, l.a) + None + } protected[akka] val defaultRemoteSupport: Option[() => RemoteSupport] = remoteSupportClass map { remoteClass => @@ -55,9 +59,11 @@ object ReflectiveAccess { remoteClass, Array[Class[_]](), Array[AnyRef]() - ) getOrElse { + ) match { + case r: Right[Exception, RemoteSupport] => r.b + case l: Left[Exception, RemoteSupport] => val e = new ModuleNotAvailableException( - "Can't instantiate [%s] - make sure that akka-remote.jar is on the classpath".format(remoteClass.getName)) + "Can't instantiate [%s] - make sure that akka-remote.jar is on the classpath".format(remoteClass.getName), l.a) EventHandler.debug(this, e.toString) throw e } @@ -114,7 +120,12 @@ object ReflectiveAccess { getObjectFor("akka.cloud.cluster.Cluster$") val serializerClass: Option[Class[_]] = - getClassFor("akka.serialization.Serializer") + getClassFor("akka.serialization.Serializer") match { + case r: Right[_, Class[_]] => Some(r.b) + case l: Left[Exception,_] => + EventHandler.debug(this, l.toString) + None + } def ensureEnabled = if (!isEnabled) throw new ModuleNotAvailableException( "Feature is only available in Akka Cloud") @@ -125,17 +136,15 @@ object ReflectiveAccess { def createInstance[T](clazz: Class[_], params: Array[Class[_]], - args: Array[AnyRef]): Option[T] = try { + args: Array[AnyRef]): Either[Exception,T] = try { assert(clazz ne null) assert(params ne null) assert(args ne null) val ctor = clazz.getDeclaredConstructor(params: _*) ctor.setAccessible(true) - Some(ctor.newInstance(args: _*).asInstanceOf[T]) + Right(ctor.newInstance(args: _*).asInstanceOf[T]) } catch { - case e: Exception => - EventHandler.debug(this, e.toString) - None + case e: Exception => Left(e) } def createInstance[T](fqn: String, @@ -145,11 +154,11 @@ object ReflectiveAccess { assert(params ne null) assert(args ne null) getClassFor(fqn) match { - case Some(clazz) => - val ctor = clazz.getDeclaredConstructor(params: _*) + case r: Right[Exception, Class[T]] => + val ctor = r.b.getDeclaredConstructor(params: _*) ctor.setAccessible(true) Some(ctor.newInstance(args: _*).asInstanceOf[T]) - case None => None + case _ => None } } catch { case e: Exception => @@ -159,11 +168,11 @@ object ReflectiveAccess { def getObjectFor[T](fqn: String, classloader: ClassLoader = loader): Option[T] = try {//Obtains a reference to $MODULE$ getClassFor(fqn) match { - case Some(clazz) => - val instance = clazz.getDeclaredField("MODULE$") + case r: Right[Exception, Class[T]] => + val instance = r.b.getDeclaredField("MODULE$") instance.setAccessible(true) Option(instance.get(null).asInstanceOf[T]) - case None => None + case _ => None } } catch { case e: ExceptionInInitializerError => @@ -171,45 +180,44 @@ object ReflectiveAccess { throw e } - def getClassFor[T](fqn: String, classloader: ClassLoader = loader): Option[Class[T]] = { + def getClassFor[T](fqn: String, classloader: ClassLoader = loader): Either[Exception,Class[T]] = try { assert(fqn ne null) // First, use the specified CL val first = try { - Option(classloader.loadClass(fqn).asInstanceOf[Class[T]]) + Right(classloader.loadClass(fqn).asInstanceOf[Class[T]]) } catch { - case c: ClassNotFoundException => None + case c: ClassNotFoundException => Left(c) } - if (first.isDefined) first + if (first.isRight) first else { // Second option is to use the ContextClassLoader val second = try { - Option(Thread.currentThread.getContextClassLoader.loadClass(fqn).asInstanceOf[Class[T]]) + Right(Thread.currentThread.getContextClassLoader.loadClass(fqn).asInstanceOf[Class[T]]) } catch { - case c: ClassNotFoundException => None + case c: ClassNotFoundException => Left(c) } - if (second.isDefined) second + if (second.isRight) second else { val third = try { - // Don't try to use "loader" if we got the default "classloader" parameter - if (classloader ne loader) Option(loader.loadClass(fqn).asInstanceOf[Class[T]]) - else None + if (classloader ne loader) Right(loader.loadClass(fqn).asInstanceOf[Class[T]]) else Left(null) //Horrid } catch { - case c: ClassNotFoundException => None + case c: ClassNotFoundException => Left(c) } - if (third.isDefined) third + if (third.isRight) third else { - // Last option is Class.forName try { - Option(Class.forName(fqn).asInstanceOf[Class[T]]) + Right(Class.forName(fqn).asInstanceOf[Class[T]]) // Last option is Class.forName } catch { - case c: ClassNotFoundException => None + case c: ClassNotFoundException => Left(c) } } } } + } catch { + case e: Exception => Left(e) } } diff --git a/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala b/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala index 7196231c2d..7caea56e88 100644 --- a/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala +++ b/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala @@ -41,7 +41,7 @@ import java.util.concurrent.atomic.{AtomicReference, AtomicBoolean} import java.util.concurrent._ import akka.AkkaException -class RemoteClientMessageBufferException(message: String) extends AkkaException(message) +class RemoteClientMessageBufferException(message: String, cause: Throwable = null) extends AkkaException(message, cause) object RemoteEncoder { def encode(rmp: RemoteMessageProtocol): AkkaRemoteProtocol = { diff --git a/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala b/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala index a31582ac3a..53ceed69eb 100644 --- a/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala +++ b/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala @@ -72,12 +72,14 @@ object TestActorRef { def apply[T <: Actor : Manifest] : TestActorRef[T] = new TestActorRef[T] ({ () => import ReflectiveAccess.{ createInstance, noParams, noArgs } - createInstance[T](manifest[T].erasure, noParams, noArgs).getOrElse( - throw new ActorInitializationException( + createInstance[T](manifest[T].erasure, noParams, noArgs) match { + case r: Right[_, T] => r.b + case l: Left[Exception, _] => throw new ActorInitializationException( "Could not instantiate Actor" + "\nMake sure Actor is NOT defined inside a class/trait," + "\nif so put it outside the class/trait, f.e. in a companion object," + - "\nOR try to change: 'actorOf[MyActor]' to 'actorOf(new MyActor)'.")) + "\nOR try to change: 'actorOf[MyActor]' to 'actorOf(new MyActor)'.", l.a) + } }) } diff --git a/akka-typed-actor/src/main/scala/akka/transactor/Coordination.scala b/akka-typed-actor/src/main/scala/akka/transactor/Coordination.scala index 33a74fea79..1f72176eed 100644 --- a/akka-typed-actor/src/main/scala/akka/transactor/Coordination.scala +++ b/akka-typed-actor/src/main/scala/akka/transactor/Coordination.scala @@ -9,7 +9,7 @@ import akka.stm.Atomic import scala.util.DynamicVariable -class CoordinateException private[akka](message: String) extends AkkaException(message) +class CoordinateException private[akka](message: String, cause: Throwable = null) extends AkkaException(message, cause) /** * Coordinating transactions between typed actors. From 8d95f180a97a709ef6573785d85bfca5394f6441 Mon Sep 17 00:00:00 2001 From: Roland Kuhn Date: Fri, 29 Apr 2011 21:11:20 +0200 Subject: [PATCH 083/112] also adapt createInstance(String, ...) and getObjectFor --- .../scala/akka/util/ReflectiveAccess.scala | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala index 6164be7bef..f1b76da678 100644 --- a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala +++ b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala @@ -91,7 +91,12 @@ object ReflectiveAccess { "Can't load the typed actor module, make sure that akka-typed-actor.jar is on the classpath") val typedActorObjectInstance: Option[TypedActorObject] = - getObjectFor("akka.actor.TypedActor$") + getObjectFor[TypedActorObject]("akka.actor.TypedActor$") match { + case r: Right[_, TypedActorObject] => Some(r.b) + case l: Left[Exception, _] => + EventHandler.debug(this, l.toString) + None + } def resolveFutureIfMessageIsJoinPoint(message: Any, future: Future[_]): Boolean = { ensureEnabled @@ -117,7 +122,12 @@ object ReflectiveAccess { lazy val isEnabled = clusterObjectInstance.isDefined val clusterObjectInstance: Option[AnyRef] = - getObjectFor("akka.cloud.cluster.Cluster$") + getObjectFor[AnyRef]("akka.cloud.cluster.Cluster$") match { + case r: Right[_, AnyRef] => Some(r.b) + case l: Left[Exception, _] => + EventHandler.debug(this, l.toString) + None + } val serializerClass: Option[Class[_]] = getClassFor("akka.serialization.Serializer") match { @@ -150,34 +160,34 @@ object ReflectiveAccess { def createInstance[T](fqn: String, params: Array[Class[_]], args: Array[AnyRef], - classloader: ClassLoader = loader): Option[T] = try { + classloader: ClassLoader = loader): Either[Exception,T] = try { assert(params ne null) assert(args ne null) getClassFor(fqn) match { - case r: Right[Exception, Class[T]] => + case r: Right[_, Class[T]] => val ctor = r.b.getDeclaredConstructor(params: _*) ctor.setAccessible(true) - Some(ctor.newInstance(args: _*).asInstanceOf[T]) - case _ => None + Right(ctor.newInstance(args: _*).asInstanceOf[T]) + case l : Left[Exception, _] => Left(l.a) } } catch { case e: Exception => - EventHandler.debug(this, e.toString) - None + Left(e) } - def getObjectFor[T](fqn: String, classloader: ClassLoader = loader): Option[T] = try {//Obtains a reference to $MODULE$ + //Obtains a reference to fqn.MODULE$ + def getObjectFor[T](fqn: String, classloader: ClassLoader = loader): Either[Exception,T] = try { getClassFor(fqn) match { - case r: Right[Exception, Class[T]] => + case r: Right[_, Class[_]] => val instance = r.b.getDeclaredField("MODULE$") instance.setAccessible(true) - Option(instance.get(null).asInstanceOf[T]) - case _ => None + val obj = instance.get(null) + if (obj eq null) Left(new NullPointerException) else Right(obj.asInstanceOf[T]) + case l : Left[Exception, _] => Left(l.a) } } catch { - case e: ExceptionInInitializerError => - EventHandler.debug(this, e.toString) - throw e + case e: Exception => + Left(e) } def getClassFor[T](fqn: String, classloader: ClassLoader = loader): Either[Exception,Class[T]] = try { From 20c5be20e61c7d5f98e441dda76e159ca1fc8379 Mon Sep 17 00:00:00 2001 From: Roland Kuhn Date: Sat, 30 Apr 2011 11:22:51 +0200 Subject: [PATCH 084/112] fix exception logging --- akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala index f1b76da678..374a60928a 100644 --- a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala +++ b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala @@ -94,7 +94,7 @@ object ReflectiveAccess { getObjectFor[TypedActorObject]("akka.actor.TypedActor$") match { case r: Right[_, TypedActorObject] => Some(r.b) case l: Left[Exception, _] => - EventHandler.debug(this, l.toString) + EventHandler.debug(this, l.a.toString) None } @@ -125,7 +125,7 @@ object ReflectiveAccess { getObjectFor[AnyRef]("akka.cloud.cluster.Cluster$") match { case r: Right[_, AnyRef] => Some(r.b) case l: Left[Exception, _] => - EventHandler.debug(this, l.toString) + EventHandler.debug(this, l.a.toString) None } @@ -133,7 +133,7 @@ object ReflectiveAccess { getClassFor("akka.serialization.Serializer") match { case r: Right[_, Class[_]] => Some(r.b) case l: Left[Exception,_] => - EventHandler.debug(this, l.toString) + EventHandler.debug(this, l.a.toString) None } From 08049c5c9d6d1463df036bf7949ba0d3f96553ae Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sat, 30 Apr 2011 13:18:04 +0200 Subject: [PATCH 085/112] Rewriting matches to use case-class extractors --- .../scala/akka/util/ReflectiveAccess.scala | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala index 374a60928a..14b46ceae5 100644 --- a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala +++ b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala @@ -47,9 +47,9 @@ object ReflectiveAccess { throw e } val remoteSupportClass = getClassFor[RemoteSupport](TRANSPORT) match { - case r: Right[_, Class[RemoteSupport]] => Some(r.b) - case l: Left[Exception,_] => - EventHandler.debug(this, l.a) + case Right(value) => Some(value) + case Left(exception) => + EventHandler.debug(this, exception.toString) None } @@ -60,10 +60,10 @@ object ReflectiveAccess { Array[Class[_]](), Array[AnyRef]() ) match { - case r: Right[Exception, RemoteSupport] => r.b - case l: Left[Exception, RemoteSupport] => + case Right(value) => value + case Left(exception) => val e = new ModuleNotAvailableException( - "Can't instantiate [%s] - make sure that akka-remote.jar is on the classpath".format(remoteClass.getName), l.a) + "Can't instantiate [%s] - make sure that akka-remote.jar is on the classpath".format(remoteClass.getName), exception) EventHandler.debug(this, e.toString) throw e } @@ -92,9 +92,9 @@ object ReflectiveAccess { val typedActorObjectInstance: Option[TypedActorObject] = getObjectFor[TypedActorObject]("akka.actor.TypedActor$") match { - case r: Right[_, TypedActorObject] => Some(r.b) - case l: Left[Exception, _] => - EventHandler.debug(this, l.a.toString) + case Right(value) => Some(value) + case Left(exception)=> + EventHandler.debug(this, exception.toString) None } @@ -123,17 +123,17 @@ object ReflectiveAccess { val clusterObjectInstance: Option[AnyRef] = getObjectFor[AnyRef]("akka.cloud.cluster.Cluster$") match { - case r: Right[_, AnyRef] => Some(r.b) - case l: Left[Exception, _] => - EventHandler.debug(this, l.a.toString) + case Right(value) => Some(value) + case Left(exception) => + EventHandler.debug(this, exception.toString) None } val serializerClass: Option[Class[_]] = getClassFor("akka.serialization.Serializer") match { - case r: Right[_, Class[_]] => Some(r.b) - case l: Left[Exception,_] => - EventHandler.debug(this, l.a.toString) + case Right(value) => Some(value) + case Left(exception) => + EventHandler.debug(this, exception.toString) None } @@ -164,11 +164,11 @@ object ReflectiveAccess { assert(params ne null) assert(args ne null) getClassFor(fqn) match { - case r: Right[_, Class[T]] => - val ctor = r.b.getDeclaredConstructor(params: _*) + case Right(value) => + val ctor = value.getDeclaredConstructor(params: _*) ctor.setAccessible(true) Right(ctor.newInstance(args: _*).asInstanceOf[T]) - case l : Left[Exception, _] => Left(l.a) + case Left(exception) => Left(exception) //We could just cast this to Either[Exception, T] but it's ugly } } catch { case e: Exception => @@ -178,12 +178,12 @@ object ReflectiveAccess { //Obtains a reference to fqn.MODULE$ def getObjectFor[T](fqn: String, classloader: ClassLoader = loader): Either[Exception,T] = try { getClassFor(fqn) match { - case r: Right[_, Class[_]] => - val instance = r.b.getDeclaredField("MODULE$") + case Right(value) => + val instance = value.getDeclaredField("MODULE$") instance.setAccessible(true) val obj = instance.get(null) if (obj eq null) Left(new NullPointerException) else Right(obj.asInstanceOf[T]) - case l : Left[Exception, _] => Left(l.a) + case Left(exception) => Left(exception) //We could just cast this to Either[Exception, T] but it's ugly } } catch { case e: Exception => From e4e53af508d9df96e16c58f757302b4749642f23 Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Sat, 30 Apr 2011 09:09:30 -0600 Subject: [PATCH 086/112] Fix Scaladoc generation failure --- akka-actor/src/main/scala/akka/dispatch/Future.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 9e657e15fa..1ca3db193a 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -311,7 +311,7 @@ sealed trait Future[+T] { * execution will fail. The normal result of getting a Future from an ActorRef using !!! will return * an untyped Future. */ - def apply[A >: T](): A @cps[Future[Any]] = shift(this flatMap _) + def apply[A >: T](): A @cps[Future[Any]] = shift(this flatMap (_: A => Future[Any])) /** * Blocks awaiting completion of this Future, then returns the resulting value, From c7444193e6e25148678aca93a585c4c50026e3c3 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Sun, 1 May 2011 17:35:05 +0200 Subject: [PATCH 087/112] Ticket 739. Beefing up config documentation. --- akka-docs/general/configuration.rst | 92 +++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 10 deletions(-) diff --git a/akka-docs/general/configuration.rst b/akka-docs/general/configuration.rst index fd19b71db4..bd293383d8 100644 --- a/akka-docs/general/configuration.rst +++ b/akka-docs/general/configuration.rst @@ -1,25 +1,30 @@ Configuration ============= +.. sidebar:: Contents + + .. contents:: :local: + Specifying the configuration file --------------------------------- -If you don't specify a configuration file then Akka uses default values. If -you want to override these then you should edit the ``akka.conf`` file in the -``AKKA_HOME/config`` directory. This config inherits from the -``akka-reference.conf`` file that you see below. Use your ``akka.conf`` to override -any property in the reference config. +If you don't specify a configuration file then Akka uses default values, corresponding to the ``akka-reference.conf`` +that you see below. You can specify your own configuration file to override any property in the reference config. +You only have to define the properties that differ from the default configuration. -The config can be specified in various ways: +The location of the config file to use can be specified in various ways: -* Define the ``-Dakka.config=...`` system property option +* Define the ``-Dakka.config=...`` system property parameter with a file path to configuration file. -* Put an ``akka.conf`` file on the classpath +* Put an ``akka.conf`` file in the root of the classpath. * Define the ``AKKA_HOME`` environment variable pointing to the root of the Akka - distribution. The config is taken from the ``AKKA_HOME/config`` directory. You + distribution. The config is taken from the ``AKKA_HOME/config/akka.conf``. You can also point to the AKKA_HOME by specifying the ``-Dakka.home=...`` system - property option. + property parameter. + +If several of these ways to specify the config file are used at the same time the precedence is the order as given above, +i.e. you can always redefine the location with the ``-Dakka.config=...`` system property. Defining the configuration file @@ -29,3 +34,70 @@ Here is the reference configuration file: .. literalinclude:: ../../config/akka-reference.conf :language: none + +A custom ``akka.conf`` might look like this: + +:: + + # In this file you can override any option defined in the 'akka-reference.conf' file. + # Copy in all or parts of the 'akka-reference.conf' file and modify as you please. + + akka { + event-handlers = ["akka.event.slf4j.Slf4jEventHandler"] + + # Comma separated list of the enabled modules. + enabled-modules = ["camel", "remote"] + + # These boot classes are loaded (and created) automatically when the Akka Microkernel boots up + # Can be used to bootstrap your application(s) + # Should be the FQN (Fully Qualified Name) of the boot class which needs to have a default constructor + boot = ["sample.camel.Boot", + "sample.myservice.Boot"] + + actor { + throughput = 10 # Throughput for ExecutorBasedEventDrivenDispatcher, set to 1 for complete fairness + } + + remote { + server { + port = 2562 # The port clients should connect to. Default is 2552 (AKKA) + } + } + } + +Specifying files for different modes +------------------------------------ + +You can use different configuration files for different purposes by specifying a mode option, either as +``-Dakka.mode=...`` system property or as ``AKKA_MODE=...`` environment variable. For example using DEBUG log level +when in development mode. Run with ``-Dakka.mode=dev`` and place the following ``akka.dev.conf`` in the root of +the classpath. + +akka.dev.conf: + +:: + + akka { + event-handler-level = "DEBUG" + } + +The mode option works in the same way when using configuration files in ``AKKA_HOME/config/`` directory. + +The mode option is not used when specifying the configuration file with ``-Dakka.config=...`` system property. + +Including files +--------------- + +Sometimes it can be useful to include another configuration file, for example if you have one ``akka.conf`` with all +environment independent settings and then override some settings for specific modes. + +akka.dev.conf: + +:: + + include "akka.conf" + + akka { + event-handler-level = "DEBUG" + } + From 56acccf82ecec2c2b7220593c047b61d1b866a68 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Sun, 1 May 2011 21:33:16 +0200 Subject: [PATCH 088/112] Added installation instructions for Sphinx etc --- akka-docs/dev/documentation.rst | 84 +++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/akka-docs/dev/documentation.rst b/akka-docs/dev/documentation.rst index 9e280220e6..04b5a31e1c 100644 --- a/akka-docs/dev/documentation.rst +++ b/akka-docs/dev/documentation.rst @@ -7,6 +7,10 @@ Documentation ############### +.. sidebar:: Contents + + .. contents:: :local: + The Akka documentation uses `reStructuredText`_ as its markup language and is built using `Sphinx`_. @@ -67,3 +71,83 @@ For example:: Here is a reference to "akka section": :ref:`akka-section` which will have the name "Akka Section". +Build the documentation +======================= + +First install `Sphinx`_. See below. + +Building +-------- + +:: + + cd akka-docs + + make html + open _build/html/index.html + + make pdf + open _build/latex/Akka.pdf + + +Installing Sphinx on OS X +------------------------- + +Install `Homebrew `_ + +Install Python and pip: + +:: + + brew install python + /usr/local/share/python/easy_install pip + +Add the Homebrew Python path to your $PATH: + +:: + + /usr/local/Cellar/python/2.7.1/bin + + +More information in case of trouble: +https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python + +Install sphinx: + +:: + + pip install sphinx + +Add sphinx_build to your $PATH: + +:: + + /usr/local/share/python + +Install BasicTeX package from: +http://www.tug.org/mactex/morepackages.html + +Add texlive bin to $PATH: + +:: + + /usr/local/texlive/2010basic/bin/universal-darwin + +Add missing tex packages: + +:: + + sudo tlmgr update --self + sudo tlmgr install titlesec + sudo tlmgr install framed + sudo tlmgr install threeparttable + sudo tlmgr install wrapfig + sudo tlmgr install helvetic + sudo tlmgr install courier + +Link the akka pygments style: + +:: + + cd /usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pygments/styles + ln -s /path/to/akka-cloud/akka-cloud-docs/themes/akka/pygments/akka.py akka.py From 3b3f8d307a15f0731934fc61308c8f59e8c6af61 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Sun, 1 May 2011 21:47:50 +0200 Subject: [PATCH 089/112] fixed typo --- akka-docs/dev/documentation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-docs/dev/documentation.rst b/akka-docs/dev/documentation.rst index 04b5a31e1c..b0da0bd698 100644 --- a/akka-docs/dev/documentation.rst +++ b/akka-docs/dev/documentation.rst @@ -150,4 +150,4 @@ Link the akka pygments style: :: cd /usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/pygments/styles - ln -s /path/to/akka-cloud/akka-cloud-docs/themes/akka/pygments/akka.py akka.py + ln -s /path/to/akka/akka-docs/themes/akka/pygments/akka.py akka.py From de7741a4644e4cbb63db661be90cc72ba0525a70 Mon Sep 17 00:00:00 2001 From: alarmnummer Date: Mon, 2 May 2011 11:40:51 +0200 Subject: [PATCH 090/112] added jmm documentation for actors and stm --- akka-docs/general/jmm.rst | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 akka-docs/general/jmm.rst diff --git a/akka-docs/general/jmm.rst b/akka-docs/general/jmm.rst new file mode 100644 index 0000000000..ed7bffb748 --- /dev/null +++ b/akka-docs/general/jmm.rst @@ -0,0 +1,33 @@ +Akka and the Java Memory Model +================================ + +Prior to Java 5, the Java Memory Model (JMM) was broken. It was possible to get all kinds of strange results like unpredictable merged writes made by concurrent executing threads, unexpected reordering of instructions, and even final fields were not guaranteed to be final. With Java 5 and JSR-133, the Java Memory Model is clearly specified. This specification makes it possible to write code that performs, but doesn't cause concurrency problems. The Java Memory Model is specified in 'happens before'-rules, e.g.: +* **monitor lock rule**: a release of a lock happens before every subsequent acquire of the same lock. +* **volatile variable rule**: a write of a volatile variable happens before every subsequent read of the same volatile variable + +The 'happens before'-rules clearly specify which visibility guarantees are provided on memory and which re-orderings are allowed. Without these rules it would not be possible to write concurrent and performant code in Java. + +Actors and the Java Memory Model +-------------------------------- + +With the Actors implementation in Akka, there are 2 ways multiple threads can execute actions on shared memory over time: +* if a message is send to an actor (e.g. by another actor). In most cases messages are immutable, but if that message is not a properly constructed immutable object, without happens before rules, the system still could be subject to instruction re-orderings and visibility problems (so a possible source of concurrency errors). +* if an actor makes changes to its internal state in one 'receive' method and access that state while processing another message. With the actors model you don't get any guarantee that the same thread will be executing the same actor for different messages. Without a happens before relation between these actions, there could be another source of concurrency errors. + +To solve the 2 problems above, Akka adds the following 2 'happens before'-rules to the JMM: +* **the actor send rule**: where the send of the message to an actor happens before the receive of the **same** actor. +* **the actor subsequent processing rule**: where processing of one message happens before processing of the next message by the **same** actor. + +Both rules only apply for the same actor instance and are not valid if different actors are used. + +STM and the Java Memory Model +----------------------------- + +The Akka STM also provides a happens before rule called: + +* **the transaction rule**: a commit on a transaction happens before every subsequent start of a transaction where there is at least 1 shared reference. + +How these rules are realized in Akka, is an implementation detail and can change over time (the exact details could even depend on the used configuration) but they will lift on the other JMM rules like the monitor lock rule or the volatile variable rule. Essentially this means that you, the Akka user, do not need to worry about adding synchronization to provide such a happens before relation, because it is the responsibility of Akka. So you have your hands free to deal with your problems and not that of the framework. + + + From 39519af3c20f815bd3982e06cafe7cf6607afcc4 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 11:50:56 +0200 Subject: [PATCH 091/112] Removing the CONFIG val in BootableActorLoaderService to fix #825 --- .../src/main/scala/akka/actor/BootableActorLoaderService.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/akka-actor/src/main/scala/akka/actor/BootableActorLoaderService.scala b/akka-actor/src/main/scala/akka/actor/BootableActorLoaderService.scala index 48c1127f84..f5112470bb 100644 --- a/akka-actor/src/main/scala/akka/actor/BootableActorLoaderService.scala +++ b/akka-actor/src/main/scala/akka/actor/BootableActorLoaderService.scala @@ -21,7 +21,6 @@ trait BootableActorLoaderService extends Bootable { protected def createApplicationClassLoader : Option[ClassLoader] = Some({ if (HOME.isDefined) { - val CONFIG = HOME.get + "/config" val DEPLOY = HOME.get + "/deploy" val DEPLOY_DIR = new File(DEPLOY) if (!DEPLOY_DIR.exists) { From 2a26a707efefd4cec1b66a4beb44d27773d35313 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Mon, 2 May 2011 12:45:54 +0200 Subject: [PATCH 092/112] Reviewed and improved serialization docs, still error with in/out, waiting for answer from Debasish --- akka-docs/java/serialization.rst | 98 ++++++++++++++------------- akka-docs/scala/serialization.rst | 108 ++++++++++-------------------- 2 files changed, 87 insertions(+), 119 deletions(-) diff --git a/akka-docs/java/serialization.rst b/akka-docs/java/serialization.rst index 813db45a9a..0a41941ba5 100644 --- a/akka-docs/java/serialization.rst +++ b/akka-docs/java/serialization.rst @@ -9,28 +9,6 @@ Serialization (Java) Akka serialization module has been documented extensively under the :ref:`serialization-scala` section. In this section we will point out the different APIs that are available in Akka for Java based serialization of ActorRefs. The Scala APIs of ActorSerialization has implicit Format objects that set up the type class based serialization. In the Java API, the Format objects need to be specified explicitly. -Serialization of ActorRef -------------------------- - -The following are the Java APIs for serialization of local ActorRefs: - -.. code-block:: scala - - /** - * Module for local actor serialization. - */ - object ActorSerialization { - // wrapper for implicits to be used by Java - def fromBinaryJ[T <: Actor](bytes: Array[Byte], format: Format[T]): ActorRef = - fromBinary(bytes)(format) - - // wrapper for implicits to be used by Java - def toBinaryJ[T <: Actor](a: ActorRef, format: Format[T], srlMailBox: Boolean = true): Array[Byte] = - toBinary(a, srlMailBox)(format) - } - -The following steps describe the procedure for serializing an Actor and ActorRef. - Serialization of a Stateless Actor ---------------------------------- @@ -38,6 +16,8 @@ Step 1: Define the Actor .. code-block:: scala + import akka.actor.UntypedActor; + public class SerializationTestActor extends UntypedActor { public void onReceive(Object msg) { getContext().replySafe("got it!"); @@ -50,6 +30,8 @@ Note how the generated Java classes are accessed using the $class based naming c .. code-block:: scala + import akka.serialization.StatelessActorFormat; + class SerializationTestActorFormat implements StatelessActorFormat { @Override public SerializationTestActor fromBinary(byte[] bytes, SerializationTestActor act) { @@ -68,6 +50,14 @@ The following JUnit snippet first creates an actor using the default constructor .. code-block:: java + import akka.actor.ActorRef; + import akka.actor.ActorTimeoutException; + import akka.actor.Actors; + import akka.actor.UntypedActor; + import akka.serialization.Format; + import akka.serialization.StatelessActorFormat; + import static akka.serialization.ActorSerialization.*; + @Test public void mustBeAbleToSerializeAfterCreateActorRefFromClass() { ActorRef ref = Actors.actorOf(SerializationTestActor.class); assertNotNull(ref); @@ -101,21 +91,23 @@ Let's now have a look at how to serialize an actor that carries a state with it. Step 1: Define the Actor -Here we consider an actor defined in Scala. We will however serialize using the Java APIs. - .. code-block:: scala - class MyUntypedActor extends UntypedActor { - var count = 0 - def onReceive(message: Any): Unit = message match { - case m: String if m == "hello" => - count = count + 1 - getContext.replyUnsafe("world " + count) - case m: String => - count = count + 1 - getContext.replyUnsafe("hello " + m + " " + count) - case _ => - throw new Exception("invalid message type") + import akka.actor.UntypedActor; + + public class MyUntypedActor extends UntypedActor { + int count = 0; + + public void onReceive(Object msg) { + if (msg.equals("hello")) { + count = count + 1; + getContext().replyUnsafe("world " + count); + } else if (msg instanceof String) { + count = count + 1; + getContext().replyUnsafe("hello " + msg + " " + count); + } else { + throw new IllegalArgumentException("invalid message type"); + } } } @@ -125,27 +117,37 @@ Step 2: Define the instance of the typeclass .. code-block:: java - class MyUntypedActorFormat implements Format { - @Override - public MyUntypedActor fromBinary(byte[] bytes, MyUntypedActor act) { - ProtobufProtocol.Counter p = - (ProtobufProtocol.Counter) new SerializerFactory().getProtobuf().fromBinary(bytes, ProtobufProtocol.Counter.class); - act.count_$eq(p.getCount()); - return act; - } + import akka.actor.UntypedActor; + import akka.serialization.Format; + import akka.serialization.SerializerFactory; - @Override - public byte[] toBinary(MyUntypedActor ac) { - return ProtobufProtocol.Counter.newBuilder().setCount(ac.count()).build().toByteArray(); - } + class MyUntypedActorFormat implements Format { + @Override + public MyUntypedActor fromBinary(byte[] bytes, MyUntypedActor act) { + ProtobufProtocol.Counter p = + (ProtobufProtocol.Counter) new SerializerFactory().getProtobuf().fromBinary(bytes, ProtobufProtocol.Counter.class); + act.count = p.getCount(); + return act; } -Note the usage of Protocol Buffers to serialize the state of the actor. + @Override + public byte[] toBinary(MyUntypedActor ac) { + return ProtobufProtocol.Counter.newBuilder().setCount(ac.count()).build().toByteArray(); + } + } + +Note the usage of Protocol Buffers to serialize the state of the actor. ProtobufProtocol.Counter is something +you need to define yourself Step 3: Serialize and de-serialize .. code-block:: java + import akka.actor.ActorRef; + import akka.actor.ActorTimeoutException; + import akka.actor.Actors; + import static akka.serialization.ActorSerialization.*; + @Test public void mustBeAbleToSerializeAStatefulActor() { ActorRef ref = Actors.actorOf(MyUntypedActor.class); assertNotNull(ref); diff --git a/akka-docs/scala/serialization.rst b/akka-docs/scala/serialization.rst index 39f9304bc8..b229b57942 100644 --- a/akka-docs/scala/serialization.rst +++ b/akka-docs/scala/serialization.rst @@ -58,10 +58,15 @@ Step 1: Define the actor } } -Step 2: Implement the type class for the actor +Step 2: Implement the type class for the actor. ProtobufProtocol.Counter is something you need to define yourself, as +explained in the Protobuf section. .. code-block:: scala + import akka.serialization.{Serializer, Format} + import akka.actor.Actor + import akka.actor.Actor._ + object BinaryFormatMyActor { implicit object MyActorFormat extends Format[MyActor] { def fromBinary(bytes: Array[Byte], act: MyActor) = { @@ -70,8 +75,7 @@ Step 2: Implement the type class for the actor act } def toBinary(ac: MyActor) = - ProtobufProtocol.Counter.newBuilder.setCount(ac.count).build.toByteArray - } + ProtobufProtocol.Counter.newBuilder.setCount(ac.count).build.toByteArray } } @@ -159,7 +163,7 @@ For a Java serializable actor: .. code-block:: scala - @serializable class MyJavaSerializableActor extends Actor { + class MyJavaSerializableActor extends Actor with scala.Serializable { var count = 0 def receive = { @@ -173,6 +177,8 @@ Create a module for the type class .. .. code-block:: scala + import akka.serialization.{SerializerBasedActorFormat, Serializer} + object BinaryFormatMyJavaSerializableActor { implicit object MyJavaSerializableActorFormat extends SerializerBasedActorFormat[MyJavaSerializableActor] { val serializer = Serializer.Java @@ -184,6 +190,7 @@ and serialize / de-serialize .. .. code-block:: scala it("should be able to serialize and de-serialize a stateful actor with a given serializer") { + import akka.actor.Actor._ import akka.serialization.ActorSerialization._ import BinaryFormatMyJavaSerializableActor._ @@ -202,7 +209,7 @@ Serialization of a RemoteActorRef You can serialize an ``ActorRef`` to an immutable, network-aware Actor reference that can be freely shared across the network, a reference that "remembers" and stay mapped to its original Actor instance and host node, and will always work as expected. -The ``RemoteActorRef`` serialization is based upon Protobuf (Google Protocol Buffers) and you don't need to do anything to use it, it works on any ``ActorRef`` (as long as the actor has **not** implemented one of the ``SerializableActor`` traits, since then deep serialization will happen). +The ``RemoteActorRef`` serialization is based upon Protobuf (Google Protocol Buffers) and you don't need to do anything to use it, it works on any ``ActorRef``. Currently Akka will **not** autodetect an ``ActorRef`` as part of your message and serialize it for you automatically, so you have to do that manually or as part of your custom serialization mechanisms. @@ -218,14 +225,14 @@ To deserialize the ``ActorRef`` to a ``RemoteActorRef`` you need to use the ``fr .. code-block:: scala - import RemoteActorSerialization._ + import akka.serialization.RemoteActorSerialization._ val actor2 = fromBinaryToRemoteActorRef(bytes) You can also pass in a class loader to load the ``ActorRef`` class and dependencies from: .. code-block:: scala - import RemoteActorSerialization._ + import akka.serialization.RemoteActorSerialization._ val actor2 = fromBinaryToRemoteActorRef(bytes, classLoader) Deep serialization of a TypedActor @@ -240,6 +247,8 @@ Step 1: Define the actor .. code-block:: scala + import akka.actor.TypedActor + trait MyTypedActor { def requestReply(s: String) : String def oneWay() : Unit @@ -252,12 +261,18 @@ Step 1: Define the actor count = count + 1 "world " + count } + + override def oneWay() { + count = count + 1 + } } Step 2: Implement the type class for the actor .. code-block:: scala + import akka.serialization.{Serializer, Format} + class MyTypedActorFormat extends Format[MyTypedActorImpl] { def fromBinary(bytes: Array[Byte], act: MyTypedActorImpl) = { val p = Serializer.Protobuf.fromBinary(bytes, Some(classOf[ProtobufProtocol.Counter])).asInstanceOf[ProtobufProtocol.Counter] @@ -271,6 +286,8 @@ Step 3: Import the type class module definition and serialize / de-serialize .. code-block:: scala + import akka.serialization.TypedActorSerialization._ + val typedActor1 = TypedActor.newInstance(classOf[MyTypedActor], classOf[MyTypedActorImpl], 1000) val f = new MyTypedActorFormat @@ -288,7 +305,7 @@ To deserialize the TypedActor to a ``RemoteTypedActorRef`` (an aspectwerkz proxy .. code-block:: scala - import RemoteTypedActorSerialization._ + import akka.serialization.RemoteTypedActorSerialization._ val typedActor = fromBinaryToRemoteTypedActorRef(bytes) // you can also pass in a class loader @@ -328,7 +345,6 @@ The ones currently supported are (besides the default which is regular Java seri - ScalaJSON (Scala only) - JavaJSON (Java but some Scala structures) -- SBinary (Scala only) - Protobuf (Scala and Java) Apart from the above, Akka also supports Scala object serialization through `SJSON `_ that implements APIs similar to ``akka.serialization.Serializer.*``. See the section on SJSON below for details. @@ -377,15 +393,16 @@ The remote Actor can then receive the Protobuf message typed as-is: JSON: Scala ----------- -Use the akka.serialization.Serialization.ScalaJSON base class with its toJSON method. Akka’s Scala JSON is based upon the SJSON library. +Use the ``akka.serialization.Serializable.ScalaJSON`` base class with its toJSON method. Akka’s Scala JSON is based upon the SJSON library. For your POJOs to be able to serialize themselves you have to extend the ScalaJSON[] trait as follows. JSON serialization is based on a type class protocol which you need to define for your own abstraction. The instance of the type class is defined as an implicit object which is used for serialization and de-serialization. You also need to implement the methods in terms of the APIs which sjson publishes. .. code-block:: scala - import akka.serialization.Serializer + import akka.serialization._ import akka.serialization.Serializable.ScalaJSON - import scala.reflect.BeanInfo + import akka.serialization.JsonSerialization._ + import akka.serialization.DefaultProtocol._ case class MyMessage(val id: String, val value: Tuple2[String, Int]) extends ScalaJSON[MyMessage] { // type class instance @@ -427,7 +444,7 @@ Here are the steps that you need to follow: .. code-block:: scala - import DefaultProtocol._ + import akka.serialization.DefaultProtocol._ implicit val MyMessageFormat: sjson.json.Format[MyMessage] = asProduct2("id", "value")(MyMessage)(MyMessage.unapply(_).get) @@ -436,6 +453,7 @@ Here are the steps that you need to follow: .. code-block:: scala import akka.serialization.Serializer.ScalaJSON + import akka.serialization.JsonSerialization._ val o = MyMessage("dg", ("akka", 100)) fromjson[MyMessage](tojson(o)) should equal(o) @@ -480,7 +498,7 @@ So if you see something like that: it means, that you haven't got a @BeanInfo annotation on your class. -You may also see this exception when trying to serialize a case class with out an attribute like this: +You may also see this exception when trying to serialize a case class without any attributes, like this: .. code-block:: scala @@ -900,12 +918,15 @@ There are other nifty ways to implement case class serialization using sjson. Fo JSON: Java ---------- -Use the akka.serialization.Serialization.JavaJSON base class with its toJSONmethod. Akka’s Java JSON is based upon the Jackson library. +Use the ``akka.serialization.Serializable.JavaJSON`` base class with its toJSONmethod. Akka’s Java JSON is based upon the Jackson library. -For your POJOs to be able to serialize themselves you have to extend the JavaJSON trait. +For your POJOs to be able to serialize themselves you have to extend the JavaJSON base class. .. code-block:: java + import akka.serialization.Serializable.JavaJSON; + import akka.serialization.SerializerFactory; + class MyMessage extends JavaJSON { private String name = null; public MyMessage(String name) { @@ -931,59 +952,4 @@ Use the akka.serialization.SerializerFactory.getJavaJSON to do generic JSON seri Foo fooCopy = factory.getJavaJSON().in(json, Foo.class); -SBinary: Scala --------------- - -To serialize Scala structures you can use SBinary serializer. SBinary can serialize all primitives and most default Scala datastructures; such as List, Tuple, Map, Set, BigInt etc. - -Here is an example of using the akka.serialization.Serializer.SBinary serializer to serialize standard Scala library objects. - -.. code-block:: scala - - import akka.serialization.Serializer - import sbinary.DefaultProtocol._ // you always need to import these implicits - val users = List(("user1", "passwd1"), ("user2", "passwd2"), ("user3", "passwd3")) - val bytes = Serializer.SBinary.out(users) - val usersCopy = Serializer.SBinary.in(bytes, Some(classOf[List[Tuple2[String,String]]])) - -If you need to serialize your own user-defined objects then you have to do three things: - -- Define an empty constructor -- Mix in the Serializable.SBinary[T] trait, and implement its methods: - - - fromBytes(bytes: Array[Byte])[T] - - toBytes: Array[Byte] - -- Create an implicit sbinary.Format[T] object for your class. Which means that you have to define its two methods: - - - reads(in: Input): T; in which you read in all the fields in your object, using read[FieldType](in)and recreate it. - - writes(out: Output, value: T): Unit; in which you write out all the fields in your object, using write[FieldType](out, value.field). - -Here is an example: - -.. code-block:: scala - - case class User(val usernamePassword: Tuple2[String, String], val email: String, val age: Int) - extends Serializable.SBinary[User] { - import sbinary.DefaultProtocol._ - import sbinary.Operations._ - - def this() = this(null, null, 0) - - implicit object UserFormat extends Format[User] { - def reads(in : Input) = User( - read[Tuple2[String, String]](in), - read[String](in), - read[Int](in)) - def writes(out: Output, value: User) = { - write[Tuple2[String, String]](out, value.usernamePassword) - write[String](out, value.email) - write[Int](out, value.age) - } - } - - def fromBytes(bytes: Array[Byte]) = fromByteArray[User](bytes) - - def toBytes: Array[Byte] = toByteArray(this) - } From 2d2bdeec7ac018dcbe6f88936542542b3fbad68a Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Mon, 2 May 2011 09:09:14 -0600 Subject: [PATCH 093/112] Will always infer type as Any, so should explicitly state it. --- akka-actor/src/main/scala/akka/dispatch/Future.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 1ca3db193a..34e9c6da9b 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -291,8 +291,8 @@ object Future { * * The Delimited Continuations compiler plugin must be enabled in order to use this method. */ - def flow[A](body: => A @cps[Future[A]], timeout: Long = Actor.TIMEOUT): Future[A] = - reset(new DefaultCompletableFuture[A](timeout).completeWithResult(body)) + def flow(body: => Any @cps[Future[Any]], timeout: Long = Actor.TIMEOUT): Future[Any] = + reset(new DefaultCompletableFuture[Any](timeout).completeWithResult(body)) private[akka] val callbacksPendingExecution = new ThreadLocal[Option[Stack[() => Unit]]]() { override def initialValue = None From 769078e7101e49335afe9afc532716e9b50fb538 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 17:13:56 +0200 Subject: [PATCH 094/112] Added alter and alterOff to Agent, #758 --- .../src/main/scala/akka/agent/Agent.scala | 61 +++++++++++++++++-- akka-stm/src/test/scala/agent/AgentSpec.scala | 17 ++++++ 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/akka-stm/src/main/scala/akka/agent/Agent.scala b/akka-stm/src/main/scala/akka/agent/Agent.scala index 80db8bff21..d64dd22715 100644 --- a/akka-stm/src/main/scala/akka/agent/Agent.scala +++ b/akka-stm/src/main/scala/akka/agent/Agent.scala @@ -7,7 +7,7 @@ package akka.agent import akka.stm._ import akka.actor.Actor import akka.japi.{Function => JFunc, Procedure => JProc} -import akka.dispatch.{Dispatchers, Future} +import akka.dispatch.{DefaultCompletableFuture, Dispatchers, Future} /** * Used internally to send functions. @@ -115,6 +115,23 @@ class Agent[T](initialValue: T) { else dispatch } + /** + * Dispatch a function to update the internal state, and return a Future where that new state can be obtained + * within the given timeout + */ + def alter(f: T => T)(timeout: Long): Future[T] = { + def dispatch = updater.!!!(Update(f),timeout) + if (Stm.activeTransaction) { + val result = new DefaultCompletableFuture[T](timeout) + get //Join xa + deferred { + result completeWith dispatch + } //Attach deferred-block to current transaction + result + } + else dispatch + } + /** * Dispatch a new value for the internal state. Behaves the same * as sending a fuction (x => newValue). @@ -140,6 +157,24 @@ class Agent[T](initialValue: T) { value }) + /** + * Dispatch a function to update the internal state but on its own thread, + * and return a Future where that new state can be obtained within the given timeout. + * This does not use the reactive thread pool and can be used for long-running + * or blocking operations. Dispatches using either `alterOff` or `alter` will + * still be executed in order. + */ + def alterOff(f: T => T)(timeout: Long): Future[T] = { + val result = new DefaultCompletableFuture[T](timeout) + send((value: T) => { + suspend + val threadBased = Actor.actorOf(new ThreadBasedAgentUpdater(this)).start() + result completeWith threadBased.!!!(Update(f), timeout) + value + }) + result + } + /** * A future to the current value that will be completed after any currently * queued updates. @@ -194,6 +229,13 @@ class Agent[T](initialValue: T) { */ def send(f: JFunc[T, T]): Unit = send(x => f(x)) + /** + * Java API + * Dispatch a function to update the internal state, and return a Future where that new state can be obtained + * within the given timeout + */ + def alter(f: JFunc[T, T], timeout: Long): Future[T] = alter(x => f(x))(timeout) + /** * Java API: * Dispatch a function to update the internal state but on its own thread. @@ -203,6 +245,16 @@ class Agent[T](initialValue: T) { */ def sendOff(f: JFunc[T, T]): Unit = sendOff(x => f(x)) + /** + * Java API: + * Dispatch a function to update the internal state but on its own thread, + * and return a Future where that new state can be obtained within the given timeout. + * This does not use the reactive thread pool and can be used for long-running + * or blocking operations. Dispatches using either `alterOff` or `alter` will + * still be executed in order. + */ + def alterOff(f: JFunc[T, T], timeout: Long): Unit = alterOff(x => f(x))(timeout) + /** * Java API: * Map this agent to a new agent, applying the function to the internal state. @@ -232,7 +284,7 @@ class AgentUpdater[T](agent: Agent[T]) extends Actor { def receive = { case update: Update[T] => - atomic(txFactory) { agent.ref alter update.function } + self.reply_?(atomic(txFactory) { agent.ref alter update.function }) case Get => self reply agent.get case _ => () } @@ -247,8 +299,9 @@ class ThreadBasedAgentUpdater[T](agent: Agent[T]) extends Actor { val txFactory = TransactionFactory(familyName = "ThreadBasedAgentUpdater", readonly = false) def receive = { - case update: Update[T] => { - atomic(txFactory) { agent.ref alter update.function } + case update: Update[T] => try { + self.reply_?(atomic(txFactory) { agent.ref alter update.function }) + } finally { agent.resume self.stop() } diff --git a/akka-stm/src/test/scala/agent/AgentSpec.scala b/akka-stm/src/test/scala/agent/AgentSpec.scala index ed07dea6bd..18233917c3 100644 --- a/akka-stm/src/test/scala/agent/AgentSpec.scala +++ b/akka-stm/src/test/scala/agent/AgentSpec.scala @@ -49,6 +49,23 @@ class AgentSpec extends WordSpec with MustMatchers { agent.close } + "maintain order between alter and alterOff" in { + + val agent = Agent("a") + + val r1 = agent.alter(_ + "b")(5000) + val r2 = agent.alterOff((s: String) => { Thread.sleep(2000); s + "c" })(5000) + val r3 = agent.alter(_ + "d")(5000) + + r1.await.resultOrException.get must be === "ab" + r2.await.resultOrException.get must be === "abc" + r3.await.resultOrException.get must be === "abcd" + + agent() must be ("abcd") + + agent.close + } + "be immediately readable" in { val countDown = new CountDownFunction[Int] val readLatch = new CountDownLatch(1) From 9bb184021114936de6661d932a21ff50e4ff97ff Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 17:34:17 +0200 Subject: [PATCH 095/112] Fixing ticket #824 --- .../src/main/scala/akka/remote/BootableRemoteActorService.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala b/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala index aa88be92c0..5293f3a0a0 100644 --- a/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala +++ b/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala @@ -4,7 +4,6 @@ package akka.remote -import akka.config.Config.config import akka.actor. {Actor, BootableActorLoaderService} import akka.util. {ReflectiveAccess, Bootable} From 03943cd536a187317a6a49ef536fb093e1a1ec32 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 18:02:56 +0200 Subject: [PATCH 096/112] Fixing typos in scaladoc --- akka-stm/src/main/scala/akka/agent/Agent.scala | 6 +++--- akka-stm/src/main/scala/akka/stm/package.scala | 2 +- .../src/main/scala/akka/actor/TypedActor.scala | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/akka-stm/src/main/scala/akka/agent/Agent.scala b/akka-stm/src/main/scala/akka/agent/Agent.scala index d64dd22715..378ee2995e 100644 --- a/akka-stm/src/main/scala/akka/agent/Agent.scala +++ b/akka-stm/src/main/scala/akka/agent/Agent.scala @@ -134,13 +134,13 @@ class Agent[T](initialValue: T) { /** * Dispatch a new value for the internal state. Behaves the same - * as sending a fuction (x => newValue). + * as sending a function (x => newValue). */ def send(newValue: T): Unit = send(x => newValue) /** * Dispatch a new value for the internal state. Behaves the same - * as sending a fuction (x => newValue). + * as sending a function (x => newValue). */ def update(newValue: T) = send(newValue) @@ -214,7 +214,7 @@ class Agent[T](initialValue: T) { def resume() = updater.dispatcher.resume(updater) /** - * Closes the agents and makes it eligable for garbage collection. + * Closes the agents and makes it eligible for garbage collection. * A closed agent cannot accept any `send` actions. */ def close() = updater.stop() diff --git a/akka-stm/src/main/scala/akka/stm/package.scala b/akka-stm/src/main/scala/akka/stm/package.scala index 055b1d3adf..c7587ac24a 100644 --- a/akka-stm/src/main/scala/akka/stm/package.scala +++ b/akka-stm/src/main/scala/akka/stm/package.scala @@ -5,7 +5,7 @@ package akka /** - * For easily importing everthing needed for STM. + * For easily importing everything needed for STM. */ package object stm extends akka.stm.Stm with akka.stm.StmUtil { diff --git a/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala b/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala index 591613a203..4cc1892e65 100644 --- a/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala +++ b/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala @@ -515,7 +515,7 @@ object TypedActor { * Factory method for remote typed actor. * @param intfClass interface the typed actor implements * @param targetClass implementation class of the typed actor - * @param host hostanme of the remote server + * @param host hostname of the remote server * @param port port of the remote server */ @deprecated("Will be removed after 1.1") @@ -527,7 +527,7 @@ object TypedActor { * Factory method for remote typed actor. * @param intfClass interface the typed actor implements * @param factory factory method that constructs the typed actor - * @param host hostanme of the remote server + * @param host hostname of the remote server * @param port port of the remote server */ @deprecated("Will be removed after 1.1") @@ -560,7 +560,7 @@ object TypedActor { * @param intfClass interface the typed actor implements * @param targetClass implementation class of the typed actor * @paramm timeout timeout for future - * @param host hostanme of the remote server + * @param host hostname of the remote server * @param port port of the remote server */ @deprecated("Will be removed after 1.1") @@ -573,7 +573,7 @@ object TypedActor { * @param intfClass interface the typed actor implements * @param factory factory method that constructs the typed actor * @paramm timeout timeout for future - * @param host hostanme of the remote server + * @param host hostname of the remote server * @param port port of the remote server */ @deprecated("Will be removed after 1.1") @@ -585,7 +585,7 @@ object TypedActor { * Factory method for typed actor. * @param intfClass interface the typed actor implements * @param factory factory method that constructs the typed actor - * @paramm config configuration object fo the typed actor + * @paramm config configuration object forthe typed actor */ def newInstance[T](intfClass: Class[T], factory: => AnyRef, config: TypedActorConfiguration): T = newInstance(intfClass, createActorRef(newTypedActor(factory),config), config) @@ -607,7 +607,7 @@ object TypedActor { * Factory method for typed actor. * @param intfClass interface the typed actor implements * @param targetClass implementation class of the typed actor - * @paramm config configuration object fo the typed actor + * @paramm config configuration object forthe typed actor */ def newInstance[T](intfClass: Class[T], targetClass: Class[_], config: TypedActorConfiguration): T = newInstance(intfClass, createActorRef(newTypedActor(targetClass),config), config) From 41273567868175106f669ac3753027e027b5c37b Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 18:09:46 +0200 Subject: [PATCH 097/112] Removing web.rst because of being severely outdated --- akka-docs/pending/web.rst | 99 --------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 akka-docs/pending/web.rst diff --git a/akka-docs/pending/web.rst b/akka-docs/pending/web.rst deleted file mode 100644 index 7d09ede65c..0000000000 --- a/akka-docs/pending/web.rst +++ /dev/null @@ -1,99 +0,0 @@ -Web Framework Integrations -========================== - -Play Framework -============== - -Home page: ``_ -Akka Play plugin: ``_ -Read more here: ``_ - -Lift Web Framework -================== - -Home page: ``_ - -In order to use Akka with Lift you basically just have to do one thing, add the 'AkkaServlet' to your 'web.xml'. - -web.xml -------- - -.. code-block:: xml - - - - - AkkaServlet - akka.comet.AkkaServlet - - - AkkaServlet - /* - - - - - LiftFilter - Lift Filter - The Filter that intercepts lift calls - net.liftweb.http.LiftFilter - - - LiftFilter - /* - - - -Boot class ----------- - -Lift bootstrap happens in the Lift 'Boot' class. Here is a good place to add Akka specific initialization. For example add declarative supervisor configuration to wire up the initial Actors. -Here is a full example taken from the Akka sample code, found here ``_. - -If a request is processed by Liftweb filter, Akka will not process the request. To disable processing of a request by the Lift filter : -* append partial function to LiftRules.liftRequest and return *false* value to disable processing of matching request -* use LiftRules.passNotFoundToChain to chain the request to the Akka filter - -Example of Boot class source code : -``_ -class Boot { - def boot { - // where to search snippet - LiftRules.addToPackages("sample.lift") - - LiftRules.httpAuthProtectedResource.prepend { - case (ParsePath("liftpage" :: Nil, _, _, _)) => Full(AuthRole("admin")) - } - - LiftRules.authentication = HttpBasicAuthentication("lift") { - case ("someuser", "1234", req) => { - Log.info("You are now authenticated !") - userRoles(AuthRole("admin")) - true - } - } - - LiftRules.liftRequest.append { - case Req("liftcount" :: _, _, _) => false - case Req("persistentliftcount" :: _, _, _) => false - } - LiftRules.passNotFoundToChain = true - - // Akka supervisor configuration wiring up initial Actor services - val supervisor = Supervisor( - SupervisorConfig( - RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])), - Supervise( - actorOf[SimpleService], - LifeCycle(Permanent)) :: - Supervise( - actorOf[PersistentSimpleService], - LifeCycle(Permanent)) :: - Nil)) - - // Build SiteMap - // val entries = Menu(Loc("Home", List("index"), "Home")) :: Nil - // LiftRules.setSiteMap(SiteMap(entries:_*)) - } -} -``_ From 15c2e1070df61780d3aeabd81b164cea4a297337 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 18:22:13 +0200 Subject: [PATCH 098/112] Adding a Common section to the docs and fixing the Scheduler docs --- akka-docs/common/index.rst | 7 +++++++ akka-docs/common/scheduler.rst | 23 +++++++++++++++++++++++ akka-docs/general/index.rst | 1 + akka-docs/index.rst | 1 + akka-docs/pending/scheduler.rst | 16 ---------------- 5 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 akka-docs/common/index.rst create mode 100644 akka-docs/common/scheduler.rst delete mode 100644 akka-docs/pending/scheduler.rst diff --git a/akka-docs/common/index.rst b/akka-docs/common/index.rst new file mode 100644 index 0000000000..6ed8cb1593 --- /dev/null +++ b/akka-docs/common/index.rst @@ -0,0 +1,7 @@ +Common utilities +========================== + +.. toctree:: + :maxdepth: 2 + + scheduler diff --git a/akka-docs/common/scheduler.rst b/akka-docs/common/scheduler.rst new file mode 100644 index 0000000000..bf2b813d2e --- /dev/null +++ b/akka-docs/common/scheduler.rst @@ -0,0 +1,23 @@ +Scheduler +========= + +Module stability: **SOLID** + +``Akka`` has a little scheduler written using actors. +This can be convenient if you want to schedule some periodic task for maintenance or similar. + +It allows you to register a message that you want to be sent to a specific actor at a periodic interval. + +Here is an example: +------------------- + +.. code-block:: scala + + import akka.actor.Scheduler + + //Sends messageToBeSent to receiverActor after initialDelayBeforeSending and then after each delayBetweenMessages + Scheduler.schedule(receiverActor, messageToBeSent, initialDelayBeforeSending, delayBetweenMessages, timeUnit) + + //Sends messageToBeSent to receiverActor after delayUntilSend + Scheduler.scheduleOnce(receiverActor, messageToBeSent, delayUntilSend, timeUnit) + diff --git a/akka-docs/general/index.rst b/akka-docs/general/index.rst index 367e45b9d5..6eae15cf67 100644 --- a/akka-docs/general/index.rst +++ b/akka-docs/general/index.rst @@ -4,6 +4,7 @@ General .. toctree:: :maxdepth: 2 + jmm migration-guides building-akka configuration diff --git a/akka-docs/index.rst b/akka-docs/index.rst index 11bfef862a..692664ce81 100644 --- a/akka-docs/index.rst +++ b/akka-docs/index.rst @@ -6,6 +6,7 @@ Contents intro/index general/index + common/index scala/index java/index dev/index diff --git a/akka-docs/pending/scheduler.rst b/akka-docs/pending/scheduler.rst deleted file mode 100644 index ac0c7a3a50..0000000000 --- a/akka-docs/pending/scheduler.rst +++ /dev/null @@ -1,16 +0,0 @@ -Scheduler -========= - -Module stability: **SOLID** - -Akka has a little scheduler written using actors. Can be convenient if you want to schedule some periodic task for maintenance or similar. - -It allows you to register a message that you want to be sent to a specific actor at a periodic interval. Here is an example: - -``_ -//Sends messageToBeSent to receiverActor after initialDelayBeforeSending and then after each delayBetweenMessages -Scheduler.schedule(receiverActor, messageToBeSent, initialDelayBeforeSending, delayBetweenMessages, timeUnit) - -//Sends messageToBeSent to receiverActor after delayUntilSend -Scheduler.scheduleOnce(receiverActor, messageToBeSent, delayUntilSend, timeUnit) -``_ From c978ba16199fd5abc5b62c4c9d75baebafe467cf Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 18:30:35 +0200 Subject: [PATCH 099/112] Scrapping parts of Home.rst and add a what-is-akka.rst under intro --- akka-docs/intro/index.rst | 1 + akka-docs/intro/what-is-akka.rst | 33 ++++++++++++++++++ akka-docs/pending/Home.rst | 60 -------------------------------- 3 files changed, 34 insertions(+), 60 deletions(-) create mode 100644 akka-docs/intro/what-is-akka.rst delete mode 100644 akka-docs/pending/Home.rst diff --git a/akka-docs/intro/index.rst b/akka-docs/intro/index.rst index 6550f1bd79..2de18010c4 100644 --- a/akka-docs/intro/index.rst +++ b/akka-docs/intro/index.rst @@ -4,6 +4,7 @@ Introduction .. toctree:: :maxdepth: 2 + what-is-akka why-akka getting-started-first-scala getting-started-first-scala-eclipse diff --git a/akka-docs/intro/what-is-akka.rst b/akka-docs/intro/what-is-akka.rst new file mode 100644 index 0000000000..c9f4e6bd18 --- /dev/null +++ b/akka-docs/intro/what-is-akka.rst @@ -0,0 +1,33 @@ +What is Akka? +==== + +**Akka** +^^^^^^ + +**Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Actors** + +We believe that writing correct concurrent, fault-tolerant and scalable applications is too hard. Most of the time it's because we are using the wrong tools and the wrong level of abstraction. Akka is here to change that. Using the Actor Model together with ``Software Transactional Memory`` we raise the abstraction level and provide a better platform to build correct concurrent and scalable applications. For fault-tolerance we adopt the ``Let it crash`` / ``Embrace failure`` model which have been used with great success in the telecom industry to build applications that self-heals, systems that never stop. Actors also provides the abstraction for transparent distribution and the basis for truly scalable and fault-tolerant applications. Akka is Open Source and available under the ``Apache 2 License``. + + +Download from ``_ + +**Akka implements a unique hybrid of:** +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* `Actors `_, which gives you: + * Simple and high-level abstractions for concurrency and parallelism. + * Asynchronous, non-blocking and highly performant event-driven programming model. + * Very lightweight event-driven processes (create ~6.5 million actors on 4GB RAM). +* `Failure management `_ through supervisor hierarchies with `let-it-crash `_ semantics. Excellent for writing highly fault-tolerant systems that never stop, systems that self-heal. +* `Software Transactional Memory `_ (STM). (Distributed transactions coming soon). +* `Transactors `_: combine actors and STM into transactional actors. Allows you to compose atomic message flows with automatic retry and rollback. +* `Remote actors `_: highly performant distributed actors with remote supervision and error management. +* Java and Scala API. + +**Akka can be used in two different ways:** +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* As a library: used by a web app, to be put into ‘WEB-INF/lib’ or as a regular JAR on your classpath. +* As a microkernel: stand-alone kernel, embedding a servlet container and all the other modules. + +See the `Use-case and Deployment Scenarios `_ for details. diff --git a/akka-docs/pending/Home.rst b/akka-docs/pending/Home.rst deleted file mode 100644 index 73c9f31172..0000000000 --- a/akka-docs/pending/Home.rst +++ /dev/null @@ -1,60 +0,0 @@ -Akka -==== - -**Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Actors** - -We believe that writing correct concurrent, fault-tolerant and scalable applications is too hard. Most of the time it's because we are using the wrong tools and the wrong level of abstraction. Akka is here to change that. Using the Actor Model together with Software Transactional Memory we raise the abstraction level and provide a better platform to build correct concurrent and scalable applications. For fault-tolerance we adopt the "Let it crash" / "Embrace failure" model which have been used with great success in the telecom industry to build applications that self-heals, systems that never stop. Actors also provides the abstraction for transparent distribution and the basis for truly scalable and fault-tolerant applications. Akka is Open Source and available under the Apache 2 License. - -Akka is split up into two different parts: -* Akka - Reflects all the sections under 'Scala API' and 'Java API' in the navigation bar. -* Akka Modules - Reflects all the sections under 'Add-on modules' in the navigation bar. - -Download from ``_ - -News: Akka 1.0 final is released --------------------------------- - -1.0 documentation ------------------ - -This documentation covers the latest release ready code in 'master' branch in the repository. -If you want the documentation for the 1.0 release you can find it `here `_. - -You can watch the recording of the `Akka talk at JFokus in Feb 2011 `_. - -``_ - -**Akka implements a unique hybrid of:** -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -* `Actors `_, which gives you: - * Simple and high-level abstractions for concurrency and parallelism. - * Asynchronous, non-blocking and highly performant event-driven programming model. - * Very lightweight event-driven processes (create ~6.5 million actors on 4 G RAM). -* `Failure management `_ through supervisor hierarchies with `let-it-crash `_ semantics. Excellent for writing highly fault-tolerant systems that never stop, systems that self-heal. -* `Software Transactional Memory `_ (STM). (Distributed transactions coming soon). -* `Transactors `_: combine actors and STM into transactional actors. Allows you to compose atomic message flows with automatic retry and rollback. -* `Remote actors `_: highly performant distributed actors with remote supervision and error management. -* Java and Scala API. - -**Akka also has a set of add-on modules:** -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -* `Camel `_: Expose actors as Apache Camel endpoints. -* `Spring `_: Wire up typed actors in the Spring config using Akka's namespace. -* `REST `_ (JAX-RS): Expose actors as REST services. -* `OSGi `_: Akka and all its dependency is OSGi enabled. -* `Mist `_: Expose actors as asynchronous HTTP services. -* `Security `_: Basic, Digest and Kerberos based security. -* `Microkernel `_: Run Akka as a stand-alone self-hosted kernel. -* `FSM `_: Finite State Machine support. -* `JTA `_: Let the STM interoperate with other transactional resources. -* `Pub/Sub `_: Publish-Subscribe across remote nodes. - -**Akka can be used in two different ways:** -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -* As a library: used by a web app, to be put into ‘WEB-INF/lib’ or as a regular JAR on your classpath. -* As a microkernel: stand-alone kernel, embedding a servlet container and all the other modules. - -See the `Use-case and Deployment Scenarios `_ for details. From a97bdda6e82cd142dd3532bcaee2e0d3dedaba4b Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 18:38:21 +0200 Subject: [PATCH 100/112] Converting the Akka Developer Guidelines and add then to the General section --- .../{pending => general}/developer-guidelines.rst | 12 ++++++------ akka-docs/general/index.rst | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) rename akka-docs/{pending => general}/developer-guidelines.rst (64%) diff --git a/akka-docs/pending/developer-guidelines.rst b/akka-docs/general/developer-guidelines.rst similarity index 64% rename from akka-docs/pending/developer-guidelines.rst rename to akka-docs/general/developer-guidelines.rst index bf2e9dad26..5965a2fe41 100644 --- a/akka-docs/pending/developer-guidelines.rst +++ b/akka-docs/general/developer-guidelines.rst @@ -1,4 +1,4 @@ -Developer Guidelines +Developer Guidelines (committers) ==================== Code Style @@ -6,25 +6,25 @@ Code Style The Akka code style follows `this document `_ . -Here is a code style settings file for IntelliJ IDEA. -``_ +Here is a code style settings file for ``IntelliJ IDEA``: +`Download <@http://scalablesolutions.se/akka/docs/akka-0.10/files/akka-intellij-code-style.jar>`_ Please follow the code style. Look at the code around you and mimic. Testing ------- -All code that is checked in should have tests. All testing is done with ScalaTest and ScalaCheck. +All code that is checked in **should** have tests. All testing is done with ``ScalaTest`` and ``ScalaCheck``. * Name tests as *Test.scala if they do not depend on any external stuff. That keeps surefire happy. * Name tests as *Spec.scala if they have external dependencies. -There is a testing standard that should be followed: `Ticket001Spec <@https://github.com/jboner/akka/blob/master/akka-actor/src/test/scala/akka/ticket/Ticket001Spec.scala>`_ +There is a testing standard that should be followed: `Ticket001Spec <@https://github.com/jboner/akka/blob/master/akka-actor-tests/src/test/scala/akka/ticket/Ticket001Spec.scala>`_ Actor TestKit ^^^^^^^^^^^^^ -There is a useful test kit for testing actors: `akka.util.TestKit <@https://github.com/jboner/akka/tree/master/akka-actor/src/main/scala/akka/util/TestKit.scala>`_. It enables assertions concerning replies received and their timing, there is more documentation in the ``_ module. +There is a useful test kit for testing actors: `akka.util.TestKit <@https://github.com/jboner/akka/tree/master/akka-testkit/src/main/scala/akka/testkit/TestKit.scala>`_. It enables assertions concerning replies received and their timing, there is more documentation in the ``_ module. NetworkFailureTest ^^^^^^^^^^^^^^^^^^ diff --git a/akka-docs/general/index.rst b/akka-docs/general/index.rst index 6eae15cf67..f836c00d1c 100644 --- a/akka-docs/general/index.rst +++ b/akka-docs/general/index.rst @@ -10,3 +10,4 @@ General configuration event-handler util + developer-guidelines From 25a56ef0539f83c24964233bbb10a845d9aa2399 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 18:46:45 +0200 Subject: [PATCH 101/112] Converting the issue-tracking doc and putting it under General --- akka-docs/general/index.rst | 1 + akka-docs/general/issue-tracking.rst | 56 ++++++++++++++++++++++++++++ akka-docs/pending/issue-tracking.rst | 51 ------------------------- 3 files changed, 57 insertions(+), 51 deletions(-) create mode 100644 akka-docs/general/issue-tracking.rst delete mode 100644 akka-docs/pending/issue-tracking.rst diff --git a/akka-docs/general/index.rst b/akka-docs/general/index.rst index f836c00d1c..eef8e30d65 100644 --- a/akka-docs/general/index.rst +++ b/akka-docs/general/index.rst @@ -11,3 +11,4 @@ General event-handler util developer-guidelines + issue-tracking diff --git a/akka-docs/general/issue-tracking.rst b/akka-docs/general/issue-tracking.rst new file mode 100644 index 0000000000..b0137c3ecf --- /dev/null +++ b/akka-docs/general/issue-tracking.rst @@ -0,0 +1,56 @@ +Issue Tracking +============== + +Akka is using ``Assembla`` as issue tracking system. + +Browsing +-------- + +Tickets +^^^^^^^ + +`You can find the Akka tickets here `_ + +`You can find the Akka Modules tickets here `_ + +Roadmaps +^^^^^^^^ + +`The roadmap for each Akka milestone is here `_ + +`The roadmap for each Akka Modules milestone is here `_ + +Creating tickets +---------------- + +In order to create tickets you need to do the following: + +`Register here `_ then log in + +For Akka tickets: +`Link to create new ticket `_ + + +For Akka Modules tickets: +`Link to create new ticket `_ + +Thanks a lot for reporting bugs and suggesting features. + +Failing test +------------ + +Please submit a failing test on the following format: + +.. code-block:: scala + + import org.scalatest.WordSpec + import org.scalatest.matchers.MustMatchers + + class Ticket001Spec extends WordSpec with MustMatchers { + + "An XXX" should { + "do YYY" in { + 1 must be (1) + } + } + } diff --git a/akka-docs/pending/issue-tracking.rst b/akka-docs/pending/issue-tracking.rst deleted file mode 100644 index fa81a4d254..0000000000 --- a/akka-docs/pending/issue-tracking.rst +++ /dev/null @@ -1,51 +0,0 @@ -Issue Tracking -============== - -Akka is using Assembla as issue tracking system. - -Browsing --------- - -You can find the Akka tickets here: ``_ -You can find the Akka Modules tickets here: ``_ - -The roadmap for each milestone is here: ``_ - -Creating tickets ----------------- - -In order to create tickets you need to do the following: - -# Register here: ``_ -# Log in - -For Akka tickets: - -# Create the ticket: ``_ - - -For Akka Modules tickets: - -# Create the ticket: ``_ - -Thanks a lot for reporting bugs and suggesting features. - -Failing test ------------- - -Please submit a failing test on the following format: - -``_ - -import org.scalatest.WordSpec -import org.scalatest.matchers.MustMatchers - -class Ticket001Spec extends WordSpec with MustMatchers { - - "An XXX" should { - "do YYY" in { - 1 must be (1) - } - } -} -``_ From 05db33ee97768758e07aa9816fac5642f35187cd Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 18:50:56 +0200 Subject: [PATCH 102/112] Moving Developer guidelines to the Dev section --- akka-docs/{general => dev}/developer-guidelines.rst | 2 +- akka-docs/dev/index.rst | 1 + akka-docs/general/index.rst | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) rename akka-docs/{general => dev}/developer-guidelines.rst (98%) diff --git a/akka-docs/general/developer-guidelines.rst b/akka-docs/dev/developer-guidelines.rst similarity index 98% rename from akka-docs/general/developer-guidelines.rst rename to akka-docs/dev/developer-guidelines.rst index 5965a2fe41..3834dec120 100644 --- a/akka-docs/general/developer-guidelines.rst +++ b/akka-docs/dev/developer-guidelines.rst @@ -1,4 +1,4 @@ -Developer Guidelines (committers) +Developer Guidelines ==================== Code Style diff --git a/akka-docs/dev/index.rst b/akka-docs/dev/index.rst index 05ab53742d..b50702ccdb 100644 --- a/akka-docs/dev/index.rst +++ b/akka-docs/dev/index.rst @@ -5,3 +5,4 @@ Information for Developers :maxdepth: 2 documentation + developer-guidelines diff --git a/akka-docs/general/index.rst b/akka-docs/general/index.rst index eef8e30d65..6807aeff83 100644 --- a/akka-docs/general/index.rst +++ b/akka-docs/general/index.rst @@ -10,5 +10,4 @@ General configuration event-handler util - developer-guidelines issue-tracking From 0d476c24d621724c0e6debd3f820b4ce9c0071d2 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 19:28:00 +0200 Subject: [PATCH 103/112] Converting team.rst, sponsors.rst and fixing some details in dev-guides --- akka-docs/dev/developer-guidelines.rst | 10 +- akka-docs/dev/index.rst | 2 + akka-docs/{pending => dev}/sponsors.rst | 10 +- akka-docs/dev/team.rst | 25 + .../pending/migration-guide-0.10.x-1.0.x.rst | 432 ------------------ akka-docs/pending/team.rst | 22 - 6 files changed, 34 insertions(+), 467 deletions(-) rename akka-docs/{pending => dev}/sponsors.rst (58%) create mode 100644 akka-docs/dev/team.rst delete mode 100644 akka-docs/pending/migration-guide-0.10.x-1.0.x.rst delete mode 100644 akka-docs/pending/team.rst diff --git a/akka-docs/dev/developer-guidelines.rst b/akka-docs/dev/developer-guidelines.rst index 3834dec120..ab19c370a2 100644 --- a/akka-docs/dev/developer-guidelines.rst +++ b/akka-docs/dev/developer-guidelines.rst @@ -7,7 +7,7 @@ Code Style The Akka code style follows `this document `_ . Here is a code style settings file for ``IntelliJ IDEA``: -`Download <@http://scalablesolutions.se/akka/docs/akka-0.10/files/akka-intellij-code-style.jar>`_ +`Download `_ Please follow the code style. Look at the code around you and mimic. @@ -16,15 +16,15 @@ Testing All code that is checked in **should** have tests. All testing is done with ``ScalaTest`` and ``ScalaCheck``. -* Name tests as *Test.scala if they do not depend on any external stuff. That keeps surefire happy. -* Name tests as *Spec.scala if they have external dependencies. +* Name tests as **Test.scala** if they do not depend on any external stuff. That keeps surefire happy. +* Name tests as **Spec.scala** if they have external dependencies. -There is a testing standard that should be followed: `Ticket001Spec <@https://github.com/jboner/akka/blob/master/akka-actor-tests/src/test/scala/akka/ticket/Ticket001Spec.scala>`_ +There is a testing standard that should be followed: `Ticket001Spec `_ Actor TestKit ^^^^^^^^^^^^^ -There is a useful test kit for testing actors: `akka.util.TestKit <@https://github.com/jboner/akka/tree/master/akka-testkit/src/main/scala/akka/testkit/TestKit.scala>`_. It enables assertions concerning replies received and their timing, there is more documentation in the ``_ module. +There is a useful test kit for testing actors: `akka.util.TestKit `_. It enables assertions concerning replies received and their timing, there is more documentation in the ``_ module. NetworkFailureTest ^^^^^^^^^^^^^^^^^^ diff --git a/akka-docs/dev/index.rst b/akka-docs/dev/index.rst index b50702ccdb..a4f1cee593 100644 --- a/akka-docs/dev/index.rst +++ b/akka-docs/dev/index.rst @@ -6,3 +6,5 @@ Information for Developers documentation developer-guidelines + sponsors + team diff --git a/akka-docs/pending/sponsors.rst b/akka-docs/dev/sponsors.rst similarity index 58% rename from akka-docs/pending/sponsors.rst rename to akka-docs/dev/sponsors.rst index 88d35f1f0a..544a35825a 100644 --- a/akka-docs/pending/sponsors.rst +++ b/akka-docs/dev/sponsors.rst @@ -1,11 +1,5 @@ -****Sponsors **** -======================================================= - -Scalable Solutions -================== - -Scalable Solutions AB is the commercial entity behind Akka, providing support, consulting and training around Akka. -``_ +**Sponsors** +============ YourKit ======= diff --git a/akka-docs/dev/team.rst b/akka-docs/dev/team.rst new file mode 100644 index 0000000000..4038fa9347 --- /dev/null +++ b/akka-docs/dev/team.rst @@ -0,0 +1,25 @@ +Team +===== + +=================== ========================== ================================= +Name Role Email +=================== ========================== ================================= +Jonas Bonér Founder, Despot, Committer jonas AT jonasboner DOT com +Viktor Klang Bad cop, Committer viktor DOT klang AT gmail DOT com +Debasish Ghosh Committer dghosh AT acm DOT org +Ross McDonald Alumni rossajmcd AT gmail DOT com +Eckhart Hertzler Alumni +Mikael Högqvist Alumni +Tim Perrett Alumni +Jeanfrancois Arcand Alumni jfarcand AT apache DOT org +Martin Krasser Committer krasserm AT googlemail DOT com +Jan Van Besien Alumni +Michael Kober Alumni +Peter Vlugter Committer +Peter Veentjer Committer +Irmo Manie Committer +Heiko Seeberger Committer +Hiram Chirino Committer +Scott Clasen Committer +Roland Kuhn Committer +=================== ========================== ================================= \ No newline at end of file diff --git a/akka-docs/pending/migration-guide-0.10.x-1.0.x.rst b/akka-docs/pending/migration-guide-0.10.x-1.0.x.rst deleted file mode 100644 index 300100941f..0000000000 --- a/akka-docs/pending/migration-guide-0.10.x-1.0.x.rst +++ /dev/null @@ -1,432 +0,0 @@ -Migration guide from 0.10.x to 1.0.x -==================================== - ----- - -Akka & Akka Modules separated into two different repositories and distributions -------------------------------------------------------------------------------- - -Akka is split up into two different parts: -* Akka - Reflects all the sections under 'Scala API' and 'Java API' in the navigation bar. -* Akka Modules - Reflects all the sections under 'Add-on modules' in the navigation bar. - -Download the release you need (Akka core or Akka Modules) from ``_ and unzip it. - ----- - -Changed Akka URI ----------------- - -http:*akkasource.org changed to http:*akka.io - -Reflects XSDs, Maven repositories, ScalaDoc etc. - ----- - -Removed 'se.scalablesolutions' prefix -------------------------------------- - -We have removed some boilerplate by shortening the Akka package from -**se.scalablesolutions.akka** to just **akka** so just do a search-replace in your project, -we apologize for the inconvenience, but we did it for our users. - ----- - -Akka-core is no more --------------------- - -Akka-core has been split into akka-actor, akka-stm, akka-typed-actor & akka-remote this means that you need to update any deps you have on akka-core. - ----- - -Config ------- - -Turning on/off modules -^^^^^^^^^^^^^^^^^^^^^^ - -All the 'service = on' elements for turning modules on and off have been replaced by a top-level list of the enabled services. - -Services available for turning on/off are: -* "remote" -* "http" -* "camel" - -**All** services are **OFF** by default. Enable the ones you are using. - -.. code-block:: ruby - - akka { - enabled-modules = [] # Comma separated list of the enabled modules. Options: ["remote", "camel", "http"] - } - -Renames -^^^^^^^ - -* 'rest' section - has been renamed to 'http' to align with the module name 'akka-http'. -* 'storage' section - has been renamed to 'persistence' to align with the module name 'akka-persistence'. - -.. code-block:: ruby - - akka { - http { - .. - } - - persistence { - .. - } - } - ----- - -Important changes from RC2-RC3 ------------------------------- - -**akka.config.SupervisionSupervise** -def apply(actorRef: ActorRef, lifeCycle: LifeCycle, registerAsRemoteService: Boolean = false) -- boolean instead of remoteAddress, registers that actor with it's id as service name on the local server - -**akka.actor.Actors now is the API for Java to interact with Actors, Remoting and ActorRegistry:** - -import static akka.actor.Actors.*; -*actorOf()..* -remote().actorOf()... -*registry().actorsFor("foo")...* - -***akka.actor.Actor now is the API for Scala to interact with Actors, Remoting and ActorRegistry:*** - -*import akka.actor.Actor._* -actorOf()... -*remote.actorOf()...* -registry.actorsFor("foo") - -**object UntypedActor has been deleted and replaced with akka.actor.Actors/akka.actor.Actor (Java/Scala)** -UntypedActor.actorOf -> Actors.actorOf (Java) or Actor.actorOf (Scala) - -**object ActorRegistry has been deleted and replaced with akka.actor.Actors.registry()/akka.actor.Actor.registry (Java/Scala)** -ActorRegistry. -> Actors.registry(). (Java) or Actor.registry. (Scala) - -**object RemoteClient has been deleted and replaced with akka.actor.Actors.remote()/akka.actor.Actor.remote (Java/Scala)** -RemoteClient -> Actors.remote() (Java) or Actor.remote (Scala) - -**object RemoteServer has been deleted and replaced with akka.actor.Actors.remote()/akka.actor.Actor.remote (Java/Scala)** -RemoteServer - deleted -> Actors.remote() (Java) or Actor.remote (Scala) - -**classes RemoteActor, RemoteUntypedActor and RemoteUntypedConsumerActors has been deleted and replaced** -**with akka.actor.Actors.remote().actorOf(x, host port)/akka.actor.Actor.remote.actorOf(x, host, port)** -RemoteActor, RemoteUntypedActor - deleted, use: remote().actorOf(YourActor.class, host, port) (Java) or remote.actorOf[YourActor](host, port) - -**Remoted spring-actors now default to spring id as service-name, use "service-name" attribute on "remote"-tag to override** - -**Listeners for RemoteServer and RemoteClient** are now registered on Actors.remote().addListener (Java) or Actor.remote.addListener (Scala), -this means that all listeners get all remote events, both remote server evens and remote client events, **so adjust your code accordingly.** - -**ActorRef.startLinkRemote has been removed since one specified on creation wether the actor is client-managed or not.** - -Important change from RC3 to RC4 --------------------------------- - -The Akka-Spring namespace has changed from akkasource.org and scalablesolutions.se to http:*akka.io/schema and http:*akka.io/akka-.xsd - ----- - -Module akka-actor ------------------ - -The Actor.init callback has been renamed to "preStart" to align with the general callback naming and is more clear about when it's called. - -The Actor.shutdown callback has been renamed to "postStop" to align with the general callback naming and is more clear about when it's called. - -The Actor.initTransactionalState callback has been removed, logic should be moved to preStart and be wrapped in an atomic block - -**se.scalablesolutions.akka.config.ScalaConfig** and **se.scalablesolutions.akka.config.JavaConfig** have been merged into **akka.config.Supervision** - -**RemoteAddress** has moved from **se.scalablesolutions.akka.config.ScalaConfig** to **akka.config** - -The ActorRef.lifeCycle has changed signature from Option[LifeCycle] to LifeCycle, this means you need to change code that looks like this: -**self.lifeCycle = Some(LifeCycle(Permanent))** to **self.lifeCycle = Permanent** - -The equivalent to **self.lifeCycle = None** is **self.lifeCycle = UndefinedLifeCycle** -**LifeCycle(Permanent)** becomes **Permanent** -**new LifeCycle(permanent())** becomes **permanent()** (need to do: import static se.scalablesolutions.akka.config.Supervision.*; first) - -**JavaConfig.Component** and **ScalaConfig.Component** have been consolidated and renamed as **Supervision.SuperviseTypedActor** - -**self.trapExit** has been moved into the FaultHandlingStrategy, and **ActorRef.faultHandler** has switched type from Option[FaultHandlingStrategy] -to FaultHandlingStrategy: - -|| **Scala** || -|| -``_ -import akka.config.Supervision._ - -self.faultHandler = OneForOneStrategy(List(classOf[Exception]), 3, 5000) - -``_ || -|| **Java** || -|| -``_ -import static akka.Supervision.*; - -getContext().setFaultHandler(new OneForOneStrategy(new Class[] { Exception.class },50,1000)) - -``_ || - -**RestartStrategy, AllForOne, OneForOne** have been replaced with **AllForOneStrategy** and **OneForOneStrategy** in **se.scalablesolutions.akka.config.Supervision** - -|| **Scala** || -|| -``_ -import akka.config.Supervision._ -SupervisorConfig( - OneForOneStrategy(List(classOf[Exception]), 3, 5000), - Supervise(pingpong1,Permanent) :: Nil -) - -``_ || -|| **Java** || -|| -``_ -import static akka.Supervision.*; - -new SupervisorConfig( - new OneForOneStrategy(new Class[] { Exception.class },50,1000), - new Server[] { new Supervise(pingpong1, permanent()) } -) - -``_ || - -We have removed the following factory methods: - -**Actor.actor { case foo => bar }** -**Actor.transactor { case foo => bar }** -**Actor.temporaryActor { case foo => bar }** -**Actor.init {} receive { case foo => bar }** - -They started the actor and no config was possible, it was inconsistent and irreparable. - -replace with your own factories, or: - -**actorOf( new Actor { def receive = { case foo => bar } } ).start** -**actorOf( new Actor { self.lifeCycle = Temporary; def receive = { case foo => bar } } ).start** - -ReceiveTimeout is now rescheduled after every message, before there was only an initial timeout. -To stop rescheduling of ReceiveTimeout, set **receiveTimeout = None** - -HotSwap -------- - -HotSwap does no longer use behavior stacking by default, but that is an option to both "become" and HotSwap. - -HotSwap now takes for Scala a Function from ActorRef to a Receive, the ActorRef passed in is the reference to self, so you can do self.reply() etc. - ----- - -Module akka-stm ---------------- - -The STM stuff is now in its own module. This means that there is no support for transactions or transactors in akka-actor. - -Local and global -^^^^^^^^^^^^^^^^ - -The **local/global** distinction has been dropped. This means that if the following general import was being used: - -.. code-block:: scala - - import akka.stm.local._ - -this is now just: - -.. code-block:: scala - - import akka.stm._ - -Coordinated is the new global -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -There is a new explicit mechanism for coordinated transactions. See the `Scala Transactors `_ and `Java Transactors `_ documentation for more information. Coordinated transactions and transactors are found in the ``akka.transactor`` package now. The usage of transactors has changed. - -Agents -^^^^^^ - -Agent is now in the akka-stm module and has moved to the ``akka.agent`` package. The implementation has been reworked and is now closer to Clojure agents. There is not much difference in general usage, the main changes involve interaction with the STM. - -While updates to Agents are asynchronous, the state of an Agent is always immediately available for reading by any thread. Agents are integrated with the STM - any dispatches made in a transaction are held until that transaction commits, and are discarded if it is retried or aborted. There is a new ``sendOff`` method for long-running or blocking update functions. - ----- - -Module akka-camel ------------------ - -Access to the CamelService managed by CamelServiceManager has changed: - -* Method service renamed to mandatoryService (Scala) -* Method service now returns Option[CamelService] (Scala) -* Introduced method getMandatoryService() (Java) -* Introduced method getService() (Java) - -|| **Scala** || -|| -``_ -import se.scalablesolutions.akka.camel.CamelServiceManager._ -import se.scalablesolutions.akka.camel.CamelService - -val o: Option[CamelService] = service -val s: CamelService = mandatoryService - -``_ || -|| **Java** || -|| -``_ -import se.scalablesolutions.akka.camel.CamelService; -import se.scalablesolutions.akka.japi.Option; -import static se.scalablesolutions.akka.camel.CamelServiceManager.*; - -Option o = getService(); -CamelService s = getMandatoryService(); - -``_ || - -Access to the CamelContext and ProducerTemplate managed by CamelContextManager has changed: - -* Method context renamed to mandatoryContext (Scala) -* Method template renamed to mandatoryTemplate (Scala) -* Method service now returns Option[CamelContext] (Scala) -* Method template now returns Option[ProducerTemplate] (Scala) -* Introduced method getMandatoryContext() (Java) -* Introduced method getContext() (Java) -* Introduced method getMandatoryTemplate() (Java) -* Introduced method getTemplate() (Java) - -|| **Scala** || -|| -``_ -import org.apache.camel.CamelContext -import org.apache.camel.ProducerTemplate - -import se.scalablesolutions.akka.camel.CamelContextManager._ - -val co: Option[CamelContext] = context -val to: Option[ProducerTemplate] = template - -val c: CamelContext = mandatoryContext -val t: ProducerTemplate = mandatoryTemplate - -``_ || -|| **Java** || -|| -``_ -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; - -import se.scalablesolutions.akka.japi.Option; -import static se.scalablesolutions.akka.camel.CamelContextManager.*; - -Option co = getContext(); -Option to = getTemplate(); - -CamelContext c = getMandatoryContext(); -ProducerTemplate t = getMandatoryTemplate(); - -``_ || - -The following methods have been renamed on class se.scalablesolutions.akka.camel.Message: - -* bodyAs(Class) has been renamed to getBodyAs(Class) -* headerAs(String, Class) has been renamed to getHeaderAs(String, Class) - -The API for waiting for consumer endpoint activation and de-activation has been changed - -* CamelService.expectEndpointActivationCount has been removed and replaced by CamelService.awaitEndpointActivation -* CamelService.expectEndpointDeactivationCount has been removed and replaced by CamelService.awaitEndpointDeactivation - -|| **Scala** || -|| -``_ -import se.scalablesolutions.akka.actor.Actor -import se.scalablesolutions.akka.camel.CamelServiceManager._ - -val s = startCamelService -val actor = Actor.actorOf[SampleConsumer] - -// wait for 1 consumer being activated -s.awaitEndpointActivation(1) { - actor.start -} - -// wait for 1 consumer being de-activated -s.awaitEndpointDeactivation(1) { - actor.stop -} - -s.stop - -``_ || -|| **Java** || -|| -``_ -import java.util.concurrent.TimeUnit; -import se.scalablesolutions.akka.actor.ActorRef; -import se.scalablesolutions.akka.actor.Actors; -import se.scalablesolutions.akka.camel.CamelService; -import se.scalablesolutions.akka.japi.SideEffect; -import static se.scalablesolutions.akka.camel.CamelServiceManager.*; - -CamelService s = startCamelService(); -final ActorRef actor = Actors.actorOf(SampleUntypedConsumer.class); - -// wait for 1 consumer being activated -s.awaitEndpointActivation(1, new SideEffect() { - public void apply() { - actor.start(); - } -}); - -// wait for 1 consumer being de-activated -s.awaitEndpointDeactivation(1, new SideEffect() { - public void apply() { - actor.stop(); - } -}); - -s.stop(); - -``_ || - -- - -Module Akka-Http ----------------- - -Atmosphere support has been removed. If you were using akka.comet.AkkaServlet for Jersey support only, -you can switch that to: akka.http.AkkaRestServlet and it should work just like before. - -Atmosphere has been removed because we have a new async http support in the form of Akka Mist, a very thin bridge -between Servlet3.0/JettyContinuations and Actors, enabling Http-as-messages, read more about it here: -http://doc.akka.io/http#Mist%20-%20Lightweight%20Asynchronous%20HTTP - -If you really need Atmosphere support, you can add it yourself by following the steps listed at the start of: -http://doc.akka.io/comet - -Module akka-spring ------------------- - -The Akka XML schema URI has changed to http://akka.io/schema/akka - -``_ - - - - - - -``_ diff --git a/akka-docs/pending/team.rst b/akka-docs/pending/team.rst deleted file mode 100644 index cdc97244bd..0000000000 --- a/akka-docs/pending/team.rst +++ /dev/null @@ -1,22 +0,0 @@ -Team -===== - -|| **Name** || **Role** || **Email** || -|| Jonas Bonér || Founder, Despot, Committer || jonas AT jonasboner DOT com || -|| Viktor Klang || Bad cop, Committer || viktor DOT klang AT gmail DOT com || -|| Debasish Ghosh || Committer || dghosh AT acm DOT org || -|| Ross McDonald || Alumni || rossajmcd AT gmail DOT com || -|| Eckhart Hertzler || Alumni || || -|| Mikael Högqvist || Alumni || || -|| Tim Perrett || Alumni || || -|| Jeanfrancois Arcand || Alumni || jfarcand AT apache DOT org || -|| Martin Krasser || Committer || krasserm AT googlemail DOT com || -|| Jan Van Besien || Alumni || || -|| Michael Kober || Committer || || -|| Peter Vlugter || Committer || || -|| Peter Veentjer || Committer || || -|| Irmo Manie || Committer || || -|| Heiko Seeberger || Committer || || -|| Hiram Chirino || Committer || || -|| Scott Clasen || Committer || || -|| Roland Kuhn || Committer || || From 4eddce0fe2729e50424b99890c14055bf666749e Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 2 May 2011 19:38:10 +0200 Subject: [PATCH 104/112] Porting licenses.rst and removing boldness in sponsors title --- akka-docs/dev/sponsors.rst | 2 +- akka-docs/general/index.rst | 3 ++- akka-docs/{pending => general}/licenses.rst | 0 3 files changed, 3 insertions(+), 2 deletions(-) rename akka-docs/{pending => general}/licenses.rst (100%) diff --git a/akka-docs/dev/sponsors.rst b/akka-docs/dev/sponsors.rst index 544a35825a..127ab17ee1 100644 --- a/akka-docs/dev/sponsors.rst +++ b/akka-docs/dev/sponsors.rst @@ -1,4 +1,4 @@ -**Sponsors** +Sponsors ============ YourKit diff --git a/akka-docs/general/index.rst b/akka-docs/general/index.rst index 6807aeff83..d5288e2af3 100644 --- a/akka-docs/general/index.rst +++ b/akka-docs/general/index.rst @@ -9,5 +9,6 @@ General building-akka configuration event-handler - util issue-tracking + util + licenses diff --git a/akka-docs/pending/licenses.rst b/akka-docs/general/licenses.rst similarity index 100% rename from akka-docs/pending/licenses.rst rename to akka-docs/general/licenses.rst From dadc572d61f6df0005031674e502e6b9a1b0718f Mon Sep 17 00:00:00 2001 From: Roland Kuhn Date: Mon, 2 May 2011 21:16:04 +0200 Subject: [PATCH 105/112] no need to install pygments on every single run --- akka-docs/Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/akka-docs/Makefile b/akka-docs/Makefile index 49f649367f..d7b391e802 100644 --- a/akka-docs/Makefile +++ b/akka-docs/Makefile @@ -16,7 +16,11 @@ PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # Set python path to include local packages for pygments styles. -PYTHONPATH += $(LOCALPACKAGES) +ifneq (,$(PYTHONPATH)) + PYTHONPATH := $(PYTHONPATH):$(LOCALPACKAGES) +else + PYTHONPATH := $(LOCALPACKAGES) +endif export PYTHONPATH .PHONY: help clean pygments html singlehtml latex pdf @@ -40,8 +44,11 @@ pygments: @echo "Custom pygments styles have been installed." @echo -html: pygments - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html +$(LOCALPACKAGES)/akkastyles-0.1-py2.6.egg: + $(MAKE) pygments + +html: $(LOCALPACKAGES)/akkastyles-0.1-py2.6.egg + $(SPHINXBUILD) -a -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." From ece765775bd09c9c7bcc6272506cc147f35887dd Mon Sep 17 00:00:00 2001 From: Roland Kuhn Date: Mon, 2 May 2011 21:18:14 +0200 Subject: [PATCH 106/112] move FSM._ import into class, fixes #831 --- akka-docs/scala/fsm.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/akka-docs/scala/fsm.rst b/akka-docs/scala/fsm.rst index 3b5fdd4394..89dedb52ec 100644 --- a/akka-docs/scala/fsm.rst +++ b/akka-docs/scala/fsm.rst @@ -49,13 +49,14 @@ Now lets create an object representing the FSM and defining the behavior. import akka.actor.{Actor, FSM} import akka.event.EventHandler - import FSM._ import akka.util.duration._ case object Move class ABC extends Actor with FSM[ExampleState, Unit] { + import FSM._ + startWith(A, Unit) when(A) { From 859b61d582c4118c1310d7bec14b4b047b1fa6ff Mon Sep 17 00:00:00 2001 From: Roland Kuhn Date: Mon, 2 May 2011 21:40:35 +0200 Subject: [PATCH 107/112] move Duration docs below common/ next to Scheduler --- akka-docs/common/index.rst | 1 + akka-docs/general/index.rst | 1 - akka-docs/general/util.rst | 49 ------------------------------------- 3 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 akka-docs/general/util.rst diff --git a/akka-docs/common/index.rst b/akka-docs/common/index.rst index 6ed8cb1593..f3ed26aa73 100644 --- a/akka-docs/common/index.rst +++ b/akka-docs/common/index.rst @@ -5,3 +5,4 @@ Common utilities :maxdepth: 2 scheduler + duration diff --git a/akka-docs/general/index.rst b/akka-docs/general/index.rst index d5288e2af3..4cd57b37b7 100644 --- a/akka-docs/general/index.rst +++ b/akka-docs/general/index.rst @@ -10,5 +10,4 @@ General configuration event-handler issue-tracking - util licenses diff --git a/akka-docs/general/util.rst b/akka-docs/general/util.rst deleted file mode 100644 index bb0f61e778..0000000000 --- a/akka-docs/general/util.rst +++ /dev/null @@ -1,49 +0,0 @@ -######### -Utilities -######### - -.. sidebar:: Contents - - .. contents:: :local: - -This section of the manual describes miscellaneous utilities which are provided -by Akka and used in multiple places. - -.. _Duration: - -Duration -======== - -Durations are used throughout the Akka library, wherefore this concept is -represented by a special data type, :class:`Duration`. Values of this type may -represent infinite (:obj:`Duration.Inf`, :obj:`Duration.MinusInf`) or finite -durations, where the latter are constructable using a mini-DSL: - -.. code-block:: scala - - import akka.util.duration._ // notice the small d - - val fivesec = 5.seconds - val threemillis = 3.millis - val diff = fivesec - threemillis - assert (diff < fivesec) - -.. note:: - - You may leave out the dot if the expression is clearly delimited (e.g. - within parentheses or in an argument list), but it is recommended to use it - if the time unit is the last token on a line, otherwise semi-colon inference - might go wrong, depending on what starts the next line. - -Java provides less syntactic sugar, so you have to spell out the operations as -method calls instead: - -.. code-block:: java - - final Duration fivesec = Duration.create(5, "seconds"); - final Duration threemillis = Duration.parse("3 millis"); - final Duration diff = fivesec.minus(threemillis); - assert (diff.lt(fivesec)); - assert (Duration.Zero().lt(Duration.Inf())); - - From 67f1e2fbca2a4c3f1104d4321518a19baa9b196b Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Mon, 2 May 2011 14:44:40 -0600 Subject: [PATCH 108/112] Fix Future.flow compile time type safety --- .../test/scala/akka/dispatch/FutureSpec.scala | 26 +++++++++++++++++++ .../src/main/scala/akka/dispatch/Future.scala | 10 +++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index b74526118e..e8d20919a9 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -623,6 +623,32 @@ class FutureSpec extends JUnitSuite { assert(result.get === Some("Hello")) } + @Test def futureFlowShouldBeTypeSafe { + import Future.flow + + def checkType[A: Manifest, B](in: Future[A], refmanifest: Manifest[B]): Boolean = manifest[A] == refmanifest + + val rString = flow { + val x = Future(5) + x().toString + } + + val rInt = flow { + val x = rString.apply + val y = Future(5) + x.length + y() + } + + assert(checkType(rString, manifest[String])) + assert(checkType(rInt, manifest[Int])) + assert(!checkType(rInt, manifest[String])) + assert(!checkType(rInt, manifest[Nothing])) + assert(!checkType(rInt, manifest[Any])) + + rString.await + rInt.await + } + @Test def ticket812FutureDispatchCleanup { val dispatcher = implicitly[MessageDispatcher] assert(dispatcher.pendingFutures === 0) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 34e9c6da9b..632ccdac3e 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -291,8 +291,14 @@ object Future { * * The Delimited Continuations compiler plugin must be enabled in order to use this method. */ - def flow(body: => Any @cps[Future[Any]], timeout: Long = Actor.TIMEOUT): Future[Any] = - reset(new DefaultCompletableFuture[Any](timeout).completeWithResult(body)) + def flow[A](body: => A @cps[Future[Any]], timeout: Long = Actor.TIMEOUT): Future[A] = { + val f = new DefaultCompletableFuture[A](timeout) + reset(f.asInstanceOf[CompletableFuture[Any]].completeWithResult(body)).onComplete{ f2 => + val e = f2.exception + e foreach (f.completeWithException(_)) + } + f + } private[akka] val callbacksPendingExecution = new ThreadLocal[Option[Stack[() => Unit]]]() { override def initialValue = None From d175ef413979b8c642b07f7c3ab0d8a9f685856b Mon Sep 17 00:00:00 2001 From: Roland Date: Mon, 2 May 2011 23:45:40 +0200 Subject: [PATCH 109/112] fix pygments dependency and add forgotten common/duration.rst --- akka-docs/Makefile | 4 +-- akka-docs/common/duration.rst | 51 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 akka-docs/common/duration.rst diff --git a/akka-docs/Makefile b/akka-docs/Makefile index d7b391e802..9811732058 100644 --- a/akka-docs/Makefile +++ b/akka-docs/Makefile @@ -44,10 +44,10 @@ pygments: @echo "Custom pygments styles have been installed." @echo -$(LOCALPACKAGES)/akkastyles-0.1-py2.6.egg: +$(LOCALPACKAGES): $(MAKE) pygments -html: $(LOCALPACKAGES)/akkastyles-0.1-py2.6.egg +html: $(LOCALPACKAGES) $(SPHINXBUILD) -a -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." diff --git a/akka-docs/common/duration.rst b/akka-docs/common/duration.rst new file mode 100644 index 0000000000..523c8a2283 --- /dev/null +++ b/akka-docs/common/duration.rst @@ -0,0 +1,51 @@ +.. _Duration: + +######## +Duration +######## + +Module stability: **SOLID** + +Durations are used throughout the Akka library, wherefore this concept is +represented by a special data type, :class:`Duration`. Values of this type may +represent infinite (:obj:`Duration.Inf`, :obj:`Duration.MinusInf`) or finite +durations. + +Scala +===== + +In Scala durations are constructable using a mini-DSL and support all expected operations: + +.. code-block:: scala + + import akka.util.duration._ // notice the small d + + val fivesec = 5.seconds + val threemillis = 3.millis + val diff = fivesec - threemillis + assert (diff < fivesec) + val fourmillis = threemillis * 4 / 3 // though you cannot write it the other way around + val n = threemillis / (1 millisecond) + +.. note:: + + You may leave out the dot if the expression is clearly delimited (e.g. + within parentheses or in an argument list), but it is recommended to use it + if the time unit is the last token on a line, otherwise semi-colon inference + might go wrong, depending on what starts the next line. + +Java +==== + +Java provides less syntactic sugar, so you have to spell out the operations as +method calls instead: + +.. code-block:: java + + final Duration fivesec = Duration.create(5, "seconds"); + final Duration threemillis = Duration.parse("3 millis"); + final Duration diff = fivesec.minus(threemillis); + assert (diff.lt(fivesec)); + assert (Duration.Zero().lt(Duration.Inf())); + + From 6c0d5c74a889868f2d60a69ffe5640d15dd327c5 Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 3 May 2011 00:52:34 +0200 Subject: [PATCH 110/112] add import statements to testing.rst --- akka-docs/scala/testing.rst | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/akka-docs/scala/testing.rst b/akka-docs/scala/testing.rst index 9238cfd198..c0e36ada78 100644 --- a/akka-docs/scala/testing.rst +++ b/akka-docs/scala/testing.rst @@ -40,6 +40,10 @@ encompass functional tests of complete actor networks. The important distinction lies in whether concurrency concerns are part of the test or not. The tools offered are described in detail in the following sections. +.. note:: + + Be sure to add the module :mod:`akka-testkit` to your dependencies. + Unit Testing with :class:`TestActorRef` ======================================= @@ -68,6 +72,8 @@ reference is done like this: .. code-block:: scala + import akka.testkit.TestActorRef + val actorRef = TestActorRef[MyActor] val actor = actorRef.underlyingActor @@ -169,6 +175,10 @@ common task easy: .. code-block:: scala + import akka.testkit.TestKit + import org.scalatest.WordSpec + import org.scalatest.matchers.MustMatchers + class MySpec extends WordSpec with MustMatchers with TestKit { "An Echo actor" must { @@ -252,6 +262,31 @@ runs everything which would normally be queued directly on the current thread, the full history of a message's processing chain is recorded on the call stack, so long as all intervening actors run on this dispatcher. +How to use it +------------- + +Just set the dispatcher as you normally would, either from within the actor + +.. code-block:: scala + + import akka.testkit.CallingThreadDispatcher + + class MyActor extends Actor { + self.dispatcher = CallingThreadDispatcher.global + ... + } + +or from the client code + +.. code-block:: scala + + val ref = Actor.actorOf[MyActor] + ref.dispatcher = CallingThreadDispatcher.global + ref.start() + +As the :class:`CallingThreadDispatcher` does not have any configurable state, +you may always use the (lazily) preallocated one as shown in the examples. + How it works ------------ From cb2d60739345a71df2335a7b6295e9ffb55f57ce Mon Sep 17 00:00:00 2001 From: Derek Williams Date: Mon, 2 May 2011 16:56:42 -0600 Subject: [PATCH 111/112] remove extra allocations and fix scaladoc type inference problem --- akka-actor/src/main/scala/akka/dispatch/Future.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 632ccdac3e..0f09a7535a 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -292,12 +292,12 @@ object Future { * The Delimited Continuations compiler plugin must be enabled in order to use this method. */ def flow[A](body: => A @cps[Future[Any]], timeout: Long = Actor.TIMEOUT): Future[A] = { - val f = new DefaultCompletableFuture[A](timeout) - reset(f.asInstanceOf[CompletableFuture[Any]].completeWithResult(body)).onComplete{ f2 => - val e = f2.exception - e foreach (f.completeWithException(_)) + val future = new DefaultCompletableFuture[A](timeout) + (reset(future.asInstanceOf[CompletableFuture[Any]].completeWithResult(body)): Future[Any]) onComplete { f => + val opte = f.exception + if (opte.isDefined) future completeWithException (opte.get) } - f + future } private[akka] val callbacksPendingExecution = new ThreadLocal[Option[Stack[() => Unit]]]() { From d97e0c1672eb5191a2f1b3e0de78eff2ecbf2285 Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 3 May 2011 04:43:05 +0200 Subject: [PATCH 112/112] fix import in testkit example; fixes #833 --- akka-docs/scala/testkit-example.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/akka-docs/scala/testkit-example.rst b/akka-docs/scala/testkit-example.rst index f53543e474..a0ec001902 100644 --- a/akka-docs/scala/testkit-example.rst +++ b/akka-docs/scala/testkit-example.rst @@ -4,7 +4,7 @@ TestKit Example ############### -Ray Roestenburg's example code from `his blog `_. +Ray Roestenburg's example code from `his blog `_ adapted to work with Akka 1.1. .. code-block:: scala @@ -14,7 +14,7 @@ Ray Roestenburg's example code from `his blog