gpt4 book ai didi

scala - 单例集群参与者未启动

转载 作者:行者123 更新时间:2023-12-03 23:22:04 26 4
gpt4 key购买 nike

以下集群单例未启动。

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

不会抛出任何错误消息。

日志是:

[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://galaxyFarFarAway@127.0.0.1:59592] [INFO] [08/03/2016 11:43:59.035] [ScalaTest-run-running-ClusterSuite] [akka.cluster.Cluster(akka://galaxyFarFarAway)] Cluster Node [akka.tcp://galaxyFarFarAway@127.0.0.1:59592] - Starting up... [INFO] [08/03/2016 11:43:59.218] [ScalaTest-run-running-ClusterSuite] [akka.cluster.Cluster(akka://galaxyFarFarAway)] Cluster Node [akka.tcp://galaxyFarFarAway@127.0.0.1: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://galaxyFarFarAway@127.0.0.1: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://galaxyFarFarAway@127.0.0.1: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://galaxyFarFarAway@127.0.0.1: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://galaxyFarFarAway@127.0.0.1:59592] - No seed-nodes configured, manual cluster join required Disconnected from the target VM, address: '127.0.0.1:59574', transport: 'socket'



配置是:
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 Actor 将被创建。
我感觉到这个问题背后的配置不正确。大家对此有什么意见吗?

最佳答案

你感觉很对:你没有为 Akka 集群指定种子节点配置。您可以在日志的最后一行看到这一点:

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



因为您没有在配置文件中指定任何种子节点,所以 Akka 将等待您以编程方式指定种子节点。您可以像这样在配置中指定种子节点:
akka.cluster.seed-nodes = [
"akka.tcp://yourClusterSystem@127.0.0.1:2551",
"akka.tcp://yourClusterSystem@127.0.0.1:2552"
]

或者,您可以调用 joinSeedNodes以编程方式加入集群的方法。在这两种情况下,您都必须指定至少一个可用的种子节点。 Actor 系统本身也可以充当种子节点。

一旦指定了种子节点并且参与者系统加入了集群,依赖于集群的 Akka 特性(集群单例、分片等)将启动。这就是为什么你可以启动一个普通的actor,但不能启动单例。

有关设置种子节点的更多信息,请参阅 Akka cluster documentation .

关于scala - 单例集群参与者未启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38740194/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com