2015-09-09 70 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 S和發現這一點:

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