gpt4 book ai didi

java - Akka 集群 - 与远程系统的关联失败...原因 : [Association failed]

转载 作者:搜寻专家 更新时间:2023-11-01 03:33:01 27 4
gpt4 key购买 nike

我有一个简单的 POC,有两个 Actor :

public final class Task1Actor extends AbstractLoggingActor {
public Task1Actor() {
final UnitPFBuilder<Object> builder = ReceiveBuilder.create()
.matchAny(message -> {
log().warning("Received unknown message: {}", message);
unhandled(message);
});
receive(builder.build());
}

@Override
public void preStart() throws Exception {
IntStream.range(0, 5).forEach(i -> {
final ActorRef actor = context().actorOf(Props.create(Task2Actor.class));
actor.tell(RandomStringUtils.randomAlphabetic(10), self());
});
}
}

public final class Task2Actor extends AbstractLoggingActor {
public Task2Actor() {
final UnitPFBuilder<Object> builder = ReceiveBuilder.create()
.match(String.class, this::process)
.matchAny(message -> {
log().warning("Received unknown message: {}", message);
unhandled(message);
});
receive(builder.build());
}

private void process(final String message) {
log().debug("Processing message: {}", message);
// Do something useful here in the (not-so far) future
}
}

这是主类:

final class ClusterSample {
public static void main(final String... args) throws Exception {
ClusterSample.start(2251);
ClusterSample.start(2252);
ClusterSample.start(0);
}

private static void start(final int port) {
final Config config = ConfigFactory.parseString(String.format("akka.remote.netty.tcp.port = %s", port))
//.withFallback(ConfigFactory.parseString(String.format("akka.cluster.roles = [%s]", role)))
.withFallback(ConfigFactory.load("cluster"));
ActorSystem system = ActorSystem.create("ClusterSystem", config);
system.actorOf(Props.create(Task1Actor.class));
}
}

...这些是我的配置文件(分别是application.confcluster.conf):

akka {
actor {
default-dispatcher { throughput = 5 }
provider = cluster
}

cluster {
seed-nodes = [ "akka.tcp://ClusterSystem@127.0.0.1:2551", "akka.tcp://ClusterSystem@127.0.0.1:2552" ]
# roles = ["role"]
}

remote {
log-remote-lifecycle-events = off
netty.tcp {
hostname = 127.0.0.1
port = 0
}
}

loggers = [ "akka.event.slf4j.Slf4jLogger" ]

logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"

loglevel = DEBUG
}

include "application"

akka.cluster.min-nr-of-members = 2

akka.cluster.role {
watson.min-nr-of-members = 2
}

akka.actor.deployment {
}

我在这里试图实现的是从一个已经建立的流程中“形成一个集群”。所以我曾经有那些 Actor (实际上可以是任何流程),现在我试图让他们在(或作为)集群中工作。我刚开始阅读它,所以我对此不是很熟悉。

我得到的错误是:

03-09-2017 16:52:43.749 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-20] - Processing message: GCGboeqRKJ
03-09-2017 16:52:43.749 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-21] - Processing message: ykhePhziFT
03-09-2017 16:52:43.749 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-2] - Processing message: SFvnRAlGgg
03-09-2017 16:52:43.753 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-21] - Processing message: bMgBtCzWCI
03-09-2017 16:52:43.753 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-20] - Processing message: ifoOOmqbbv
03-09-2017 16:52:43.753 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-2] - Processing message: ZekwWXmmSQ
03-09-2017 16:52:43.754 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-21] - Processing message: MqXGoSQSzU
03-09-2017 16:52:43.754 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-20] - Processing message: NrdVYAFgrR
03-09-2017 16:52:43.754 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-2] - Processing message: GsjyIsxetC
03-09-2017 16:52:43.754 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-21] - Processing message: LpVNmbriXO
03-09-2017 16:52:43.754 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-20] - Processing message: HCFzOjJwnO
03-09-2017 16:52:43.755 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-2] - Processing message: iqflQMSeJF
03-09-2017 16:52:43.755 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-21] - Processing message: HlyMdMJfUs
03-09-2017 16:52:43.755 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-20] - Processing message: jlwxzLmRsF
03-09-2017 16:52:43.755 |- DEBUG in Task2Actor:88 [ClusterSystem-akka.actor.default-dispatcher-2] - Processing message: XPSmMYekCs
03-09-2017 16:52:43.794 |- WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-20] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2552] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2552]] Caused by: [Connection refused: /127.0.0.1:2552]
03-09-2017 16:52:43.794 |- WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-21] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2552] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2552]] Caused by: [Connection refused: /127.0.0.1:2552]
03-09-2017 16:52:43.794 |- WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-20] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2551] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2551]] Caused by: [Connection refused: /127.0.0.1:2551]
03-09-2017 16:52:43.794 |- WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-2] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2551] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2551]] Caused by: [Connection refused: /127.0.0.1:2551]
03-09-2017 16:52:43.795 |- WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-21] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2551] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2551]] Caused by: [Connection refused: /127.0.0.1:2551]
03-09-2017 16:52:43.796 |- WARN in ReliableDeliverySupervisor:78 [ClusterSystem-akka.actor.default-dispatcher-2] - Association with remote system [akka.tcp://ClusterSystem@127.0.0.1:2552] has failed, address is now gated for [5000] ms. Reason: [Association failed with [akka.tcp://ClusterSystem@127.0.0.1:2552]] Caused by: [Connection refused: /127.0.0.1:2552]

我在同一台机器上执行此操作,但没有使用这些端口...保证。我的 Gradle 配置中有所有依赖项,但仍然无法正常工作。

最佳答案

原来我使用的是不同的端口号; Java代码中的22522251,Akka配置中的25522551

更正错误会消失...但是,如果我打印出 Actor 的路径,我不会像 akka.tcp://那样看到它。 . . 但是 akka://。 . .,所以我假设整个集群也没有工作。一个不同的故事,也许还有另一个问题。

关于java - Akka 集群 - 与远程系统的关联失败...原因 : [Association failed],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42706365/

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