From 94eaeca3a7c42fd06c7b081436434525018c740a Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Tue, 16 Oct 2012 10:54:21 +0200 Subject: [PATCH] Mavenize java akka-sample-cluster --- akka-docs/rst/cluster/cluster-usage-java.rst | 104 ++++++++++++------- akka-docs/rst/project/links.rst | 50 +++++++-- akka-samples/akka-sample-cluster/pom.xml | 39 +++++++ 3 files changed, 148 insertions(+), 45 deletions(-) create mode 100644 akka-samples/akka-sample-cluster/pom.xml diff --git a/akka-docs/rst/cluster/cluster-usage-java.rst b/akka-docs/rst/cluster/cluster-usage-java.rst index c8e2d791b4..6abe22e700 100644 --- a/akka-docs/rst/cluster/cluster-usage-java.rst +++ b/akka-docs/rst/cluster/cluster-usage-java.rst @@ -25,6 +25,8 @@ version from ``_. We recommend against using ``SNAPSHOT`` in order to obtain stable builds. +.. _cluster_simple_example_java: + A Simple Cluster Example ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,17 +56,33 @@ ip-addresses or host names of the machines in ``application.conf`` instead of `` .. literalinclude:: ../../../akka-samples/akka-sample-cluster/src/main/java/sample/cluster/simple/japi/SimpleClusterApp.java :language: java +3. Add `maven exec plugin `_ to your pom.xml:: -3. Start the first seed node. Open a sbt session in one terminal window and run:: + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + - run-main sample.cluster.simple.japi.SimpleClusterApp 2551 + +4. Start the first seed node. Open a terminal window and run (one line):: + + mvn exec:java -Dexec.mainClass="sample.cluster.simple.japi.SimpleClusterApp" \ + -Dexec.args="2551" 2551 corresponds to the port of the first seed-nodes element in the configuration. In the log output you see that the cluster node has been started and changed status to 'Up'. -4. Start the second seed node. Open a sbt session in another terminal window and run:: +5. Start the second seed node. Open another terminal window and run:: - run-main sample.cluster.simple.japi.SimpleClusterApp 2552 + mvn exec:java -Dexec.mainClass="sample.cluster.simple.japi.SimpleClusterApp" \ + -Dexec.args="2552" 2552 corresponds to the port of the second seed-nodes element in the configuration. @@ -73,9 +91,9 @@ and becomes a member of the cluster. It's status changed to 'Up'. Switch over to the first terminal window and see in the log output that the member joined. -5. Start another node. Open a sbt session in yet another terminal window and run:: +6. Start another node. Open a sbt session in yet another terminal window and run:: - run-main sample.cluster.simple.japi.SimpleClusterApp + mvn exec:java -Dexec.mainClass="sample.cluster.simple.japi.SimpleClusterApp" Now you don't need to specify the port number, and it will use a random available port. It joins one of the configured seed nodes. Look at the log output in the different terminal @@ -197,23 +215,28 @@ Death watch uses the cluster failure detector for nodes in the cluster, i.e. it network failures and JVM crashes, in addition to graceful termination of watched actor. -This example is included in ``akka-samples/akka-sample-cluster`` -and you can try by starting nodes in different terminal windows. For example, starting 2 +This example is included in ``akka-samples/akka-sample-cluster`` and you can try it by copying the +`source `_ to your +maven project, defined as in :ref:`cluster_simple_example_java`. +Run it by starting nodes in different terminal windows. For example, starting 2 frontend nodes and 3 backend nodes:: - sbt + mvn exec:java \ + -Dexec.mainClass="sample.cluster.transformation.japi.TransformationFrontendMain" \ + -Dexec.args="2551" - project akka-sample-cluster-experimental + mvn exec:java \ + -Dexec.mainClass="sample.cluster.transformation.japi.TransformationBackendMain" \ + -Dexec.args="2552" - run-main sample.cluster.transformation.japi.TransformationFrontendMain 2551 + mvn exec:java \ + -Dexec.mainClass="sample.cluster.transformation.japi.TransformationBackendMain" - run-main sample.cluster.transformation.japi.TransformationBackendMain 2552 + mvn exec:java \ + -Dexec.mainClass="sample.cluster.transformation.japi.TransformationBackendMain" - run-main sample.cluster.transformation.japi.TransformationBackendMain - - run-main sample.cluster.transformation.japi.TransformationBackendMain - - run-main sample.cluster.transformation.japi.TransformationFrontendMain + mvn exec:java \ + -Dexec.mainClass="sample.cluster.transformation.japi.TransformationFrontendMain" .. note:: The above example should probably be designed as two separate, frontend/backend, clusters, when there is a `cluster client for decoupling clusters `_. @@ -355,21 +378,26 @@ This means that user requests can be sent to ``StatsService`` on any node and it ``StatsWorker`` on all nodes. There can only be one worker per node, but that worker could easily fan out to local children if more parallelism is needed. -This example is included in ``akka-samples/akka-sample-cluster`` -and you can try by starting nodes in different terminal windows. For example, starting 3 +This example is included in ``akka-samples/akka-sample-cluster`` and you can try it by copying the +`source `_ to your +maven project, defined as in :ref:`cluster_simple_example_java`. +Run it by starting nodes in different terminal windows. For example, starting 3 service nodes and 1 client:: - sbt + mvn exec:java \ + -Dexec.mainClass="run-main sample.cluster.stats.japi.StatsSampleMain" \ + -Dexec.args="2551" - project akka-sample-cluster-experimental + mvn exec:java \ + -Dexec.mainClass="run-main sample.cluster.stats.japi.StatsSampleMain" \ + -Dexec.args="2552" - run-main sample.cluster.stats.japi.StatsSampleMain 2551 + mvn exec:java \ + -Dexec.mainClass="run-main sample.cluster.stats.japi.StatsSampleMain" - run-main sample.cluster.stats.japi.StatsSampleMain 2552 + mvn exec:java \ + -Dexec.mainClass="run-main sample.cluster.stats.japi.StatsSampleMain" - run-main sample.cluster.stats.japi.StatsSampleClientMain - - run-main sample.cluster.stats.japi.StatsSampleMain The above setup is nice for this example, but we will also take a look at how to use a single master node that creates and deploys workers. To keep track of a single @@ -387,22 +415,26 @@ All nodes start ``StatsFacade`` and the router is now configured like this: .. includecode:: ../../../akka-samples/akka-sample-cluster/src/main/java/sample/cluster/stats/japi/StatsSampleOneMasterMain.java#start-router-deploy - -This example is included in ``akka-samples/akka-sample-cluster`` -and you can try by starting nodes in different terminal windows. For example, starting 3 +This example is included in ``akka-samples/akka-sample-cluster`` and you can try it by copying the +`source `_ to your +maven project, defined as in :ref:`cluster_simple_example_java`. +Run it by starting nodes in different terminal windows. For example, starting 3 service nodes and 1 client:: - sbt + mvn exec:java \ + -Dexec.mainClass="sample.cluster.stats.japi.StatsSampleOneMasterMain" \ + -Dexec.args="2551" - project akka-sample-cluster-experimental + mvn exec:java \ + -Dexec.mainClass="sample.cluster.stats.japi.StatsSampleOneMasterMain" \ + -Dexec.args="2552" - run-main sample.cluster.stats.japi.StatsSampleOneMasterMain 2551 + mvn exec:java \ + -Dexec.mainClass="sample.cluster.stats.japi.StatsSampleOneMasterClientMain" - run-main sample.cluster.stats.japi.StatsSampleOneMasterMain 2552 + mvn exec:java \ + -Dexec.mainClass="sample.cluster.stats.japi.StatsSampleOneMasterMain" - run-main sample.cluster.stats.japi.StatsSampleOneMasterClientMain - - run-main sample.cluster.stats.japi.StatsSampleOneMasterMain .. note:: The above example, especially the last part, will be simplified when the cluster handles automatic actor partitioning. diff --git a/akka-docs/rst/project/links.rst b/akka-docs/rst/project/links.rst index 238971d1ba..8266240e24 100644 --- a/akka-docs/rst/project/links.rst +++ b/akka-docs/rst/project/links.rst @@ -1,13 +1,17 @@ .. _support: +######### + Project +######### + Commercial Support -================== +^^^^^^^^^^^^^^^^^^ Commercial support is provided by `Typesafe `_. Akka is now part of the `Typesafe Stack `_. Mailing List -============ +^^^^^^^^^^^^ `Akka User Google Group `_ @@ -15,13 +19,13 @@ Mailing List Downloads -========= +^^^^^^^^^ ``_ Source Code -=========== +^^^^^^^^^^^ Akka uses Git and is hosted at `Github `_. @@ -29,7 +33,7 @@ Akka uses Git and is hosted at `Github `_. Releases Repository -=================== +^^^^^^^^^^^^^^^^^^^ The Akka Maven repository can be found at http://repo.akka.io/releases/. @@ -50,7 +54,7 @@ underlying repositories directly. Snapshots Repository -==================== +^^^^^^^^^^^^^^^^^^^^ Nightly builds are available in http://repo.akka.io/snapshots/ and proxied through http://repo.typesafe.com/typesafe/snapshots/ as both ``SNAPSHOT`` and @@ -60,12 +64,40 @@ For timestamped versions, pick a timestamp from http://repo.typesafe.com/typesafe/snapshots/com/typesafe/akka/akka-actor_@binVersion@/. All Akka modules that belong to the same build have the same timestamp. -Make sure that you add the repository to the sbt resolvers or maven repositories:: +sbt definition of snapshot repository +------------------------------------- + +Make sure that you add the repository to the sbt resolvers:: resolvers += "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/" Define the library dependencies with the timestamp as version. For example:: - libraryDependencies += "com.typesafe.akka" % "akka-actor_@binVersion@" % "2.1-20120913-000917" + libraryDependencies += "com.typesafe.akka" % "akka-remote_@binVersion@" % "2.1-20121016-001042" + +maven definition of snapshot repository +--------------------------------------- + +Make sure that you add the repository to the maven repositories in pom.xml:: + + + + typesafe-snapshots + Typesafe Snapshots + http://repo.typesafe.com/typesafe/snapshots/ + default + + + +Define the library dependencies with the timestamp as version. For example:: + + + + com.typesafe.akka + akka-remote_@binVersion@ + 2.1-20121016-001042 + + + + - libraryDependencies += "com.typesafe.akka" % "akka-remote_@binVersion@" % "2.1-20120913-000917" diff --git a/akka-samples/akka-sample-cluster/pom.xml b/akka-samples/akka-sample-cluster/pom.xml new file mode 100644 index 0000000000..e01518726d --- /dev/null +++ b/akka-samples/akka-sample-cluster/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + com.typesafe.akka + akka-sample-cluster-experimental-japi + 2.1-SNAPSHOT + jar + + UTF-8 + + + + com.typesafe.akka + akka-cluster-experimental_2.10.0-RC1 + 2.1-20121016-001042 + + + + + typesafe-snapshots + Typesafe Snapshots + http://repo.typesafe.com/typesafe/snapshots/ + default + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + \ No newline at end of file