2015-09-09 2 views
3

Как я могу определить состояние Карантина из системы, находящейся в карантине ~?Обнаружение кластеров Akka Карантинированное состояние

Я вижу это бревно ниже:

[warn] Remoting - Tried to associate with unreachable remote address [akka.tcp://[email protected]: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.

, но я не знаю, как я могу реагировать на это из кода.


Я нашел эту тему: Recovering from the Quarantined state, предполагая для прослушивания QuarantinedEvent но не отправляется на систему быть помещены в карантин.

И я на самом деле слушал все RemotingLifecycleEvent с и нашел:

AssociationError [akka.tcp://[email protected]:2552] -> [akka.tcp://[email protected]:6000]: Error [Invalid address: akka.tcp://[email protected]:6000] [akka.remote.InvalidAssociation: Invalid address: akka.tcp://[email protected]: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." в пределах ошибки, чтобы быть уверен ??

ответ

5

Да, что вы предложили работу и можете быть сделаны следующим образом

Подписаться актер на akka.remote.AssociationErrorEvent

override def preStart(): Unit = { 
    context.system.eventStream.subscribe(self, classOf[akka.remote.AssociationErrorEvent]) 
} 

, а затем сделайте следующее в методе 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") 
    } 
} 
Смежные вопросы