Hello! I have been trying to find information on how to move/migrate a running actor from one node to another but I have not been able to find anything concrete.
Assume we have three actors, the producer, the processor and the consumer. The producer creates/senses/reads data and sends it to the processor, the processor processes this data and sends it to the consumer that logs/saves it. Communication chain: ProducerActor -> ProcessActor -> ConsumerActor For the context: Assume we had the three nodes 6000,6001,6002 running when we initially deployed the actors. After a while, node 6003 enters the cluster. We now realize that node 6003 is a much better candidate for running the ProcessActor, so we would like to move/migrate it. I looked at the SimpleClusterApp<https://github.com/akka/akka/blob/master/akka-samples/akka-sample-cluster-scala/src/main/scala/sample/cluster/simple/SimpleClusterApp.scala> and I just changed it around a bit in order to try out some stuff: object SimpleClusterApp { def main(args: Array[String]): Unit = { if (args.isEmpty) startup(Seq("6000", "6001", "6002", "6003")) else startup(args) } def startup(ports: Seq[String]): Unit = { ports foreach { port => // Override the configuration of the port val config = ConfigFactory.parseString("akka.remote.netty.tcp.port=" + port). withFallback(ConfigFactory.load()) // Create an Akka system val system = ActorSystem("ClusterSystem", config) // Create an actor that handles cluster domain events system.actorOf(Props[ClusterListener], name = "clusterListener") if(port == "0") { // Set adresses for the four nodes val producerAddr = AddressFromURIString("akka.tcp://[email protected]:6000") val processAddr = AddressFromURIString("akka.tcp://[email protected]:6001") val consumerAddr = AddressFromURIString("akka.tcp://[email protected]:6002") val newAddr = AddressFromURIString("akka.tcp://[email protected]:6003") // Deploy the actors val consumerRef = system.actorOf(Props[ConsumerActor].withDeploy(Deploy(scope = RemoteScope(consumerAddr))), name = "Consumer") val processRef = system.actorOf(Props(classOf[ProcessActor],consumerRef).withDeploy(Deploy(scope = RemoteScope(processAddr))), name = "ProcessingResource") val producerRef = system.actorOf(Props(classOf[ProducerActor],processRef).withDeploy(Deploy(scope = RemoteScope(producerAddr))), name = "Producer") // Tell producer to start producing values producerRef ! Start // migrate processRef to newAddr } } } } If it is Stateless I could just do something like: //temporarily halt production producerRef ! Halt // shut down processRef processRef ! Stop //create new processing resource val newRef = system.actorOf(Props(classOf[ProcessActor],consumerRef).withDeploy(Deploy(scope = RemoteScope(newAddr))), name = "ProcessingResource") //redirect producer output to new processing resource producerRef ! ChangeOutput(newRef) //restart production producerRef ! "Start" Basically, how do I move/migrate the actor ProcessingResource to newAddr if it has a state? Also, is there a smarter/easier way of doing the stateless "migration" that I showed above? Regards, Andreas -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
