Chr*_*ris 4 scala akka akka-cluster
如何从被隔离的系统中检测隔离状态〜?
我在下面看到这个日志:
[warn] Remoting - Tried to associate with unreachable remote address [akka.tcp://Application@192.168.0.15:6000]. Address is now gated for 5000 ms, all messages to this address will be delivered to dead letters. Reason: The remote system has quarantined this system. No further associations to the remote system are possible until this system is restarted.
但我不确定如何从代码中对此作出反应.
我找到了这个帖子:从Quarantined状态恢复,建议侦听QuarantinedEvent但是在被隔离的系统上没有调度.
我实际上听了所有RemotingLifecycleEvents并发现了这个:
AssociationError [akka.tcp://Application@192.168.0.100:2552] -> [akka.tcp://Application@192.168.0.15:6000]: Error [Invalid address: akka.tcp://Application@192.168.0.15:6000] [akka.remote.InvalidAssociation: Invalid address: akka.tcp://Application@192.168.0.15:6000
Caused by: akka.remote.transport.Transport$InvalidAssociationException: The remote system has quarantined this system. No further associations to the remote system are possible until this system is restarted.]
但这也是一个AssociationError因为许多其他原因而被派遣的,我是否必须"The remote system has quarantined this system."在错误中搜索实际文本以确定?
是的,你建议的工作,可以按如下方式完成
订阅演员 akka.remote.AssociationErrorEvent
override def preStart(): Unit = {
context.system.eventStream.subscribe(self, classOf[akka.remote.AssociationErrorEvent])
}
Run Code Online (Sandbox Code Playgroud)
然后在receive方法中执行以下操作
override def receive: Receive = {
case e:AssociationErrorEvent =>
log.info(s"AssociationErrorEvent: $e")
if (e.cause.getCause.getMessage.contains("quarantined this system")) {
log.warning(s"We got quarantined")
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1946 次 |
| 最近记录: |