From 962ee1ebba43e14a3fd7b1459f23d6e54fc04925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bone=CC=81r?= Date: Tue, 17 May 2011 16:34:07 +0200 Subject: [PATCH] Added docs for durable mailboxes, plus filtered out replication tests --- .../cluster/replication/TransactionLog.scala | 27 ++- .../akka/cluster/ClusterDeployerSpec.scala | 3 +- .../scala/akka/cluster/ReplicationSpec.scala | 6 +- akka-docs/cluster/cluster/more.png | Bin 0 -> 1502 bytes akka-docs/cluster/durable-mailbox.rst | 228 ++++++++++++++++++ akka-docs/cluster/index.rst | 7 + akka-docs/index.rst | 1 + akka-docs/java/dispatchers.rst | 2 + akka-docs/more.png | Bin 0 -> 1502 bytes akka-docs/scala/dispatchers.rst | 2 + project/build/AkkaProject.scala | 21 +- 11 files changed, 275 insertions(+), 22 deletions(-) create mode 100644 akka-docs/cluster/cluster/more.png create mode 100644 akka-docs/cluster/durable-mailbox.rst create mode 100644 akka-docs/cluster/index.rst create mode 100644 akka-docs/more.png diff --git a/akka-cluster/src/main/scala/akka/cluster/replication/TransactionLog.scala b/akka-cluster/src/main/scala/akka/cluster/replication/TransactionLog.scala index 018b2c1726..8254d86872 100644 --- a/akka-cluster/src/main/scala/akka/cluster/replication/TransactionLog.scala +++ b/akka-cluster/src/main/scala/akka/cluster/replication/TransactionLog.scala @@ -319,13 +319,15 @@ object TransactionLog { new TransactionLog(ledger, id, isAsync) /** - * TODO document method + * Shuts down the transaction log. */ def shutdown() { isConnected switchOff { try { - zkClient.close - bookieClient.halt + EventHandler.info(this, "Shutting down transaction log...") + zkClient.close() + bookieClient.halt() + EventHandler.info(this, "Transaction log shut down successfully") } catch { case e => handleError(e) } @@ -378,8 +380,7 @@ object TransactionLog { "] meta-data in ZooKeeper for UUID [" + id +"]")) } - EventHandler.info(this, - "Created new transaction log [%s] for UUID [%s]".format(logId, id)) + EventHandler.info(this, "Created new transaction log [%s] for UUID [%s]".format(logId, id)) TransactionLog(ledger, id, isAsync) } @@ -459,6 +460,7 @@ object LocalBookKeeperEnsemble { localBookKeeper.runZookeeper(port) localBookKeeper.initializeZookeper localBookKeeper.runBookies + EventHandler.info(this, "LocalBookKeeperEnsemble started successfully") } } @@ -467,10 +469,17 @@ object LocalBookKeeperEnsemble { */ def shutdown() { isRunning switchOff { - localBookKeeper.bs.foreach(_.shutdown) // stop bookies - localBookKeeper.zkc.close // stop zk client - localBookKeeper.zks.shutdown // stop zk server - localBookKeeper.serverFactory.shutdown // stop zk NIOServer + EventHandler.info(this, "Shutting down LocalBookKeeperEnsemble...") + println("***************************** 1") + localBookKeeper.bs.foreach(_.shutdown()) // stop bookies + println("***************************** 2") + localBookKeeper.zkc.close() // stop zk client + println("***************************** 3") + localBookKeeper.zks.shutdown() // stop zk server + println("***************************** 4") + localBookKeeper.serverFactory.shutdown() // stop zk NIOServer + println("***************************** 5") + EventHandler.info(this, "LocalBookKeeperEnsemble shut down successfully") } } } diff --git a/akka-cluster/src/test/scala/akka/cluster/ClusterDeployerSpec.scala b/akka-cluster/src/test/scala/akka/cluster/ClusterDeployerSpec.scala index 7568a6a580..7290c396e1 100644 --- a/akka-cluster/src/test/scala/akka/cluster/ClusterDeployerSpec.scala +++ b/akka-cluster/src/test/scala/akka/cluster/ClusterDeployerSpec.scala @@ -36,6 +36,7 @@ class ClusterDeployerSpec extends WordSpec with MustMatchers with BeforeAndAfter oldDeployment must equal(newDeployment.get) } } + /* "be able to create an actor deployed using ClusterDeployer" in { val pi = Actor.actorOf[Pi]("service-pi") @@ -58,7 +59,7 @@ class ClusterDeployerSpec extends WordSpec with MustMatchers with BeforeAndAfter } override def afterAll() { - Deployer.shutdown() + ClusterDeployer.shutdown() Cluster.shutdownLocalCluster() Actor.registry.local.shutdownAll() } diff --git a/akka-cluster/src/test/scala/akka/cluster/ReplicationSpec.scala b/akka-cluster/src/test/scala/akka/cluster/ReplicationSpec.scala index 84b48f8fdc..1120c977ed 100644 --- a/akka-cluster/src/test/scala/akka/cluster/ReplicationSpec.scala +++ b/akka-cluster/src/test/scala/akka/cluster/ReplicationSpec.scala @@ -271,11 +271,11 @@ class ReplicationSpec extends WordSpec with MustMatchers with BeforeAndAfterAll } override def beforeAll() = { - LocalBookKeeperEnsemble.start + LocalBookKeeperEnsemble.start() } override def afterAll() = { - TransactionLog.shutdown - LocalBookKeeperEnsemble.shutdown + TransactionLog.shutdown() + LocalBookKeeperEnsemble.shutdown() } } diff --git a/akka-docs/cluster/cluster/more.png b/akka-docs/cluster/cluster/more.png new file mode 100644 index 0000000000000000000000000000000000000000..3eb7b05c84809454c095bcb61b27d83585540bb2 GIT binary patch literal 1502 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}EX7WqAsieW95oy%9SjT% zk|nMYCBgY=CFO}lsSM@i<$9TU*~Q6;1*v-ZMd`EO*+?-kuoif_IEF;D9-S7QBN8fc z{Qv!#H|O5ncIDoi)}U@yO|gadcDOt32;uP!OYU&HC?4rDuV$kA;y@ptD?gTWdM6!d zS)tNm>KNkWAfk1NskLcJl-JAFd*v_7^oy!0szW@vcpba1`g{AYCmOj`=Rb%i<|)a>`yt`uO3u&M7Y zj=cNJN+{#&k1dwpV;v?m-C9+Z`u4K^w8;Wz<>qhuv5!-LgGtNnY~C52wPMoK_XjQD z_`2fwa?^YAj7l6r3LGpwayC=qInJ*#FEU;Jn*F?9?(N+5^UwWnIKKQTLxw_Qc;}1A zG(FKZ=Wbm4A^7Vn_lBD-XW5FTCQVrS==rkuhlMwOT+g>>>H8h&jQ#%6zD&Q<#KN<; zUiE(_dR}9(%~}D=b2S`67v=Xdbo+XkC2r)LexkWcM&@62{f{(_f(fc-zxVF4%w_EN zFP?NDo%P)(UEc2avT$)-mn&RO&kcMen>803Sa8key^(V;joHw;uC zpL1nv&!3apDgGzUw&XaI-25;fE<42OngL5*uGxcY z@BFV!DN;${Re#7ZVYS#{6WyM^o(P6-%MUFV`S4@Q*3hF{Ur#@CcLB>;I|hcyTn&@$ zRjND143?CuJl80^=CGN&@X?o#9eKy@eb2wR-{X0TNXPx}cVExD^@Qv8;tdh)4P0!^ zGadw`IVifH5^dRcqq1jqvq1_AL%_1L%r7l1E*9A&&3ab0Km7jO&Z)Z0v$M6tM4mo- zrj+o-VFDN1g!R)79?bh=edE+#&rL zZp?jcx| z&x^MmH_Z(%e`Q(p*lgDMxjf#Q(tqRrMwnHEF)qCD*mb99$_b5}Z2=EfxTM$5u3hnT zH{-M$PrkqM?cAvUw&-)h8s^1S;%Pfy3(Cx$kbXPLNvCq|{nh6Ftmo%3y7eA@*r4Ye z&?+3L+!R0SyVRM8SKnXNu5?!QZh0Gcrs#TdMZ%eV7w$yv%_@L)n>VXH=s%k2*ZqD7a~ z%Kdm8eNQY|Z^!4?GD*rsrD4kU#6Jx})4jHBm($3c6TSJx+lZ1oIsf;*eeFE|xL-f- zAvT9h$rOf9W{Jzccg_^_KdDlXRsHz5Yv^g|SMmI_lh1YghV#q)G`J$jr)sQm>A^RX zTV+*jmsltLePr2HeAasERo2Z@XDwVUZ0`4#vxI+3WSWieO34#bI=@WyW-v3pJ=xB~ z=uVr9it&>Zih&ygO2y6x-tA)c+7SNguKL#*lB~xc&UCr7R3~lP`_ Is a very +fast NOSQL database that has a wide range of data structure abstractions, one of +them is a queue which is what we are using in this implementation. This means +that you have to start up a Redis server that can host these durable +mailboxes. Read more in the Redis documentation on how to do that. + +Here is an example of how you can configure your dispatcher to use this mailbox:: + + val dispatcher = DurableEventBasedDispatcher( + "my:service", + RedisDurableMailboxStorage) + +or for a thread-based durable dispatcher. :: + + self.dispatcher = DurableThreadBasedDispatcher( + self, + RedisDurableMailboxStorage) + +You also need to configure the IP and port for the Redis server. This is done in +the ``akka.actor.mailbox.redis`` section in the ``akka.conf`` configuration +file. + +.. code-block:: conf + + akka { + actor { + mailbox { + redis { + hostname = "127.0.0.1" + port = 6379 + } + } + } + } + + +ZooKeeper-based durable mailbox +------------------------------- + +This mailbox is backed by `ZooKeeper `_. ZooKeeper +is a centralized service for maintaining configuration information, naming, +providing distributed synchronization, and providing group services This means +that you have to start up a ZooKeeper server (for production a ZooKeeper server +ensamble) that can host these durable mailboxes. Read more in the ZooKeeper +documentation on how to do that. + +Akka is using ZooKeeper for many other things, for example the clustering +support so if you're using that you love to run a ZooKeeper server anyway and +there will not be that much more work to set up this durable mailbox. + +Here is an example of how you can configure your dispatcher to use this mailbox:: + + val dispatcher = DurableEventBasedDispatcher( + "my:service", + ZooKeeperDurableMailboxStorage) + +or for a thread-based durable dispatcher. :: + + self.dispatcher = DurableThreadBasedDispatcher( + self, + ZooKeeperDurableMailboxStorage) + +You also need to configure ZooKeeper server addresses, timeouts, etc. This is +done in the ``akka.actor.mailbox.zookeeper`` section in the ``akka.conf`` +configuration file. + +.. code-block:: conf + + akka { + actor { + mailbox { + zookeeper { + server-addresses = "localhost:2181" + session-timeout = 60 + connection-timeout = 30 + blocking-queue = on + } + } + } + } + + +Beanstalk-based durable mailbox +------------------------------- + +This mailbox is backed by `Beanstalkd `_. +Beanstalk is a simple, fast work queue. This means that you have to start up a +Beanstalk server that can host these durable mailboxes. Read more in the +Beanstalk documentation on how to do that. :: + + val dispatcher = DurableEventBasedDispatcher( + "my:service", + BeanstalkDurableMailboxStorage) + +or for a thread-based durable dispatcher. :: + + self.dispatcher = DurableThreadBasedDispatcher( + self, + BeanstalkDurableMailboxStorage) + +You also need to configure the IP, and port, and so on, for the Beanstalk +server. This is done in the ``akka.actor.mailbox.beanstalk`` section in the +``akka.conf`` configuration file. + +.. code-block:: conf + + akka { + actor { + mailbox { + beanstalk { + hostname = "127.0.0.1" + port = 11300 + reconnect-window = 5 + message-submit-delay = 0 + message-submit-timeout = 5 + message-time-to-live = 120 + } + } + } + } + + +.. |more| image:: more.png + :align: middle + :alt: More info + diff --git a/akka-docs/cluster/index.rst b/akka-docs/cluster/index.rst new file mode 100644 index 0000000000..b9ffb28378 --- /dev/null +++ b/akka-docs/cluster/index.rst @@ -0,0 +1,7 @@ +Cluster +======= + +.. toctree:: + :maxdepth: 2 + + durable-mailbox diff --git a/akka-docs/index.rst b/akka-docs/index.rst index 738b8e636f..4c94d7a68a 100644 --- a/akka-docs/index.rst +++ b/akka-docs/index.rst @@ -9,6 +9,7 @@ Contents common/index scala/index java/index + cluster/index dev/index project/index additional/index diff --git a/akka-docs/java/dispatchers.rst b/akka-docs/java/dispatchers.rst index 578fcd4ff5..36bd22d8ba 100644 --- a/akka-docs/java/dispatchers.rst +++ b/akka-docs/java/dispatchers.rst @@ -1,3 +1,5 @@ +.. _dispatchers-java: + Dispatchers (Java) ================== diff --git a/akka-docs/more.png b/akka-docs/more.png new file mode 100644 index 0000000000000000000000000000000000000000..3eb7b05c84809454c095bcb61b27d83585540bb2 GIT binary patch literal 1502 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}EX7WqAsieW95oy%9SjT% zk|nMYCBgY=CFO}lsSM@i<$9TU*~Q6;1*v-ZMd`EO*+?-kuoif_IEF;D9-S7QBN8fc z{Qv!#H|O5ncIDoi)}U@yO|gadcDOt32;uP!OYU&HC?4rDuV$kA;y@ptD?gTWdM6!d zS)tNm>KNkWAfk1NskLcJl-JAFd*v_7^oy!0szW@vcpba1`g{AYCmOj`=Rb%i<|)a>`yt`uO3u&M7Y zj=cNJN+{#&k1dwpV;v?m-C9+Z`u4K^w8;Wz<>qhuv5!-LgGtNnY~C52wPMoK_XjQD z_`2fwa?^YAj7l6r3LGpwayC=qInJ*#FEU;Jn*F?9?(N+5^UwWnIKKQTLxw_Qc;}1A zG(FKZ=Wbm4A^7Vn_lBD-XW5FTCQVrS==rkuhlMwOT+g>>>H8h&jQ#%6zD&Q<#KN<; zUiE(_dR}9(%~}D=b2S`67v=Xdbo+XkC2r)LexkWcM&@62{f{(_f(fc-zxVF4%w_EN zFP?NDo%P)(UEc2avT$)-mn&RO&kcMen>803Sa8key^(V;joHw;uC zpL1nv&!3apDgGzUw&XaI-25;fE<42OngL5*uGxcY z@BFV!DN;${Re#7ZVYS#{6WyM^o(P6-%MUFV`S4@Q*3hF{Ur#@CcLB>;I|hcyTn&@$ zRjND143?CuJl80^=CGN&@X?o#9eKy@eb2wR-{X0TNXPx}cVExD^@Qv8;tdh)4P0!^ zGadw`IVifH5^dRcqq1jqvq1_AL%_1L%r7l1E*9A&&3ab0Km7jO&Z)Z0v$M6tM4mo- zrj+o-VFDN1g!R)79?bh=edE+#&rL zZp?jcx| z&x^MmH_Z(%e`Q(p*lgDMxjf#Q(tqRrMwnHEF)qCD*mb99$_b5}Z2=EfxTM$5u3hnT zH{-M$PrkqM?cAvUw&-)h8s^1S;%Pfy3(Cx$kbXPLNvCq|{nh6Ftmo%3y7eA@*r4Ye z&?+3L+!R0SyVRM8SKnXNu5?!QZh0Gcrs#TdMZ%eV7w$yv%_@L)n>VXH=s%k2*ZqD7a~ z%Kdm8eNQY|Z^!4?GD*rsrD4kU#6Jx})4jHBm($3c6TSJx+lZ1oIsf;*eeFE|xL-f- zAvT9h$rOf9W{Jzccg_^_KdDlXRsHz5Yv^g|SMmI_lh1YghV#q)G`J$jr)sQm>A^RX zTV+*jmsltLePr2HeAasERo2Z@XDwVUZ0`4#vxI+3WSWieO34#bI=@WyW-v3pJ=xB~ z=uVr9it&>Zih&ygO2y6x-tA)c+7SNguKL#*lB~xc&UCr7R3~lP