doc: small improvements of core cluster pages (#27939)

* proofreading of core cluster pages
* some more info in failure detector
This commit is contained in:
Patrik Nordwall 2019-10-09 11:17:22 +02:00 committed by Christopher Batey
parent 86965d0a05
commit 40ce73ad4e
10 changed files with 110 additions and 41 deletions

View file

@ -7,6 +7,7 @@ package jdocs.akka.cluster.typed;
// #join-seed-nodes
import akka.actor.Address;
import akka.actor.AddressFromURIString;
import akka.cluster.Member;
import akka.cluster.typed.JoinSeedNodes;
// #join-seed-nodes
@ -120,4 +121,29 @@ public class BasicClusterExampleTest { // extends JUnitSuite {
Cluster.get(system).manager().tell(new JoinSeedNodes(seedNodes));
// #join-seed-nodes
}
static class Backend {
static Behavior<Void> create() {
return Behaviors.empty();
}
}
static class Frontend {
static Behavior<Void> create() {
return Behaviors.empty();
}
}
void illustrateRoles() {
ActorContext<Void> context = null;
// #hasRole
Member selfMember = Cluster.get(context.getSystem()).selfMember();
if (selfMember.hasRole("backend")) {
context.spawn(Backend.create(), "back");
} else if (selfMember.hasRole("front")) {
context.spawn(Frontend.create(), "front");
}
// #hasRole
}
}

View file

@ -62,6 +62,27 @@ akka {
Cluster(system).manager ! JoinSeedNodes(seedNodes)
//#join-seed-nodes
}
object Backend {
def apply(): Behavior[_] = Behaviors.empty
}
object Frontend {
def apply(): Behavior[_] = Behaviors.empty
}
def illustrateRoles(): Unit = {
val context: ActorContext[_] = ???
//#hasRole
val selfMember = Cluster(context.system).selfMember
if (selfMember.hasRole("backend")) {
context.spawn(Backend(), "back")
} else if (selfMember.hasRole("frontend")) {
context.spawn(Frontend(), "front")
}
//#hasRole
}
}
class BasicClusterConfigSpec extends WordSpec with ScalaFutures with Eventually with Matchers with LogCapturing {