2016-08-03 57 views
2

以下羣集單身人員未啓動。單身團隊演員未啓動

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

沒有引發錯誤消息。

日誌是:

[INFO] [2016年8月3日11:43:58.656] [ScalaTest - 運行 - 磨合ClusterSuite] [akka.remote.Remoting]啓動遠程 [INFO] [08/03/2016 11:43:59.007] [ScalaTest-run-running-ClusterSuite] [akka.remote.Remoting] Remoting開始了;監聽地址:[akka.tcp://[email protected]:59592] [INFO] [08/03/2016 11:43:59.035] [ScalaTest-run-running-ClusterSuite] [akka.cluster.Cluster (akka:// galaxyFarFarAway)]集羣節點[akka.tcp://[email protected]:59592] - 啓動... [INFO] [08/03/2016 11:43:59.218] [ScalaTest-運行 - 運行 - ClusterSuite] [akka.cluster.Cluster(akka:// galaxyFarFarAway)]集羣節點[akka.tcp://[email protected]:59592] - 已註冊的集羣JMX MBean [akka:type =集羣] [INFO] [08/03/2016 11:43:59.218] [ScalaTest-run-running-ClusterSuite] [akka.cluster.Cluster(akka:// galaxyFarFarAway)]集羣節點[akka.tcp://[email protected] .0.1:59592] - 成功啓動 [INFO] [08/03/2016 11:43:59.247] [galaxyFarFarAway-akka.actor.default-dispatcher-2] [akka.cluster.Cluster(akka:// galaxyFarFarAway )]集羣節點[akka.tcp:// galaxyFarFarAway @ 127 .0.0.1:59592] - 度量標準將從MBeans中檢索出來,並且在某些平臺上可能不正確。要提高度量準確性,請將'sigar.jar'添加到類路徑中,並將適當的特定於平臺的本機庫添加到'java.library.path'中。原因: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)]集羣節點[akka.tcp://[email protected]:59592] - 指標集合已成功啓動 [INFO] [08/03/2016 11:43:59.268] [galaxyFarFarAway- akka.actor.default-dispatcher-3] [akka.cluster.Cluster(akka:// galaxyFarFarAway)]集羣節點[akka.tcp://[email protected]:59592] - 沒有配置種子節點,手動集羣聯接所需 斷開從目標VM,地址: '127.0.0.1:59574',運輸: '插座'

的配置是:

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"] 
} 

當我調試Commander類的代碼時,構造函數甚至沒有被調用到任何地方。當我省略ClusterSingletonManager並僅用Props創建它時,它確實可行,但Commander演員即將創建。 我感覺這個問題背後的配置不正確。你們對此有何評論?

回答

2

您已經感覺非常正確:您沒有爲Akka集羣指定種子節點配置。您可以在日誌的最後一行看到這一點:

[akka.tcp://[email protected]:59592] - 無種子節點配置,手動加入集羣需要從目標VM斷開,地址:'127.0.0.1:59574',transport:'socket'

因爲您沒有在配置文件中指定任何種子節點,Akka會等待您以編程方式指定種子節點。你可以在這樣的配置指定種子節點:

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

或者,你可以調用joinSeedNodes方法加入集羣編程。在這兩種情況下,您必須指定至少一個可用的種子節點。參與者系統本身也可以充當種子節點。

一旦指定了種子節點並且參與者系統已經加入了羣集,Akka將依賴於羣集(羣集單身人士,分片等)功能將啓動。這就是爲什麼你可以發起一個普通的演員,但不是單身人士。

有關設置種子節點的更多信息,請參閱Akka cluster documentation