4
votes

The following cluster singleton is not starting up.

commander = system.actorOf(
  ClusterSingletonManager.props(Commander.props(this),
    terminationMessage = PoisonPill.getInstance,
    settings = ClusterSingletonManagerSettings.create(system).withRole("commander")
  ), name = "Commander")

No error messages are thrown.

Logs are:

[INFO] [08/03/2016 11:43:58.656] [ScalaTest-run-running-ClusterSuite] [akka.remote.Remoting] Starting remoting [INFO] [08/03/2016 11:43:59.007] [ScalaTest-run-running-ClusterSuite] [akka.remote.Remoting] Remoting started; listening on addresses :[akka.tcp://[email protected]:59592] [INFO] [08/03/2016 11:43:59.035] [ScalaTest-run-running-ClusterSuite] [akka.cluster.Cluster(akka://galaxyFarFarAway)] Cluster Node [akka.tcp://[email protected]:59592] - Starting up... [INFO] [08/03/2016 11:43:59.218] [ScalaTest-run-running-ClusterSuite] [akka.cluster.Cluster(akka://galaxyFarFarAway)] Cluster Node [akka.tcp://[email protected]:59592] - Registered cluster JMX MBean [akka:type=Cluster] [INFO] [08/03/2016 11:43:59.218] [ScalaTest-run-running-ClusterSuite] [akka.cluster.Cluster(akka://galaxyFarFarAway)] Cluster Node [akka.tcp://[email protected]:59592] - Started up successfully [INFO] [08/03/2016 11:43:59.247] [galaxyFarFarAway-akka.actor.default-dispatcher-2] [akka.cluster.Cluster(akka://galaxyFarFarAway)] Cluster Node [akka.tcp://[email protected]:59592] - Metrics will be retreived from MBeans, and may be incorrect on some platforms. To increase metric accuracy add the 'sigar.jar' to the classpath and the appropriate platform-specific native libary to 'java.library.path'. Reason: java.lang.ClassNotFoundException: org.hyperic.sigar.Sigar [INFO] [08/03/2016 11:43:59.257] [galaxyFarFarAway-akka.actor.default-dispatcher-2] [akka.cluster.Cluster(akka://galaxyFarFarAway)] Cluster Node [akka.tcp://[email protected]:59592] - Metrics collection has started successfully [INFO] [08/03/2016 11:43:59.268] [galaxyFarFarAway-akka.actor.default-dispatcher-3] [akka.cluster.Cluster(akka://galaxyFarFarAway)] Cluster Node [akka.tcp://[email protected]:59592] - No seed-nodes configured, manual cluster join required Disconnected from the target VM, address: '127.0.0.1:59574', transport: 'socket'

The configuration is:

akka {
 actor {
  provider = "akka.cluster.ClusterActorRefProvider"
  default-dispatcher {
  throughput = 10
  }
}
 cluster {
  roles = [commander]
}

 remote {
  log-remote-lifecycle-events = off
  netty.tcp {
     hostname = "127.0.0.1"
     port = 0
    }
 }
 akka.extensions=["akka.cluster.metrics.ClusterMetricsExtension"]
}

When I debug the code of Commander class, the constructor is not even called anywhere. When I omit the ClusterSingletonManager and just create it with Props it does work however, the Commander actor is going to be created. I sense incorrect configuration behind this issue. Do you guys have any remarks about this?

1

1 Answers

4
votes

You've sensed quite right: you haven't specified the seed node configuration for the Akka clustering. You can see this in the last line of the log:

[akka.tcp://[email protected]:59592] - No seed-nodes configured, manual cluster join required Disconnected from the target VM, address: '127.0.0.1:59574', transport: 'socket'

Because you haven't specified any seed nodes in the configuration file, Akka will wait for you to specify the seed nodes programmatically. You can specify the seed nodes in the config like this:

akka.cluster.seed-nodes = [
  "akka.tcp://[email protected]:2551",
  "akka.tcp://[email protected]:2552"
]

Alternatively, you can call the joinSeedNodes method to join the cluster programmatically. In both cases, you have to specify at least one seed node that is available. The actor system itself can also act as a seed node.

Once the seed nodes have been specified and the actor system has joined the cluster, Akka features depending on clustering (cluster singletons, sharding etc.) will boot up. This is why you can launch an ordinary actor, but not the singleton.

For more information on setting up seed nodes see Akka cluster documentation.