RH (18) [Avatar] Offline
#1
PDF page 249 (my emphasis):
You create the cluster singleton by using specialized Props generated by
ClusterSingletonManager. In the following example, you can see how you create Props for
an actor called Coordinator. In a typical application, it's likely that this actor is responsible for
coordinating certain actions across all nodes in the cluster. As you can see, you create the
regular Props that you need to create the actor, in which you can specify how to create the
actor and which constructor parameters are required. These are then passed to
ClusterSingletonManager. You also specify the message used for termination, should the
singleton need to be relocated in the event that the oldest node becomes available again after
a failure. In this case, you just use PoisonPill,
but if you have more complex work before
shutting down, then you may want to use a custom termination message. Finally, you also
supply the settings used for handling the cluster singleton. For example, in this case, you have
specified that the singleton should only be deployed onto a node that belongs to the
orchestration role.


The code example, however, seems to omit the parts referenced by the text in bold above:
//Create the Props for the actor which will be deployed on only one node in the cluster
var coordinatorProps = Props.Create<CoordinatorActor>();
//Create the settings for the cluster singleton manager, retrieving them from the actor system
//configuration and then overriding the name of the singleton
var settings =
  ClusterSingletonManagerSettings.Create(actorSystem)
  .WithSingletonName("coordinator");
//Create the Props for the cluster singleton manager by providing the props of the singleton and the
//settings to use for the singleton
var clusterSingletonProps =
  ClusterSingletonManager.Props(coordinatorProps, settings);


Also, on page 250, the cluster singleton proxy configuration is missing the restriction about nodes with a specific role:
... When creating the Props, you need to specify the
actor path to the singleton that you previously created. As you deployed it at the top of the
actor hierarchy, the path will be /user/coordinator. You also need to supply any additional
configuration. In this case, you need to specify that you deployed the singleton onto nodes with
a specific role.
If the roles failed to match, then the proxy would not be able to accurately route
the messages to the correct target.

The code fragment, however, makes no mention of this.
...
var coordinatorProxySettings =
  ClusterSingletonProxySettings.Create(actorSystem)
  .WithSingletonName("coordinator");
...
var coordinatorProxyProps =
  ClusterSingletonProxy.Props("/user/coordinatorManager", coordinatorProxySettings);
...
var coordinatorProxy =
  actorSystem.ActorOf(coordinatorProxyProps, "coordinatorProxy");