From b6a27deaeaa2efd4a21c4748fc2c7de06402bb21 Mon Sep 17 00:00:00 2001 From: Christopher Batey Date: Fri, 20 Apr 2018 17:31:51 +0100 Subject: [PATCH] Fix snippets in typed cluster docs --- .../typed/ShardingCompileOnlySpec.scala | 6 ++-- .../typed/BasicClusterExampleTest.java | 1 - .../ClusterSingletonPersistenceSpec.scala | 1 - akka-docs/src/main/paradox/remoting-artery.md | 4 +-- .../main/paradox/typed/cluster-singleton.md | 29 +++++++++++-------- akka-docs/src/main/paradox/typed/cluster.md | 5 +--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala b/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala index de2e170afe..b51199bd47 100644 --- a/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala +++ b/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala @@ -30,10 +30,10 @@ object ShardingCompileOnlySpec { final case class GetValue(replyTo: ActorRef[Int]) extends CounterCommand case object GoodByeCounter extends CounterCommand - def counter(entityId: String, value: Int): Behavior[CounterCommand] = Behaviors.receive[CounterCommand] { - case (ctx, Increment) ⇒ + def counter(entityId: String, value: Int): Behavior[CounterCommand] = Behaviors.receiveMessage[CounterCommand] { + case Increment ⇒ counter(entityId, value + 1) - case (ctx, GetValue(replyTo)) ⇒ + case GetValue(replyTo) ⇒ replyTo ! value Behaviors.same } diff --git a/akka-cluster-typed/src/test/java/jdocs/akka/cluster/typed/BasicClusterExampleTest.java b/akka-cluster-typed/src/test/java/jdocs/akka/cluster/typed/BasicClusterExampleTest.java index b230c9129f..81a9d7e65b 100644 --- a/akka-cluster-typed/src/test/java/jdocs/akka/cluster/typed/BasicClusterExampleTest.java +++ b/akka-cluster-typed/src/test/java/jdocs/akka/cluster/typed/BasicClusterExampleTest.java @@ -5,7 +5,6 @@ package jdocs.akka.cluster.typed; //#cluster-imports - import akka.actor.typed.*; import akka.actor.typed.javadsl.*; import akka.cluster.ClusterEvent; diff --git a/akka-cluster-typed/src/test/scala/akka/cluster/typed/ClusterSingletonPersistenceSpec.scala b/akka-cluster-typed/src/test/scala/akka/cluster/typed/ClusterSingletonPersistenceSpec.scala index e94cb819d0..0262a98ccd 100644 --- a/akka-cluster-typed/src/test/scala/akka/cluster/typed/ClusterSingletonPersistenceSpec.scala +++ b/akka-cluster-typed/src/test/scala/akka/cluster/typed/ClusterSingletonPersistenceSpec.scala @@ -13,7 +13,6 @@ object ClusterSingletonPersistenceSpec { val config = ConfigFactory.parseString( """ akka.actor.provider = cluster - akka.remote.artery.enabled = true akka.remote.netty.tcp.port = 0 akka.remote.artery.canonical.port = 0 diff --git a/akka-docs/src/main/paradox/remoting-artery.md b/akka-docs/src/main/paradox/remoting-artery.md index bec047d34d..42cfb0a7bc 100644 --- a/akka-docs/src/main/paradox/remoting-artery.md +++ b/akka-docs/src/main/paradox/remoting-artery.md @@ -887,7 +887,7 @@ your configuration file. This a limitation of the current version and will not b @@@ -Emitting event information (logs) from internals is always a tradeoff. The events that are usable for +Emitting event information (logs) from internals is always a trade off. The events that are usable for the Akka developers are usually too low level to be of any use for users and usually need to be fine-grained enough to provide enough information to be able to debug issues in the internal implementation. This usually means that these logs are hidden behind special flags and emitted at low log levels to not clutter the log output of the user @@ -908,7 +908,7 @@ crashes unexpectedly. * Very low overhead, specialized, binary logging that has no significant overhead and can be safely left enabled for production systems. -The location of the file can be controlled via the *akka.remote.artery.advanced.flight-recoder.destination* setting (see +The location of the file can be controlled via the *akka.remote.artery.advanced.flight-recorder.destination* setting (see @ref:[akka-remote (artery)](general/configuration.md#config-akka-remote-artery) for details). By default, a file with the *.afr* extension is produced in the temporary directory of the operating system. In cases where the flight recorder casuses issues, it can be disabled by adding the setting *akka.remote.artery.advanced.flight-recorder.enabled=off*, although this is not recommended. diff --git a/akka-docs/src/main/paradox/typed/cluster-singleton.md b/akka-docs/src/main/paradox/typed/cluster-singleton.md index 91eb711f60..ba4de3324f 100644 --- a/akka-docs/src/main/paradox/typed/cluster-singleton.md +++ b/akka-docs/src/main/paradox/typed/cluster-singleton.md @@ -1,5 +1,14 @@ # Cluster Singleton +@@@ warning + +This module is currently marked as @ref:[may change](../common/may-change.md) in the sense + of being the subject of active research. This means that API or semantics can + change without warning or deprecation period and it is not recommended to use + this module in production just yet—you have been warned. + +@@@ + For some use cases it is convenient and sometimes also mandatory to ensure that you have exactly one actor of a certain type running somewhere in the cluster. @@ -16,18 +25,10 @@ such as single-point of bottleneck. Single-point of failure is also a relevant c but for some cases this feature takes care of that by making sure that another singleton instance will eventually be started. -@@@ warning - -This module is currently marked as @ref:[may change](../common/may-change.md) in the sense - of being the subject of active research. This means that API or semantics can - change without warning or deprecation period and it is not recommended to use - this module in production just yet—you have been warned. - -@@@ ## Dependency -To use Akka Cluster Singleton Typed, add the module to your project: +Cluster singleton is part of the cluster module: @@dependency[sbt,Maven,Gradle] { group=com.typesafe.akka @@ -40,13 +41,13 @@ To use Akka Cluster Singleton Typed, add the module to your project: Any `Behavior` can be run as a singleton. E.g. a basic counter: Scala -: @@snip [ShardingCompileOnlySpec.scala]($akka$/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala) { #sharding-extension } +: @@snip [ShardingCompileOnlySpec.scala]($akka$/akka-cluster-sharding-typed/src/test/scala/doc/akka/cluster/sharding/typed/ShardingCompileOnlySpec.scala) { #counter } Java -: @@snip [ShardingCompileOnlyTest.java]($akka$/akka-cluster-sharding-typed/src/test/java/jdoc/akka/cluster/sharding/typed/ShardingCompileOnlyTest.java) { #sharding-extension } +: @@snip [ShardingCompileOnlyTest.java]($akka$/akka-cluster-sharding-typed/src/test/java/jdoc/akka/cluster/sharding/typed/ShardingCompileOnlyTest.java) { #counter } Then on every node in the cluster, or every node with a given role, use the `ClusterSingleton` extension -to spawn the singleton. Only a single instance will run in the cluster: +to spawn the singleton. An instance will per data centre of the cluster: Scala @@ -55,3 +56,7 @@ Scala Java : @@snip [ShardingCompileOnlyTest.java]($akka$/akka-cluster-sharding-typed/src/test/java/jdoc/akka/cluster/sharding/typed/ShardingCompileOnlyTest.java) { #singleton } +## Accessing singleton of another data centre + +TODO + diff --git a/akka-docs/src/main/paradox/typed/cluster.md b/akka-docs/src/main/paradox/typed/cluster.md index 637c01efc1..6e7edb52e1 100644 --- a/akka-docs/src/main/paradox/typed/cluster.md +++ b/akka-docs/src/main/paradox/typed/cluster.md @@ -34,11 +34,8 @@ Java And the minimum configuration required is to set a host/port for remoting and the `akka.actor.provider = "cluster"`. -Scala -: @@snip [BasicClusterExampleTest.java]($akka$/akka-cluster-typed/src/test/java/jdocs/akka/cluster/typed/BasicClusterExampleTest.java) { #cluster-imports } +@@snip [BasicClusterExampleSpec.scala]($akka$/akka-cluster-typed/src/test/scala/docs/akka/cluster/typed/BasicClusterExampleSpec.scala) { #config-seeds } -Java -: @@snip [BasicClusterExampleTest.java]($akka$/akka-cluster-typed/src/test/java/jdocs/akka/cluster/typed/BasicClusterExampleTest.java) { #cluster-imports } ## Cluster API extension