akka простой кластер с двумя начальными узлами

Пользуюсь akka cluster 2.3.6

Я скомпилировал две отдельные банки, и внутри у меня есть основной класс

   val configuration = ConfigFactory.load()
    val bucket = configuration.getString("bucket")
    val system = ActorSystem(bucket,configuration)
    val resultDispatcherActor = system.actorOf(Props(new MyActor)) 

Я использую две отдельные банки:

java -Dconfig.file=poc.conf -jar poc.jar

где мой poc.conf следующий:

akka {
  loglevel = INFO
  stdout-loglevel = INFO  
  event-handlers = ["akka.event.Logging$DefaultLogger"]

  actor {    
    provider = "akka.cluster.ClusterActorRefProvider"
       }
  remote{
    enabled-transports = ["akka.remote.netty.tcp"]    
    log-remote-lifecycle-events = off

    netty.tcp {      
      hostname = ""      
      host = "10.0.0.5"     
      port = 2551
    }         
  }
  cluster {
    seed-nodes = [
      "akka.tcp://[email protected]:2551",
      "akka.tcp://[email protected]:2552"]
     
  }
}

внутри блока netty.tcp каждое первое приложение назначено на порт 2551 и часть 2552.

Однако, когда я запускаю обе банки, каждая из них выводит следующий журнал:

[INFO] [11/16/2014 18:43:53.890] [main] [Remoting] Starting remoting
[INFO] [11/16/2014 18:43:54.739] [main] [Remoting] Remoting started; listening on addresses :[akka.tcp://[email protected]:2551]
[INFO] [11/16/2014 18:43:54.757] [main] [Cluster(akka://myCluster)] Cluster Node [akka.tcp://[email protected]:2551] - Starting up...
[INFO] [11/16/2014 18:43:54.848] [main] [Cluster(akka://myCluster)] Cluster Node [akka.tcp://[email protected]:2551] - Registered cluster JMX MBean [akka:type=Cluster]
[INFO] [11/16/2014 18:43:54.848] [main] [Cluster(akka://myCluster)] Cluster Node [akka.tcp://[email protected]:2551] - Started up successfully
[INFO] [11/16/2014 18:43:54.858] [myCluster-akka.actor.default-dispatcher-15] [Cluster(akka://myCluster)] Cluster Node [akka.tcp://[email protected]:2551] - 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] [11/16/2014 18:43:54.863] [myCluster-akka.actor.default-dispatcher-15] [Cluster(akka://myCluster)] Cluster Node [akka.tcp://[email protected]:2551] - Metrics collection has started successfully
[WARN] [11/16/2014 18:43:54.963] [myCluster-akka.remote.default-remote-dispatcher-6] [Remoting] Tried to associate with unreachable remote address [akka.tcp://[email protected]:2552]. Address is now gated for 5000 ms, all messages to this address will be delivered to dead letters. Reason: Connection refused: /10.0.0.5:2552
[INFO] [11/16/2014 18:43:54.972] [myCluster-akka.actor.default-dispatcher-16] [akka://myCluster/deadLetters] Message [akka.cluster.InternalClusterAction$InitJoin$] from Actor[akka://myCluster/system/cluster/core/daemon/firstSeedNodeProcess-1#-86755168] to Actor[akka://myCluster/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

Что я делаю неправильно?


person danny.lesnik    schedule 16.11.2014    source источник
comment
Какие именно команды / настройки вы используете для запуска каждого приложения? Это просто означает, что он не может достичь akka.tcp://[email protected]:2552 здесь.   -  person Dragisa Krsmanovic    schedule 17.11.2014


Ответы (2)


Вам необходимо предоставить порт для программы при ее запуске. Ваше значение netty.tcp.port по умолчанию равно 2551 в обоих случаях.

Пример того, как это сделать:

// 0 means a random unused port will be assigned
val port = if (args.isEmpty) "0" else args(0)
val config = ConfigFactory.parseString(s"akka.remote.netty.tcp.port=$port") //etc

Также см. примеры кластера, чтобы узнать, как это сделать.

person opyate    schedule 06.01.2015

person    schedule
comment
какой смысл использовать один и тот же порт на одном ip? вы просто скрываете проблему, что второй экземпляр приложения еще не доступен - person hicolour; 03.12.2014